If a symbol is global, reloc against it even if it is in a mergeable section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115817 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-10-06 19:27:21 +00:00
parent 9c220fc165
commit 153666c038
2 changed files with 18 additions and 3 deletions

View File

@ -539,12 +539,12 @@ static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
const MCSectionELF &Section =
static_cast<const MCSectionELF&>(Symbol.getSection());
if (Section.getFlags() & MCSectionELF::SHF_MERGE)
return Target.getConstant() != 0;
if (SD.isExternal())
return true;
if (Section.getFlags() & MCSectionELF::SHF_MERGE)
return Target.getConstant() != 0;
MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind();
const MCSectionELF &Sec2 =
static_cast<const MCSectionELF&>(F.getParent()->getSection());

View File

@ -12,9 +12,12 @@
movl $.Lfoo+2, %edi
jmp foo@PLT
movq foo@GOTPCREL, %rax
movq zed, %rax
.section .sec1,"aM",@progbits,16
.Lfoo:
zed:
.global zed
.section bar,"ax",@progbits
foo:
@ -39,6 +42,10 @@ foo:
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 4)
// Symbol number 8 is zed
// CHECK: # Symbol 8
// CHECK-NEXT: (('st_name', 11) # 'zed'
// Relocation 0 refers to symbol 1
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
@ -79,4 +86,12 @@ foo:
// CHECK-NEXT: ('r_type', 9
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 5 refers to symbol 8
// CHECK-NEXT: # Relocation 5
// CHECK-NEXT: (('r_offset', 35)
// CHECK-NEXT: ('r_sym', 8)
// CHECK-NEXT: ('r_type', 11)
// CHECK-NEXT: ('r_addend', 0)
// CHECK-NEXT: ),
// CHECK-NEXT: ])