[lld] r261591 - Handle a weak undefined tls to archive member.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 15:19:29 PST 2016


Author: rafael
Date: Mon Feb 22 17:19:29 2016
New Revision: 261591

URL: http://llvm.org/viewvc/llvm-project?rev=261591&view=rev
Log:
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.

Added:
    lld/trunk/test/ELF/Inputs/tls-in-archive.s
    lld/trunk/test/ELF/tls-in-archive.s
Modified:
    lld/trunk/ELF/SymbolTable.cpp

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=261591&r1=261590&r2=261591&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Mon Feb 22 17:19:29 2016
@@ -321,10 +321,13 @@ void SymbolTable<ELFT>::addMemberFile(Un
   // 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;
   }
 

Added: lld/trunk/test/ELF/Inputs/tls-in-archive.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/tls-in-archive.s?rev=261591&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/tls-in-archive.s (added)
+++ lld/trunk/test/ELF/Inputs/tls-in-archive.s Mon Feb 22 17:19:29 2016
@@ -0,0 +1,3 @@
+        .type foo, @tls_object
+        .globl  foo
+foo:

Added: lld/trunk/test/ELF/tls-in-archive.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-in-archive.s?rev=261591&view=auto
==============================================================================
--- lld/trunk/test/ELF/tls-in-archive.s (added)
+++ lld/trunk/test/ELF/tls-in-archive.s Mon Feb 22 17:19:29 2016
@@ -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 at gottpoff(%rip), %rax
+        .section        .tbss,"awT", at nobits
+        .weak   foo




More information about the llvm-commits mailing list