[PATCH] D44993: Do not create R_X86_64_32S in dyna relo tbl

Han Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 28 12:22:00 PDT 2018


shenhan created this revision.
shenhan added a reviewer: ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.

We have a case that creates in the dynamic relocation table an R_X86_64_32S entry, which is not a valid dynamic relocation type at all.

Fixed by properly handle this in the back end.

BUG <https://bugs.llvm.org/show_bug.cgi?id=36923>


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44993

Files:
  ELF/Arch/X86_64.cpp
  test/ELF/Inputs/x86-64-reloc-32s-input.s
  test/ELF/x86-64-reloc-32s.s


Index: test/ELF/x86-64-reloc-32s.s
===================================================================
--- /dev/null
+++ test/ELF/x86-64-reloc-32s.s
@@ -0,0 +1,23 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc--linux %p/Inputs/x86-64-reloc-32s-input.s -o %t2.o
+// RUN: ld.lld -shared %t2.o -o %t2.so
+// RUN: ld.lld -e main -z notext %t.o %t2.so -o %t3.out
+// RUN: llvm-readobj -r %t3.out | FileCheck %s
+
+.data
+.long foo
+.type foo, at object
+.size foo, 8
+
+.text
+.globl main
+.type main, @function
+main:
+	movq	foo, %rax
+
+// CHECK:       Relocations [
+// CHECK-NEXT:      Section ({{.*}}) .rela.dyn {
+// CHECK-NEXT:          R_X86_64_COPY foo 0x0
+// CHECK-NEXT:      }
+// CHECK-NEXT:  ]
Index: test/ELF/Inputs/x86-64-reloc-32s-input.s
===================================================================
--- /dev/null
+++ test/ELF/Inputs/x86-64-reloc-32s-input.s
@@ -0,0 +1,5 @@
+.globl foo
+.type foo, at object
+.size foo, 8
+foo:
+	.quad 0x12
Index: ELF/Arch/X86_64.cpp
===================================================================
--- ELF/Arch/X86_64.cpp
+++ ELF/Arch/X86_64.cpp
@@ -157,7 +157,7 @@
 
 template <class ELFT> bool X86_64<ELFT>::isPicRel(RelType Type) const {
   return Type != R_X86_64_PC32 && Type != R_X86_64_32 &&
-         Type != R_X86_64_TPOFF32;
+    Type != R_X86_64_32S && Type != R_X86_64_TPOFF32;
 }
 
 template <class ELFT>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44993.140118.patch
Type: text/x-patch
Size: 1459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180328/eb30b584/attachment.bin>


More information about the llvm-commits mailing list