[lld] r280664 - [ELF][MIPS] Do not create a hidden definition for __tls_get_addr on MIPS
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 5 08:42:30 PDT 2016
Author: atanasyan
Date: Mon Sep 5 10:42:29 2016
New Revision: 280664
URL: http://llvm.org/viewvc/llvm-project?rev=280664&view=rev
Log:
[ELF][MIPS] Do not create a hidden definition for __tls_get_addr on MIPS
On most architectures the linker is required to optimize away any
references to __tls_get_addr in case of static linking. As usual
a special case is MIPS - libc defines __tls_get_addr itself because
there are no TLS optimizations for this architecture.
Added:
lld/trunk/test/ELF/mips-tls-static.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=280664&r1=280663&r2=280664&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Sep 5 10:42:29 2016
@@ -604,8 +604,10 @@ template <class ELFT> void Writer<ELFT>:
// __tls_get_addr is defined by the dynamic linker for dynamic ELFs. For
// static linking the linker is required to optimize away any references to
// __tls_get_addr, so it's not defined anywhere. Create a hidden definition
- // to avoid the undefined symbol error.
- if (!Out<ELFT>::DynSymTab)
+ // to avoid the undefined symbol error. As usual as special case is MIPS -
+ // MIPS libc defines __tls_get_addr itself because there are no TLS
+ // optimizations for this target.
+ if (!Out<ELFT>::DynSymTab && Config->EMachine != EM_MIPS)
Symtab<ELFT>::X->addIgnored("__tls_get_addr");
// If linker script do layout we do not need to create any standart symbols.
Added: lld/trunk/test/ELF/mips-tls-static.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-tls-static.s?rev=280664&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-tls-static.s (added)
+++ lld/trunk/test/ELF/mips-tls-static.s Mon Sep 5 10:42:29 2016
@@ -0,0 +1,23 @@
+# Check handling TLS related relocations and symbols when linking
+# a static executable.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t
+# RUN: ld.lld -static %t -o %t.exe
+# RUN: llvm-readobj -d %t.exe | FileCheck %s
+
+# REQUIRES: mips
+
+# CHECK: LoadName
+
+ .text
+ .global __start
+__start:
+ nop
+
+ .global __tls_get_addr
+__tls_get_addr:
+ nop
+
+ .data
+loc:
+ .word __tls_get_addr
More information about the llvm-commits
mailing list