[PATCH] D14153: [ELF2] R_X86_64_64 plt relocation implemented.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 11:02:06 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL251536: [ELF2] R_X86_64_64 plt relocation implemented. (authored by grimar).

Changed prior to commit:
  http://reviews.llvm.org/D14153?vs=38672&id=38673#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14153

Files:
  lld/trunk/ELF/Target.cpp
  lld/trunk/test/elf2/dynamic-reloc-index.s
  lld/trunk/test/elf2/dynamic-reloc.s

Index: lld/trunk/test/elf2/dynamic-reloc.s
===================================================================
--- lld/trunk/test/elf2/dynamic-reloc.s
+++ lld/trunk/test/elf2/dynamic-reloc.s
@@ -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
Index: lld/trunk/test/elf2/dynamic-reloc-index.s
===================================================================
--- lld/trunk/test/elf2/dynamic-reloc-index.s
+++ lld/trunk/test/elf2/dynamic-reloc-index.s
@@ -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: ]
 
Index: lld/trunk/ELF/Target.cpp
===================================================================
--- lld/trunk/ELF/Target.cpp
+++ lld/trunk/ELF/Target.cpp
@@ -262,14 +262,9 @@
 }
 
 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 @@
   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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14153.38673.patch
Type: text/x-patch
Size: 3326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151028/39c83c10/attachment.bin>


More information about the llvm-commits mailing list