[PATCH] D45158: [ELF] - X86_64: don't allow 8/16 bit dynamic relocations.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 3 05:02:08 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD329059: [ELF] - X86_64: don't allow 8/16 bit dynamic relocations. (authored by grimar, committed by ).
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D45158
Files:
ELF/Arch/X86_64.cpp
test/ELF/x86-64-dyn-rel-error3.s
Index: ELF/Arch/X86_64.cpp
===================================================================
--- ELF/Arch/X86_64.cpp
+++ ELF/Arch/X86_64.cpp
@@ -156,8 +156,9 @@
}
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;
+ return Type != R_X86_64_8 && Type != R_X86_64_PC8 && Type != R_X86_64_16 &&
+ Type != R_X86_64_PC16 && Type != R_X86_64_32 &&
+ Type != R_X86_64_PC32 && Type != R_X86_64_TPOFF32;
}
template <class ELFT>
Index: test/ELF/x86-64-dyn-rel-error3.s
===================================================================
--- test/ELF/x86-64-dyn-rel-error3.s
+++ test/ELF/x86-64-dyn-rel-error3.s
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: not ld.lld %t.o -shared -o %t.so 2>&1 | FileCheck %s
+
+# CHECK: relocation R_X86_64_8 cannot be used against symbol foo; recompile with -fPIC
+# CHECK: relocation R_X86_64_16 cannot be used against symbol foo; recompile with -fPIC
+# CHECK: relocation R_X86_64_PC8 cannot be used against symbol foo; recompile with -fPIC
+# CHECK: relocation R_X86_64_PC16 cannot be used against symbol foo; recompile with -fPIC
+
+.global foo
+
+.data
+.byte foo # R_X86_64_8
+.short foo # R_X86_64_16
+.byte foo - . # R_X86_64_PC8
+.short foo - . # R_X86_64_PC16
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45158.140761.patch
Type: text/x-patch
Size: 1413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180403/3a287f54/attachment.bin>
More information about the llvm-commits
mailing list