Put in the symbol table symbols only used in a .globl statement.

Fixes PR9292.

llvm-svn: 126330
This commit is contained in:
Rafael Espindola 2011-02-23 20:22:07 +00:00
parent d9564589f6
commit 993a4ef35c
2 changed files with 31 additions and 1 deletions

View File

@ -833,7 +833,11 @@ static bool isInSymtab(const MCAssembler &Asm, const MCSymbolData &Data,
return true;
const MCSymbol &A = Symbol.AliasedSymbol();
if (!A.isVariable() && A.isUndefined() && !Data.isCommon())
if (Symbol.isVariable() && !A.isVariable() && A.isUndefined())
return false;
bool IsGlobal = GetBinding(Data) == ELF::STB_GLOBAL;
if (!Symbol.isVariable() && Symbol.isUndefined() && !IsGlobal)
return false;
if (!Asm.isSymbolLinkerVisible(Symbol) && !Symbol.isUndefined())

26
test/MC/ELF/pr9292.s Normal file
View File

@ -0,0 +1,26 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
// Test that both foo and bar are undefined.
.globl foo
.globl bar
mov %eax,bar
// CHECK: (('st_name', 0x00000005) # 'bar'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000000)
// CHECK-NEXT: ('st_value', 0x0000000000000000)
// CHECK-NEXT: ('st_size', 0x0000000000000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 0x00000005
// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000000)
// CHECK-NEXT: ('st_value', 0x0000000000000000)
// CHECK-NEXT: ('st_size', 0x0000000000000000)
// CHECK-NEXT: ),