[PATCH] D38660: Don't create a dummy __tls_get_addr
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 19:09:58 PDT 2017
rafael created this revision.
Herald added subscribers: javed.absar, emaste.
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.
https://reviews.llvm.org/D38660
Files:
ELF/Writer.cpp
test/ELF/arm-tls-norelax-gd-le.s
test/ELF/tls-static.s
Index: test/ELF/tls-static.s
===================================================================
--- test/ELF/tls-static.s
+++ 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 at TLSGD(%rip), %rdi
+ data16
+ data16
+ rex64
+ callq __tls_get_addr at PLT
-// CHECK: error: undefined symbol: __tls_get_addr
-// CHECK: >>> referenced by {{.*}}:(.text+0x1)
+
+.section .tdata,"awT", at progbits
+.global foobar
+foobar:
+ .long 42
Index: test/ELF/arm-tls-norelax-gd-le.s
===================================================================
--- test/ELF/arm-tls-norelax-gd-le.s
+++ test/ELF/arm-tls-norelax-gd-le.s
@@ -35,3 +35,7 @@
// 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
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -799,15 +799,6 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38660.118122.patch
Type: text/x-patch
Size: 2165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171007/203a2223/attachment.bin>
More information about the llvm-commits
mailing list