mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Compute the correct section for zed = foo + 1 in COFF.
This fixes pr19147. There are a few more related issues to fix, but the testcase in the bug now passes. llvm-svn: 207763
This commit is contained in:
parent
6b3eacf852
commit
4ce7e8e6df
@ -441,6 +441,7 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
|
||||
} else {
|
||||
const MCSymbolData &ResSymData =
|
||||
Assembler.getSymbolData(Symbol.AliasedSymbol());
|
||||
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
||||
coff_symbol->Data.Value = getSymbolValue(ResSymData, Layout);
|
||||
|
||||
coff_symbol->Data.Type = (ResSymData.getFlags() & 0x0000FFFF) >> 0;
|
||||
@ -454,11 +455,14 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
|
||||
external ? COFF::IMAGE_SYM_CLASS_EXTERNAL : COFF::IMAGE_SYM_CLASS_STATIC;
|
||||
}
|
||||
|
||||
if (Symbol.isAbsolute() || Symbol.AliasedSymbol().isVariable())
|
||||
if (!Base) {
|
||||
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
|
||||
else if (ResSymData.Fragment)
|
||||
coff_symbol->Section =
|
||||
SectionMap[&ResSymData.Fragment->getParent()->getSection()];
|
||||
} else {
|
||||
const MCSymbolData &BaseData = Assembler.getSymbolData(*Base);
|
||||
if (BaseData.Fragment)
|
||||
coff_symbol->Section =
|
||||
SectionMap[&BaseData.Fragment->getParent()->getSection()];
|
||||
}
|
||||
|
||||
coff_symbol->MCData = &ResSymData;
|
||||
}
|
||||
@ -826,14 +830,9 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
||||
Header.NumberOfSymbols = 0;
|
||||
|
||||
for (auto & Symbol : Symbols) {
|
||||
MCSymbolData const *SymbolData = Symbol->MCData;
|
||||
|
||||
// Update section number & offset for symbols that have them.
|
||||
if (SymbolData && SymbolData->Fragment) {
|
||||
assert(Symbol->Section != nullptr);
|
||||
|
||||
if (Symbol->Section)
|
||||
Symbol->Data.SectionNumber = Symbol->Section->Number;
|
||||
}
|
||||
|
||||
if (Symbol->should_keep()) {
|
||||
MakeSymbolReal(*Symbol, Header.NumberOfSymbols++);
|
||||
|
@ -11,7 +11,7 @@ test1_zed = test1_foo + 1
|
||||
// CHECK: Symbol {
|
||||
// CHECK: Name: test1_zed
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: Section:
|
||||
// CHECK-NEXT: Section: .data
|
||||
// CHECK-NEXT: BaseType: Null
|
||||
// CHECK-NEXT: ComplexType: Null
|
||||
// CHECK-NEXT: StorageClass: External
|
||||
|
Loading…
Reference in New Issue
Block a user