[ELF2] R_X86_64_64 plt relocation implemented.

This little patch is a final point in fix for https://llvm.org/bugs/show_bug.cgi?id=25175.

It`s make sample from issue description to work with -O0 optimization flag (with -O0 it generates R_X86_64_64 plt relocation).

Differential revision: http://reviews.llvm.org/D14153

llvm-svn: 251536
This commit is contained in:
George Rimar
2015-10-28 17:59:44 +00:00
parent 559d170021
commit 06f4e43d29
3 changed files with 15 additions and 19 deletions

View File

@@ -262,14 +262,9 @@ bool X86_64TargetInfo::relocNeedsGot(uint32_t Type, const SymbolBody &S) const {
}
unsigned X86_64TargetInfo::getPLTRefReloc(unsigned Type) const {
switch (Type) {
case R_X86_64_32:
return R_X86_64_32;
case R_X86_64_PC32:
case R_X86_64_PLT32:
if (Type == R_X86_64_PLT32)
return R_X86_64_PC32;
}
llvm_unreachable("Unexpected relocation");
return Type;
}
bool X86_64TargetInfo::relocNeedsPlt(uint32_t Type, const SymbolBody &S) const {
@@ -280,6 +275,7 @@ bool X86_64TargetInfo::relocNeedsPlt(uint32_t Type, const SymbolBody &S) const {
default:
return false;
case R_X86_64_32:
case R_X86_64_64:
case R_X86_64_PC32:
// This relocation is defined to have a value of (S + A - P).
// The problems start when a non PIC program calls a function in a shared

View File

@@ -7,8 +7,8 @@
// We used to record the wrong symbol index for this test
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
// CHECK-NEXT: 0x11000 R_X86_64_64 bar 0x0
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
// CHECK-NEXT: 0x120C8 R_X86_64_JUMP_SLOT bar 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]

View File

@@ -9,7 +9,7 @@
// CHECK: Index: 1
// CHECK-NEXT: Name: .dynsym
// CHECK: Name: .rela.dyn
// CHECK: Name: .rela.plt
// CHECK-NEXT: Type: SHT_RELA
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
@@ -28,24 +28,25 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_EXECINSTR
// CHECK-NEXT: ]
// CHECK-NEXT: Address: [[ADDR:.*]]
// CHECK-NEXT: Address: 0x11000
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: [[ADDR]]
// CHECK-NEXT: Type: R_X86_64_64
// CHECK-NEXT: Offset: 0x120C8
// CHECK-NEXT: Type: R_X86_64_JUMP_SLOT
// CHECK-NEXT: Symbol: bar
// CHECK-NEXT: Addend: 0x42
// CHECK-NEXT: Addend: 0x0
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK: DynamicSection [
// CHECK-NEXT: Tag Type Name/Value
// CHECK-NEXT: 0x0000000000000007 RELA [[RELAADDR]]
// CHECK-NEXT: 0x0000000000000008 RELASZ [[RELASIZE]] (bytes)
// CHECK-NEXT: 0x0000000000000009 RELAENT 24 (bytes)
// CHECK-NEXT: 0x0000000000000017 JMPREL 0x10200
// CHECK-NEXT: 0x0000000000000002 PLTRELSZ 24 (bytes)
// CHECK-NEXT: 0x0000000000000003 PLTGOT 0x120B0
// CHECK-NEXT: 0x0000000000000014 PLTREL RELA
// CHECK-NEXT: 0x0000000000000006 SYMTAB
// CHECK-NEXT: 0x000000000000000B SYMENT 24 (bytes)
// CHECK-NEXT: 0x0000000000000005 STRTAB
@@ -55,7 +56,6 @@
// CHECK-NEXT: 0x0000000000000000 NULL 0x0
// CHECK-NEXT: ]
.global _start
_start:
.quad bar + 0x42