[lld] r280666 - [ELF][MIPS] Support R_MIPS_TLS_DTPREL64 / R_MIPS_TLS_TPREL64 relocations calculation
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 5 08:42:43 PDT 2016
Author: atanasyan
Date: Mon Sep 5 10:42:43 2016
New Revision: 280666
URL: http://llvm.org/viewvc/llvm-project?rev=280666&view=rev
Log:
[ELF][MIPS] Support R_MIPS_TLS_DTPREL64 / R_MIPS_TLS_TPREL64 relocations calculation
Added:
lld/trunk/test/ELF/mips-tls-static-64.s
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=280666&r1=280665&r2=280666&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Sep 5 10:42:43 2016
@@ -2124,10 +2124,10 @@ void MipsTargetInfo<ELFT>::relocateOne(u
// 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(u
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:
Added: lld/trunk/test/ELF/mips-tls-static-64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-tls-static-64.s?rev=280666&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-tls-static-64.s (added)
+++ lld/trunk/test/ELF/mips-tls-static-64.s Mon Sep 5 10:42:43 2016
@@ -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
More information about the llvm-commits
mailing list