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

Correctly handle GOTPCREL relocations.

llvm-svn: 115793
This commit is contained in:
Rafael Espindola 2010-10-06 16:23:36 +00:00
parent 57f707c6a7
commit 0c327e6e77
2 changed files with 15 additions and 3 deletions

View File

@ -544,12 +544,12 @@ static bool ShouldRelocOnSymbol(const MCSymbolData &SD,
if (SD.isExternal())
return true;
const llvm::MCSymbolRefExpr& Ref = *Target.getSymA();
MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind();
const MCSectionELF &Sec2 =
static_cast<const MCSectionELF&>(F.getParent()->getSection());
if (Ref.getKind() == MCSymbolRefExpr::VK_PLT &&
&Sec2 != &Section)
if (&Sec2 != &Section &&
(Kind == MCSymbolRefExpr::VK_PLT || Kind == MCSymbolRefExpr::VK_GOTPCREL))
return true;
return false;
@ -648,6 +648,9 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
case MCSymbolRefExpr::VK_GOT:
Type = ELF::R_X86_64_GOT32;
break;
case llvm::MCSymbolRefExpr::VK_GOTPCREL:
Type = ELF::R_X86_64_GOTPCREL;
break;
default:
llvm_unreachable("Unimplemented");
}

View File

@ -11,6 +11,7 @@
movl $.Lfoo, %edi
movl $.Lfoo+2, %edi
jmp foo@PLT
movq foo@GOTPCREL, %rax
.section .sec1,"aM",@progbits,16
.Lfoo:
@ -70,4 +71,12 @@ foo:
// CHECK-NEXT: ('r_type', 4
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 4 refers to symbol 2
// CHECK-NEXT: # Relocation 4
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 9
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// CHECK-NEXT: ])