summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-10-10 17:27:34 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-10-10 17:27:34 +0000
commit97c57b9e7b0e74b99eb01f51631595330cefef7a (patch)
treecae27e4d57bc313eef0a79893ea1729093d11e2a
parent072eff0930ee651433bd5e756f8e76549425ae10 (diff)
downloadbcm5719-llvm-97c57b9e7b0e74b99eb01f51631595330cefef7a.tar.gz
bcm5719-llvm-97c57b9e7b0e74b99eb01f51631595330cefef7a.zip
Don't create a dummy __tls_get_addr.
We just don't need one with the current setup. We only error on undefined references that are used by some relocation. If we managed to relax all uses of __tls_get_addr, no relocation uses it and we don't produce an error. This is less code and fixes the case were we fail to relax. Before we would produce a broken output, but now we produce an error. llvm-svn: 315334
-rw-r--r--lld/ELF/Writer.cpp9
-rw-r--r--lld/test/ELF/arm-tls-norelax-gd-le.s4
-rw-r--r--lld/test/ELF/tls-static.s16
3 files changed, 16 insertions, 13 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 396e9ae1552..0cc506eddf6 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -799,15 +799,6 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() {
ElfSym::GlobalOffsetTable = addOptionalRegular<ELFT>(
"_GLOBAL_OFFSET_TABLE_", GotSection, Target->GotBaseSymOff);
- // __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 (!InX::DynSymTab)
- if (SymbolBody *S = Symtab->find("__tls_get_addr"))
- if (!S->isInCurrentDSO())
- Symtab->addAbsolute<ELFT>(S->getName(), STV_HIDDEN);
-
// __ehdr_start is the location of ELF file headers. Note that we define
// this symbol unconditionally even when using a linker script, which
// differs from the behavior implemented by GNU linker which only define
diff --git a/lld/test/ELF/arm-tls-norelax-gd-le.s b/lld/test/ELF/arm-tls-norelax-gd-le.s
index ba6c9003468..788c845b3f8 100644
--- a/lld/test/ELF/arm-tls-norelax-gd-le.s
+++ b/lld/test/ELF/arm-tls-norelax-gd-le.s
@@ -35,3 +35,7 @@ x:
// Module index is always 1 for executable
// CHECK-NEXT: 13060 01000000 00000000
+
+// Without any definition of __tls_get_addr we get an error
+// RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck --check-prefix=ERR %s
+// ERR: error: undefined symbol: __tls_get_addr
diff --git a/lld/test/ELF/tls-static.s b/lld/test/ELF/tls-static.s
index 81ecc82758d..338d95c817e 100644
--- a/lld/test/ELF/tls-static.s
+++ b/lld/test/ELF/tls-static.s
@@ -3,12 +3,20 @@
// RUN: ld.lld -static %t -o %tout
// RUN: ld.lld %t -o %tout
// RUN: ld.lld -shared %tso -o %tshared
-// RUN: not ld.lld -static %t %tshared -o %tout 2>&1 | FileCheck %s
+// RUN: ld.lld -static %t %tshared -o %tout
// REQUIRES: x86
.global _start
_start:
- call __tls_get_addr
+ data16
+ leaq foobar@TLSGD(%rip), %rdi
+ data16
+ data16
+ rex64
+ callq __tls_get_addr@PLT
-// CHECK: error: undefined symbol: __tls_get_addr
-// CHECK: >>> referenced by {{.*}}:(.text+0x1)
+
+.section .tdata,"awT",@progbits
+.global foobar
+foobar:
+ .long 42
OpenPOWER on IntegriCloud