mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
Start fixing pr19147.
This makes the coff writer compute the correct symbol value for the test in pr19147. The section is still incorrect, that will be fixed in a followup patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
21b719dfcf
commit
b77f8919bc
@ -385,6 +385,18 @@ void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) {
|
|||||||
SectionMap[&SectionData.getSection()] = coff_section;
|
SectionMap[&SectionData.getSection()] = coff_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint64_t getSymbolValue(const MCSymbolData &Data,
|
||||||
|
const MCAsmLayout &Layout) {
|
||||||
|
if (Data.isCommon() && Data.isExternal())
|
||||||
|
return Data.getCommonSize();
|
||||||
|
|
||||||
|
uint64_t Res;
|
||||||
|
if (!Layout.getSymbolOffset(&Data, Res))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return Res;
|
||||||
|
}
|
||||||
|
|
||||||
/// This function takes a symbol data object from the assembler
|
/// This function takes a symbol data object from the assembler
|
||||||
/// and creates the associated COFF symbol staging object.
|
/// and creates the associated COFF symbol staging object.
|
||||||
void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
|
void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
|
||||||
@ -429,14 +441,7 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
|
|||||||
} else {
|
} else {
|
||||||
const MCSymbolData &ResSymData =
|
const MCSymbolData &ResSymData =
|
||||||
Assembler.getSymbolData(Symbol.AliasedSymbol());
|
Assembler.getSymbolData(Symbol.AliasedSymbol());
|
||||||
|
coff_symbol->Data.Value = getSymbolValue(ResSymData, Layout);
|
||||||
if (Symbol.isVariable()) {
|
|
||||||
int64_t Addr;
|
|
||||||
if (Symbol.getVariableValue()->EvaluateAsAbsolute(Addr, Layout))
|
|
||||||
coff_symbol->Data.Value = Addr;
|
|
||||||
} else if (SymbolData.isExternal() && SymbolData.isCommon()) {
|
|
||||||
coff_symbol->Data.Value = SymbolData.getCommonSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
coff_symbol->Data.Type = (ResSymData.getFlags() & 0x0000FFFF) >> 0;
|
coff_symbol->Data.Type = (ResSymData.getFlags() & 0x0000FFFF) >> 0;
|
||||||
coff_symbol->Data.StorageClass = (ResSymData.getFlags() & 0x00FF0000) >> 16;
|
coff_symbol->Data.StorageClass = (ResSymData.getFlags() & 0x00FF0000) >> 16;
|
||||||
@ -828,8 +833,6 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||||||
assert(Symbol->Section != nullptr);
|
assert(Symbol->Section != nullptr);
|
||||||
|
|
||||||
Symbol->Data.SectionNumber = Symbol->Section->Number;
|
Symbol->Data.SectionNumber = Symbol->Section->Number;
|
||||||
Symbol->Data.Value = Layout.getFragmentOffset(SymbolData->Fragment)
|
|
||||||
+ SymbolData->Offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Symbol->should_keep()) {
|
if (Symbol->should_keep()) {
|
||||||
|
19
test/MC/COFF/offset.s
Normal file
19
test/MC/COFF/offset.s
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s -o - | llvm-readobj -t -r | FileCheck %s
|
||||||
|
|
||||||
|
.data
|
||||||
|
.globl test1_foo
|
||||||
|
test1_foo:
|
||||||
|
.long 42
|
||||||
|
|
||||||
|
.globl test1_zed
|
||||||
|
test1_zed = test1_foo + 1
|
||||||
|
|
||||||
|
// CHECK: Symbol {
|
||||||
|
// CHECK: Name: test1_zed
|
||||||
|
// CHECK-NEXT: Value: 1
|
||||||
|
// CHECK-NEXT: Section:
|
||||||
|
// CHECK-NEXT: BaseType: Null
|
||||||
|
// CHECK-NEXT: ComplexType: Null
|
||||||
|
// CHECK-NEXT: StorageClass: External
|
||||||
|
// CHECK-NEXT: AuxSymbolCount: 0
|
||||||
|
// CHECK-NEXT: }
|
Loading…
x
Reference in New Issue
Block a user