summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-01-18 02:20:53 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-01-18 02:20:53 +0000
commitae30386fb31157499f0e610558f6de57f77681c1 (patch)
tree48dea49cbb67e311c9b8e2fa7f7034c86ef6a930
parent367c86ddbec5d9da7c4390f0df72adac544f0d1d (diff)
downloadbcm5719-llvm-ae30386fb31157499f0e610558f6de57f77681c1.tar.gz
bcm5719-llvm-ae30386fb31157499f0e610558f6de57f77681c1.zip
ELF: Add support for relocation type R_X86_64_8.
Although this relocation type is not part of the x86-64 psABI, I intend to use it internally as part of the ThinLTO implementation. Differential Revision: https://reviews.llvm.org/D28841 llvm-svn: 292330
-rw-r--r--lld/ELF/Target.cpp5
-rw-r--r--lld/test/ELF/Inputs/x86-64-reloc-8-error.s3
-rw-r--r--lld/test/ELF/Inputs/x86-64-reloc-8.s3
-rw-r--r--lld/test/ELF/x86-64-reloc-8.s14
4 files changed, 25 insertions, 0 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 55fcf1734d1..1adbb5f9893 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -631,6 +631,7 @@ template <class ELFT>
RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
const SymbolBody &S) const {
switch (Type) {
+ case R_X86_64_8:
case R_X86_64_32:
case R_X86_64_32S:
case R_X86_64_64:
@@ -857,6 +858,10 @@ template <class ELFT>
void X86_64TargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
uint64_t Val) const {
switch (Type) {
+ case R_X86_64_8:
+ checkUInt<8>(Loc, Val, Type);
+ *Loc = Val;
+ break;
case R_X86_64_32:
checkUInt<32>(Loc, Val, Type);
write32le(Loc, Val);
diff --git a/lld/test/ELF/Inputs/x86-64-reloc-8-error.s b/lld/test/ELF/Inputs/x86-64-reloc-8-error.s
new file mode 100644
index 00000000000..b6a7626456d
--- /dev/null
+++ b/lld/test/ELF/Inputs/x86-64-reloc-8-error.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 256
diff --git a/lld/test/ELF/Inputs/x86-64-reloc-8.s b/lld/test/ELF/Inputs/x86-64-reloc-8.s
new file mode 100644
index 00000000000..c5b2f553604
--- /dev/null
+++ b/lld/test/ELF/Inputs/x86-64-reloc-8.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 0x42
diff --git a/lld/test/ELF/x86-64-reloc-8.s b/lld/test/ELF/x86-64-reloc-8.s
new file mode 100644
index 00000000000..1c3831fafa2
--- /dev/null
+++ b/lld/test/ELF/x86-64-reloc-8.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-8.s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-8-error.s -o %t2
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: ld.lld -shared %t %t1 -o %t3
+
+// CHECK: Contents of section .text:
+// CHECK-NEXT: 200000 42
+
+// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
+// ERROR: relocation R_X86_64_8 out of range
+
+.byte foo
OpenPOWER on IntegriCloud