[PATCH] D47098: [ELF] Support R_X86_64_GOTPC{32,64}
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 09:48:49 PDT 2018
MaskRay updated this revision to Diff 150973.
MaskRay added a comment.
Proof of .got end
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D47098
Files:
ELF/Arch/X86_64.cpp
ELF/Relocations.cpp
test/ELF/x86-64-reloc-got.s
Index: test/ELF/x86-64-reloc-got.s
===================================================================
--- /dev/null
+++ test/ELF/x86-64-reloc-got.s
@@ -0,0 +1,21 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld %t.o -shared -o %t.so
+// RUN: llvm-readelf -s %t.so | FileCheck %s -check-prefix=SECTION
+// RUN: llvm-objdump -d %t.so | FileCheck %s
+
+// SECTION: .got PROGBITS 0000000000003070 003070 000000
+// The size is 0.
+
+// 0x3070 (.got end) - 0x1007 = 8297
+// CHECK: R_X86_64_GOTPC32:
+// CHECK-NEXT: 1000: {{.*}} leaq 8297(%rip), %r15
+.global R_X86_64_GOTPC32
+R_X86_64_GOTPC32:
+ leaq _GLOBAL_OFFSET_TABLE_(%rip), %r15
+
+// CHECK: R_X86_64_GOTPC64:
+// CHECK-NEXT: 1007: {{.*}} movabsq $8297, %r11
+.global R_X86_64_GOTPC64
+R_X86_64_GOTPC64:
+ movabsq $_GLOBAL_OFFSET_TABLE_-., %r11
Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -347,7 +347,7 @@
if (isRelExprOneOf<R_GOT_FROM_END, R_GOT_OFF, R_MIPS_GOT_LOCAL_PAGE,
R_MIPS_GOTREL, R_MIPS_GOT_OFF, R_MIPS_GOT_OFF32,
R_MIPS_GOT_GP_PC, R_MIPS_TLSGD, R_GOT_PAGE_PC, R_GOT_PC,
- R_GOTONLY_PC, R_GOTONLY_PC_FROM_END, R_PLT_PC, R_TLSGD_GOT,
+ R_GOTONLY_PC, R_GOTONLY_PC_FROM_END, R_GOTREL_FROM_END, R_PLT_PC, R_TLSGD_GOT,
R_TLSGD_PC, R_TLSGD, R_PPC_CALL_PLT, R_TLSDESC_CALL,
R_TLSDESC_PAGE, R_HINT>(E))
return true;
Index: ELF/Arch/X86_64.cpp
===================================================================
--- ELF/Arch/X86_64.cpp
+++ ELF/Arch/X86_64.cpp
@@ -105,6 +105,9 @@
case R_X86_64_REX_GOTPCRELX:
case R_X86_64_GOTTPOFF:
return R_GOT_PC;
+ case R_X86_64_GOTPC32:
+ case R_X86_64_GOTPC64:
+ return R_GOTONLY_PC_FROM_END;
case R_X86_64_NONE:
return R_NONE;
default:
@@ -300,6 +303,7 @@
case R_X86_64_32S:
case R_X86_64_TPOFF32:
case R_X86_64_GOT32:
+ case R_X86_64_GOTPC32:
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCRELX:
case R_X86_64_REX_GOTPCRELX:
@@ -319,6 +323,7 @@
case R_X86_64_PC64:
case R_X86_64_SIZE64:
case R_X86_64_GOT64:
+ case R_X86_64_GOTPC64:
write64le(Loc, Val);
break;
default:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47098.150973.patch
Type: text/x-patch
Size: 2325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180612/dfd7d484/attachment.bin>
More information about the llvm-commits
mailing list