[lld] r249160 - Weak undefined symbols should not fetch archive members.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 10:41:22 PDT 2015


Author: rafael
Date: Fri Oct  2 12:41:22 2015
New Revision: 249160

URL: http://llvm.org/viewvc/llvm-project?rev=249160&view=rev
Log:
Weak undefined symbols should not fetch archive members.

Added:
    lld/trunk/test/elf2/Inputs/archive2.s
Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/test/elf2/archive.s

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=249160&r1=249159&r2=249160&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Oct  2 12:41:22 2015
@@ -226,7 +226,7 @@ void SymbolTable::addLazy(Lazy *New) {
   if (Sym->Body == New)
     return;
   SymbolBody *Existing = Sym->Body;
-  if (Existing->isDefined() || Existing->isLazy())
+  if (Existing->isDefined() || Existing->isLazy() || Existing->isWeak())
     return;
   Sym->Body = New;
   assert(Existing->isUndefined() && "Unexpected symbol kind.");

Added: lld/trunk/test/elf2/Inputs/archive2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/Inputs/archive2.s?rev=249160&view=auto
==============================================================================
--- lld/trunk/test/elf2/Inputs/archive2.s (added)
+++ lld/trunk/test/elf2/Inputs/archive2.s Fri Oct  2 12:41:22 2015
@@ -0,0 +1,2 @@
+.global foo
+foo:

Modified: lld/trunk/test/elf2/archive.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/archive.s?rev=249160&r1=249159&r2=249160&view=diff
==============================================================================
--- lld/trunk/test/elf2/archive.s (original)
+++ lld/trunk/test/elf2/archive.s Fri Oct  2 12:41:22 2015
@@ -1,6 +1,7 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/archive.s -o %t2
-# RUN: llvm-ar rcs %tar %t2
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/archive2.s -o %t3
+# RUN: llvm-ar rcs %tar %t2 %t3
 # RUN: lld -flavor gnu2 %t %tar -o %tout
 # RUN: llvm-nm %tout | FileCheck %s
 # REQUIRES: x86
@@ -9,5 +10,9 @@
 
 .quad end
 
+.weak foo
+.quad foo
+
 # CHECK: T _start
 # CHECK: T end
+# CHECK: w foo




More information about the llvm-commits mailing list