diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2016-09-05 15:42:29 +0000 |
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2016-09-05 15:42:29 +0000 |
| commit | d9ea6560210934515ab53d60dea224cd6c710656 (patch) | |
| tree | 8b8948f044a7cf8bb9d576e85d0e80bdbe3a57b3 | |
| parent | 305229bd72e61933d6287ed861eb22f22dbf35e3 (diff) | |
| download | bcm5719-llvm-d9ea6560210934515ab53d60dea224cd6c710656.tar.gz bcm5719-llvm-d9ea6560210934515ab53d60dea224cd6c710656.zip | |
[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
| -rw-r--r-- | lld/ELF/Writer.cpp | 6 | ||||
| -rw-r--r-- | lld/test/ELF/mips-tls-static.s | 23 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 396a2d8882d..b1c08d1fdad 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -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. diff --git a/lld/test/ELF/mips-tls-static.s b/lld/test/ELF/mips-tls-static.s new file mode 100644 index 00000000000..dbfd7697b24 --- /dev/null +++ b/lld/test/ELF/mips-tls-static.s @@ -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 |

