summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Target.cpp6
-rw-r--r--lld/test/ELF/mips-tls-static-64.s37
2 files changed, 41 insertions, 2 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index b0ecced3a90..98bb8dbab0c 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -2124,10 +2124,10 @@ void MipsTargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
// Thread pointer and DRP offsets from the start of TLS data area.
// https://www.linux-mips.org/wiki/NPTL
if (Type == R_MIPS_TLS_DTPREL_HI16 || Type == R_MIPS_TLS_DTPREL_LO16 ||
- Type == R_MIPS_TLS_DTPREL32)
+ Type == R_MIPS_TLS_DTPREL32 || Type == R_MIPS_TLS_DTPREL64)
Val -= 0x8000;
else if (Type == R_MIPS_TLS_TPREL_HI16 || Type == R_MIPS_TLS_TPREL_LO16 ||
- Type == R_MIPS_TLS_TPREL32)
+ Type == R_MIPS_TLS_TPREL32 || Type == R_MIPS_TLS_TPREL64)
Val -= 0x7000;
if (ELFT::Is64Bits)
std::tie(Type, Val) = calculateMips64RelChain(Type, Val);
@@ -2139,6 +2139,8 @@ void MipsTargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
write32<E>(Loc, Val);
break;
case R_MIPS_64:
+ case R_MIPS_TLS_DTPREL64:
+ case R_MIPS_TLS_TPREL64:
write64<E>(Loc, Val);
break;
case R_MIPS_26:
diff --git a/lld/test/ELF/mips-tls-static-64.s b/lld/test/ELF/mips-tls-static-64.s
new file mode 100644
index 00000000000..e7baf67bb29
--- /dev/null
+++ b/lld/test/ELF/mips-tls-static-64.s
@@ -0,0 +1,37 @@
+# Check handling TLS related relocations and symbols when linking
+# a 64-bit static executable.
+
+# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t
+# RUN: ld.lld -static %t -o %t.exe
+# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
+
+# REQUIRES: mips
+
+# CHECK: Contents of section .data:
+# CHECK-NEXT: 40000 00020004 ffffffff ffff8004 ffffffff
+# CHECK-NEXT: 40010 ffff9004
+#
+# CHECK: SYMBOL TABLE:
+# CHECK: 0000000000020004 .text 00000000 __tls_get_addr
+# CHECK: 0000000000000000 g .tdata 00000000 tls1
+
+ .text
+ .global __start
+__start:
+ nop
+
+ .global __tls_get_addr
+__tls_get_addr:
+ nop
+
+ .data
+loc:
+ .word __tls_get_addr
+ .dtpreldword tls1+4 # R_MIPS_TLS_DTPREL64
+ .tpreldword tls1+4 # R_MIPS_TLS_TPREL64
+
+ .section .tdata,"awT",%progbits
+ .global tls1
+tls1:
+ .word __tls_get_addr
+ .word 0
OpenPOWER on IntegriCloud