[lld] r334534 - Handle R_X86_64_GOTOFF64.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 13:27:16 PDT 2018
Author: ruiu
Date: Tue Jun 12 13:27:16 2018
New Revision: 334534
URL: http://llvm.org/viewvc/llvm-project?rev=334534&view=rev
Log:
Handle R_X86_64_GOTOFF64.
R_X86_64_GOTOFF64 is a relocation type to set to a distance betwween
a symbol and the beginning of the .got section. Previously, we always
created a dynamic relocation for the relocation type even though it
can be resolved at link-time.
Creating a dynamic relocation for R_X86_64_GOTOFF64 caused link failure
for some programs that do have a relocation of the type in a .text
section, as text relocations are prohibited in most configurations.
Differential Revision: https://reviews.llvm.org/D48058
Added:
lld/trunk/test/ELF/x86-64-reloc-gotoff64.s
Modified:
lld/trunk/ELF/Arch/X86_64.cpp
Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=334534&r1=334533&r2=334534&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Tue Jun 12 13:27:16 2018
@@ -105,6 +105,8 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType
case R_X86_64_REX_GOTPCRELX:
case R_X86_64_GOTTPOFF:
return R_GOT_PC;
+ case R_X86_64_GOTOFF64:
+ return R_GOTREL;
case R_X86_64_GOTPC32:
case R_X86_64_GOTPC64:
return R_GOTONLY_PC_FROM_END;
@@ -323,6 +325,7 @@ void X86_64<ELFT>::relocateOne(uint8_t *
case R_X86_64_PC64:
case R_X86_64_SIZE64:
case R_X86_64_GOT64:
+ case R_X86_64_GOTOFF64:
case R_X86_64_GOTPC64:
write64le(Loc, Val);
break;
Added: lld/trunk/test/ELF/x86-64-reloc-gotoff64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-gotoff64.s?rev=334534&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-gotoff64.s (added)
+++ lld/trunk/test/ELF/x86-64-reloc-gotoff64.s Tue Jun 12 13:27:16 2018
@@ -0,0 +1,17 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -shared -o %t.so %t.o
+// RUN: llvm-readelf -sections %t.so | FileCheck %s
+// RUN: llvm-objdump -d %t.so | FileCheck -check-prefix=DISASM %s
+
+// CHECK: .dynamic DYNAMIC 0000000000002000 002000
+// CHECK: .got PROGBITS 0000000000002070 002070
+
+// DISASM: 1000: 48 ba 90 ff ff ff ff ff ff ff movabsq $-112, %rdx
+
+.global _start
+.weak _DYNAMIC
+.hidden _DYNAMIC
+_start:
+ movabsq $_DYNAMIC at GOTOFF, %rdx
More information about the llvm-commits
mailing list