mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 07:30:31 +00:00
coff: fix the section of weak symbols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a8a201a894
commit
8d48aba10b
@ -359,6 +359,13 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
||||
MCAssembler &Assembler,
|
||||
const MCAsmLayout &Layout) {
|
||||
COFFSymbol *coff_symbol = GetOrCreateCOFFSymbol(&Symbol);
|
||||
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
||||
COFFSection *Sec = nullptr;
|
||||
if (Base && Base->getFragment()) {
|
||||
Sec = SectionMap[Base->getFragment()->getParent()];
|
||||
if (coff_symbol->Section && coff_symbol->Section != Sec)
|
||||
report_fatal_error("conflicting sections for symbol");
|
||||
}
|
||||
|
||||
if (cast<MCSymbolCOFF>(Symbol).isWeakExternal()) {
|
||||
coff_symbol->Data.StorageClass = COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL;
|
||||
@ -374,7 +381,12 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
||||
} else {
|
||||
std::string WeakName = (".weak." + Symbol.getName() + ".default").str();
|
||||
COFFSymbol *WeakDefault = createSymbol(WeakName);
|
||||
WeakDefault->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
|
||||
|
||||
if (!Sec)
|
||||
WeakDefault->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
|
||||
else
|
||||
WeakDefault->Section = Sec;
|
||||
|
||||
WeakDefault->Data.StorageClass = COFF::IMAGE_SYM_CLASS_EXTERNAL;
|
||||
WeakDefault->Data.Type = 0;
|
||||
WeakDefault->Data.Value = getSymbolValue(Symbol, Layout);
|
||||
@ -391,7 +403,6 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
||||
|
||||
coff_symbol->MC = &Symbol;
|
||||
} else {
|
||||
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
||||
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
|
||||
|
||||
const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(Symbol);
|
||||
@ -408,18 +419,10 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
||||
: COFF::IMAGE_SYM_CLASS_STATIC;
|
||||
}
|
||||
|
||||
if (!Base) {
|
||||
if (!Base)
|
||||
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
|
||||
} else {
|
||||
if (Base->getFragment()) {
|
||||
COFFSection *Sec = SectionMap[Base->getFragment()->getParent()];
|
||||
|
||||
if (coff_symbol->Section && coff_symbol->Section != Sec)
|
||||
report_fatal_error("conflicting sections for symbol");
|
||||
|
||||
coff_symbol->Section = Sec;
|
||||
}
|
||||
}
|
||||
else
|
||||
coff_symbol->Section = Sec;
|
||||
|
||||
coff_symbol->MC = &Symbol;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ b:
|
||||
// CHECK-NEXT: Symbol {
|
||||
// CHECK-NEXT: Name: .weak.b.default
|
||||
// CHECK-NEXT: Value: 4
|
||||
// CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
|
||||
// CHECK-NEXT: Section: .data (2)
|
||||
// CHECK-NEXT: BaseType: Null (0x0)
|
||||
// CHECK-NEXT: ComplexType: Null (0x0)
|
||||
// CHECK-NEXT: StorageClass: External (0x2)
|
||||
|
Loading…
Reference in New Issue
Block a user