Implement more alias cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115699 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-10-05 22:26:43 +00:00
parent d350e4757e
commit 01f9ea35a7
2 changed files with 48 additions and 0 deletions

View File

@ -807,9 +807,20 @@ void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm) {
MSD.SymbolData = it;
MSD.StringIndex = Entry;
// FIXME: There is duplicated code with the local case.
if (it->isCommon()) {
MSD.SectionIndex = ELF::SHN_COMMON;
ExternalSymbolData.push_back(MSD);
} else if (Symbol.isVariable()) {
const MCExpr *Value = Symbol.getVariableValue();
assert (Value->getKind() == MCExpr::SymbolRef && "Unimplemented");
const MCSymbolRefExpr *Ref = static_cast<const MCSymbolRefExpr*>(Value);
const MCSymbol &RefSymbol = Ref->getSymbol();
if (RefSymbol.isDefined()) {
MSD.SectionIndex = SectionIndexMap.lookup(&RefSymbol.getSection());
assert(MSD.SectionIndex && "Invalid section index!");
ExternalSymbolData.push_back(MSD);
}
} else if (Symbol.isUndefined()) {
MSD.SectionIndex = ELF::SHN_UNDEF;
// FIXME: Undefined symbols are global, but this is the first place we

View File

@ -3,6 +3,13 @@
foo:
bar = foo
.globl foo2
foo2 = bar2
foo3:
.globl bar3
bar3 = foo3
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 5) # 'bar'
// CHECK-NEXT: ('st_bind', 0)
@ -20,3 +27,33 @@ bar = foo
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 3
// CHECK-NEXT: (('st_name', 9) # 'foo3'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 4
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 5
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 6
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 7
// CHECK-NEXT: (('st_name', 24) # 'bar3'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 8
// CHECK-NEXT: (('st_name', 19) # 'bar2'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 0)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)