1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Use a relocation against the symbol if it is a PLT and the symbol is in another

section. Common because of linkonce sections.

llvm-svn: 115718
This commit is contained in:
Rafael Espindola 2010-10-05 23:57:26 +00:00
parent 9096fe41cb
commit 8c7f9745de
2 changed files with 31 additions and 6 deletions

View File

@ -529,7 +529,8 @@ void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F,
}
static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
const MCValue &Target) {
const MCValue &Target,
const MCFragment &F) {
const MCSymbol &Symbol = SD.getSymbol();
if (Symbol.isUndefined())
return true;
@ -543,6 +544,14 @@ static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
if (SD.isExternal())
return true;
const llvm::MCSymbolRefExpr& Ref = *Target.getSymA();
const MCSectionELF &Sec2 =
static_cast<const MCSectionELF&>(F.getParent()->getSection());
if (Ref.getKind() == MCSymbolRefExpr::VK_PLT &&
&Sec2 != &Section)
return true;
return false;
}
@ -587,7 +596,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
return;
}
bool RelocOnSymbol = ShouldRelocOnSymbol(SD, Target);
bool RelocOnSymbol = ShouldRelocOnSymbol(SD, Target, *Fragment);
if (!RelocOnSymbol) {
Index = F->getParent()->getOrdinal();

View File

@ -10,10 +10,14 @@
movsd .Lfoo(%rip), %xmm1
movl $.Lfoo, %edi
movl $.Lfoo+2, %edi
jmp foo@PLT
.section .sec1,"aM",@progbits,16
.Lfoo:
.section bar,"ax",@progbits
foo:
// Section 4 is "sec1"
// CHECK: # Section 4
// CHECK-NEXT: (('sh_name', 18) # '.sec1'
@ -22,8 +26,12 @@
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 1) # '.Lfoo'
// Symbol number 5 is section 4
// CHECK: # Symbol 5
// Symbol number 2 is foo
// CHECK: # Symbol 2
// CHECK-NEXT: (('st_name', 7) # 'foo'
// Symbol number 6 is section 4
// CHECK: # Symbol 6
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 3)
@ -39,10 +47,10 @@
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 1 refers to symbol 5
// Relocation 1 refers to symbol 6
// CHECK-NEXT: # Relocation 1
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 5)
// CHECK-NEXT: ('r_sym', 6)
// CHECK-NEXT: ('r_type', 10)
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
@ -54,4 +62,12 @@
// CHECK-NEXT: ('r_type', 10
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 3 refers to symbol 2
// CHECK-NEXT: # Relocation 3
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 4
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// CHECK-NEXT: ])