From 9fdf9d2a1e4caffd6178cc35800d63fbb8c45d73 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 17 Mar 2014 04:29:51 +0000 Subject: [PATCH] Consider the base pointer for setting the symbol type. This is really a consistency fix. Since given a = b we propagate the information, we should propagate it too given a = b + (1 - 1) Fixes pr19145. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204028 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 5 +++-- test/MC/ELF/offset.s | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) 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: }