diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 0f3fa04c079..54703b9912b 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -580,8 +580,9 @@ void ELFObjectWriter::WriteSymbol(MCDataFragment *SymtabF, ELFSymbolData &MSD, const MCAsmLayout &Layout) { MCSymbolData &OrigData = *MSD.SymbolData; - MCSymbolData &Data = - Layout.getAssembler().getSymbolData(OrigData.getSymbol().AliasedSymbol()); + const MCSymbol *Base = OrigData.getSymbol().getBaseSymbol(Layout); + const MCSymbolData &Data = + Base ? Layout.getAssembler().getSymbolData(*Base) : OrigData; bool IsReserved = Data.isCommon() || Data.getSymbol().isAbsolute() || Data.getSymbol().isVariable(); diff --git a/test/MC/ELF/offset.s b/test/MC/ELF/offset.s index 417a38d1d77..bc4252c1a78 100644 --- a/test/MC/ELF/offset.s +++ b/test/MC/ELF/offset.s @@ -6,6 +6,7 @@ .data .globl sym_a .byte 42 + .type sym_a, @object sym_a: // CHECK: Symbol { @@ -13,7 +14,7 @@ sym_a: // CHECK-NEXT: Value: 0x1 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None +// CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .data // CHECK-NEXT: } @@ -28,7 +29,7 @@ sym_c = sym_a // CHECK-NEXT: Value: 0x1 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None +// CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .data // CHECK-NEXT: } @@ -40,7 +41,7 @@ sym_d = sym_a + 1 // CHECK-NEXT: Value: 0x2 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None +// CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .data // CHECK-NEXT: } @@ -52,7 +53,20 @@ sym_e = sym_a + (sym_b - sym_a) * 3 // CHECK-NEXT: Value: 0xD // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Global -// CHECK-NEXT: Type: None +// CHECK-NEXT: Type: Object +// CHECK-NEXT: Other: 0 +// CHECK-NEXT: Section: .data +// CHECK-NEXT: } + + + .globl sym_f +sym_f = sym_a + (1 - 1) +// CHECK: Symbol { +// CHECK: Name: sym_f +// CHECK-NEXT: Value: 0x1 +// CHECK-NEXT: Size: 0 +// CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: Object // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .data // CHECK-NEXT: }