From 8176d57d621b95833acf36500b88f4550e799e8b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 22 Feb 2016 23:19:29 +0000 Subject: [PATCH] Handle a weak undefined tls to archive member. A weak undefined should not fetch archive members, so we have to keep the Lazy symbol. That means the lazy symbol has to encode information about the original weak undef. Fixes pr25762. llvm-svn: 261591 --- lld/ELF/SymbolTable.cpp | 5 ++++- lld/test/ELF/Inputs/tls-in-archive.s | 3 +++ lld/test/ELF/tls-in-archive.s | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/Inputs/tls-in-archive.s create mode 100644 lld/test/ELF/tls-in-archive.s diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 145f17f..fab3bce 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -321,10 +321,13 @@ void SymbolTable::addMemberFile(Undefined *Undef, Lazy *L) { // If a strong undefined symbol never shows up, this lazy symbol will // get to the end of the link and must be treated as the weak undefined one. // We set UsedInRegularObj in a similar way to what is done with shared - // symbols and mark it as weak to reduce how many special cases are needed. + // symbols and copy information to reduce how many special cases are needed. if (Undef->isWeak()) { L->setUsedInRegularObj(); L->setWeak(); + + // FIXME: Do we need to copy more? + L->IsTls = Undef->IsTls; return; } diff --git a/lld/test/ELF/Inputs/tls-in-archive.s b/lld/test/ELF/Inputs/tls-in-archive.s new file mode 100644 index 0000000..0474a41 --- /dev/null +++ b/lld/test/ELF/Inputs/tls-in-archive.s @@ -0,0 +1,3 @@ + .type foo, @tls_object + .globl foo +foo: diff --git a/lld/test/ELF/tls-in-archive.s b/lld/test/ELF/tls-in-archive.s new file mode 100644 index 0000000..71f60e3 --- /dev/null +++ b/lld/test/ELF/tls-in-archive.s @@ -0,0 +1,11 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-in-archive.s -o %t1.o +// RUN: llvm-ar cru %t.a %t1.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +// RUN: ld.lld %t2.o %t.a -o %tout + + .globl _start +_start: + movq foo@gottpoff(%rip), %rax + .section .tbss,"awT",@nobits + .weak foo -- 2.7.4