Produce a R_X86_64_PLT32 when needed.

llvm-svn: 115541
This commit is contained in:
Rafael Espindola 2010-10-04 19:04:13 +00:00
parent d5a97fc683
commit baadbd554a
2 changed files with 24 additions and 1 deletions

View File

@ -581,7 +581,16 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
unsigned Type;
if (Is64Bit) {
if (IsPCRel) {
Type = ELF::R_X86_64_PC32;
switch (Modifier) {
case MCSymbolRefExpr::VK_None:
Type = ELF::R_X86_64_PC32;
break;
case MCSymbolRefExpr::VK_PLT:
Type = ELF::R_X86_64_PLT32;
break;
default:
llvm_unreachable("Unimplemented");
}
} else {
switch ((unsigned)Fixup.getKind()) {
default: llvm_unreachable("invalid fixup kind!");

14
llvm/test/MC/ELF/plt.s Normal file
View File

@ -0,0 +1,14 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
// Test that this produces a R_X86_64_PLT32.
jmp foo@PLT
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 4)
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// CHECK-NEXT: ])