[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.

llvm-svn: 280664
This commit is contained in:
Simon Atanasyan 2016-09-05 15:42:29 +00:00
parent 305229bd72
commit d9ea656021
2 changed files with 27 additions and 2 deletions

View File

@ -604,8 +604,10 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() {
// __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.

View File

@ -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