summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Schouten <ed@nuxi.nl>2016-04-06 17:53:31 +0000
committerEd Schouten <ed@nuxi.nl>2016-04-06 17:53:31 +0000
commit0a04b03ab2f58d87e296870718c9ecfd59c54e95 (patch)
tree7748c0bd874e22c462f2376e676136210d8998b3
parent615aca1a25959a66032d520009059f9be408880f (diff)
downloadbcm5719-llvm-0a04b03ab2f58d87e296870718c9ecfd59c54e95.tar.gz
bcm5719-llvm-0a04b03ab2f58d87e296870718c9ecfd59c54e95.zip
Make TLS work for PIE executables on aarch64.
Similar to r265462, TLS related relocations aren't marked as relative, meaning that we end up generating R_AARCH64_RELATIVE relocations for them. This change adds TLS relocations that I've seen on my system. With this patch applied CloudABI's unit testing binary now passes on aarch64. Approved by: ruiu Differential Revision: http://reviews.llvm.org/D18816 llvm-svn: 265575
-rw-r--r--lld/ELF/Target.cpp4
-rw-r--r--lld/test/ELF/aarch64-tls-pie.s28
2 files changed, 32 insertions, 0 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index a5893d23108..39f478e4353 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -1253,6 +1253,10 @@ bool AArch64TargetInfo::isRelRelative(uint32_t Type) const {
switch (Type) {
default:
return false;
+ case R_AARCH64_TLSLE_ADD_TPREL_HI12:
+ case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+ case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+ case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
case R_AARCH64_PREL32:
case R_AARCH64_ADR_PREL_LO21:
case R_AARCH64_ADR_PREL_PG_HI21:
diff --git a/lld/test/ELF/aarch64-tls-pie.s b/lld/test/ELF/aarch64-tls-pie.s
new file mode 100644
index 00000000000..466045d6765
--- /dev/null
+++ b/lld/test/ELF/aarch64-tls-pie.s
@@ -0,0 +1,28 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-cloudabi %s -o %t1.o
+# RUN: ld.lld -pie %t1.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+# Similar to bug 27174: R_AARCH64_TLSLE_*TPREL* relocations should be
+# eliminated when building a PIE executable, as the static TLS layout is
+# fixed.
+#
+# CHECK: Relocations [
+# CHECK-NEXT: ]
+
+ .globl _start
+_start:
+ # Accessing the variable directly.
+ add x11, x8, :tprel_hi12:i
+ add x11, x11, :tprel_lo12_nc:i
+
+ # Accessing the variable through the GOT.
+ adrp x10, :gottprel:i
+ mrs x8, TPIDR_EL0
+ ldr x10, [x10, :gottprel_lo12:i]
+
+ .section .tbss.i,"awT",@nobits
+ .globl i
+i:
+ .word 0
+ .size i, 4
OpenPOWER on IntegriCloud