summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-02-13 16:21:34 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-02-13 16:21:34 +0000
commitd6e9ef7e2136ca51607c82fb9da584a5598f6ece (patch)
tree788b7020e58331491044b4c40b3fa8620616918a
parenta62b8ce3233166f468acec6241253fe26ac06316 (diff)
downloadbcm5719-llvm-d6e9ef7e2136ca51607c82fb9da584a5598f6ece.tar.gz
bcm5719-llvm-d6e9ef7e2136ca51607c82fb9da584a5598f6ece.zip
Implement R_X86_64_16.
It is used by qemu. llvm-svn: 294965
-rw-r--r--lld/ELF/Target.cpp5
-rw-r--r--lld/test/ELF/Inputs/x86-64-reloc-16-error.s3
-rw-r--r--lld/test/ELF/Inputs/x86-64-reloc-16.s3
-rw-r--r--lld/test/ELF/x86-64-reloc-16.s14
4 files changed, 25 insertions, 0 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 8a28f4debe3..0826f4b81d5 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -650,6 +650,7 @@ RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
const SymbolBody &S) const {
switch (Type) {
case R_X86_64_8:
+ case R_X86_64_16:
case R_X86_64_32:
case R_X86_64_32S:
case R_X86_64_64:
@@ -879,6 +880,10 @@ void X86_64TargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
checkUInt<8>(Loc, Val, Type);
*Loc = Val;
break;
+ case R_X86_64_16:
+ checkUInt<16>(Loc, Val, Type);
+ write16le(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-16-error.s b/lld/test/ELF/Inputs/x86-64-reloc-16-error.s
new file mode 100644
index 00000000000..8deed64dbef
--- /dev/null
+++ b/lld/test/ELF/Inputs/x86-64-reloc-16-error.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 65536
diff --git a/lld/test/ELF/Inputs/x86-64-reloc-16.s b/lld/test/ELF/Inputs/x86-64-reloc-16.s
new file mode 100644
index 00000000000..c5b2f553604
--- /dev/null
+++ b/lld/test/ELF/Inputs/x86-64-reloc-16.s
@@ -0,0 +1,3 @@
+.globl foo
+.hidden foo
+foo = 0x42
diff --git a/lld/test/ELF/x86-64-reloc-16.s b/lld/test/ELF/x86-64-reloc-16.s
new file mode 100644
index 00000000000..2954d9900cf
--- /dev/null
+++ b/lld/test/ELF/x86-64-reloc-16.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-16.s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/x86-64-reloc-16-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_16 out of range
+
+.short foo
OpenPOWER on IntegriCloud