summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2015-10-06 00:45:42 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2015-10-06 00:45:42 +0000
commit4c46f57a4926559316e57e7e4e79267c80f277c5 (patch)
tree74085c5a293b8a666161fab757c5fd73f4b1c0cf
parente51c058ecc2d06b329e176a78487144828a7ae51 (diff)
downloadbcm5719-llvm-4c46f57a4926559316e57e7e4e79267c80f277c5.tar.gz
bcm5719-llvm-4c46f57a4926559316e57e7e4e79267c80f277c5.zip
[elf2] Ignore __tls_get_addr when static linking.
llvm-svn: 249365
-rw-r--r--lld/ELF/SymbolTable.cpp7
-rw-r--r--lld/test/elf2/tls-static.s8
2 files changed, 15 insertions, 0 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 14fcb3548a8..d077ce69065 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -133,6 +133,13 @@ template <class ELFT> void SymbolTable::init(uint16_t EMachine) {
// Given that the symbol is effectively unused, we just create a dummy
// hidden one to avoid the undefined symbol error.
addIgnoredSym<ELFT>("_GLOBAL_OFFSET_TABLE_");
+
+ // __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 (Config->Static)
+ addIgnoredSym<ELFT>("__tls_get_addr");
}
template <class ELFT> void SymbolTable::addELFFile(ELFFileBase *File) {
diff --git a/lld/test/elf2/tls-static.s b/lld/test/elf2/tls-static.s
new file mode 100644
index 00000000000..6d4a2a48233
--- /dev/null
+++ b/lld/test/elf2/tls-static.s
@@ -0,0 +1,8 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: lld -flavor gnu2 -static %t -o %tout
+// REQUIRES: x86
+
+.global _start
+.text
+_start:
+ call __tls_get_addr
OpenPOWER on IntegriCloud