[lld] r198041 - Fix a bug that undefined symbols are not reported if dead-stripping is enabled.

Rui Ueyama ruiu at google.com
Thu Dec 26 00:37:16 PST 2013


Author: ruiu
Date: Thu Dec 26 02:37:16 2013
New Revision: 198041

URL: http://llvm.org/viewvc/llvm-project?rev=198041&view=rev
Log:
Fix a bug that undefined symbols are not reported if dead-stripping is enabled.

There was a bug that the linker does not report an error if symbols specified
by -u (or /include on Windows) are not resolved. This patch fixes it by adding
such symbols to the dead strip root.

Modified:
    lld/trunk/lib/Core/Resolver.cpp
    lld/trunk/test/pecoff/export.test
    lld/trunk/test/pecoff/grouped-sections.test
    lld/trunk/test/pecoff/include.test

Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=198041&r1=198040&r2=198041&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Dec 26 02:37:16 2013
@@ -345,10 +345,6 @@ void Resolver::deadStripOptimize() {
   for (const StringRef &name : _context.deadStripRoots()) {
     const Atom *symAtom = _symbolTable.findByName(name);
     assert(symAtom);
-    if (symAtom->definition() == Atom::definitionUndefined)
-      // Dead-strip root atoms can be undefined at this point only when
-      // allowUndefines flag is on. Skip such undefines.
-      continue;
     _deadStripRoots.insert(symAtom);
   }
 

Modified: lld/trunk/test/pecoff/export.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/export.test?rev=198041&r1=198040&r2=198041&view=diff
==============================================================================
--- lld/trunk/test/pecoff/export.test (original)
+++ lld/trunk/test/pecoff/export.test Thu Dec 26 02:37:16 2013
@@ -1,6 +1,6 @@
 # RUN: yaml2obj %p/Inputs/export.obj.yaml > %t.obj
 #
-# RUN: lld -flavor link /out:%t1.dll /dll /entry:_init \
+# RUN: lld -flavor link /out:%t1.dll /dll /entry:init \
 # RUN:   /export:exportfn1 /export:exportfn2 -- %t.obj
 # RUN: llvm-objdump -s %t1.dll | FileCheck -check-prefix=CHECK1 %s
 
@@ -13,7 +13,7 @@ CHECK1-NEXT:  1040 72742e74 6573742e 746
 CHECK1-NEXT:  1050 00657870 6f727466 6e310065 78706f72
 CHECK1-NEXT:  1060 74666e32 00
 
-# RUN: lld -flavor link /out:%t2.dll /dll /subsystem:console /entry:_init \
+# RUN: lld -flavor link /out:%t2.dll /dll /subsystem:console /entry:init \
 # RUN:   /export:exportfn1, at 5 /export:exportfn2 -- %t.obj
 # RUN: llvm-objdump -s %t2.dll | FileCheck -check-prefix=CHECK2 %s
 
@@ -26,7 +26,7 @@ CHECK2-NEXT:  1040 72742e74 6573742e 746
 CHECK2-NEXT:  1050 00657870 6f727466 6e310065 78706f72
 CHECK2-NEXT:  1060 74666e32 00
 
-# RUN: lld -flavor link /out:%t3.dll /dll /subsystem:console /entry:_init \
+# RUN: lld -flavor link /out:%t3.dll /dll /subsystem:console /entry:init \
 # RUN:   /export:exportfn1, at 5,noname /export:exportfn2 -- %t.obj
 # RUN: llvm-objdump -s %t3.dll | FileCheck -check-prefix=CHECK3 %s
 

Modified: lld/trunk/test/pecoff/grouped-sections.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/grouped-sections.test?rev=198041&r1=198040&r2=198041&view=diff
==============================================================================
--- lld/trunk/test/pecoff/grouped-sections.test (original)
+++ lld/trunk/test/pecoff/grouped-sections.test Thu Dec 26 02:37:16 2013
@@ -1,6 +1,6 @@
 # RUN: yaml2obj %p/Inputs/grouped-sections.obj.yaml > %t.obj
 #
-# RUN: lld -flavor link /out:%t1 /subsystem:console \
+# RUN: lld -flavor link /out:%t1 /subsystem:console /entry:main \
 # RUN:   -- %t.obj && llvm-objdump -s %t1 | FileCheck %s
 #
 # The file "grouped-sections.obj" has three data sections in the following

Modified: lld/trunk/test/pecoff/include.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/include.test?rev=198041&r1=198040&r2=198041&view=diff
==============================================================================
--- lld/trunk/test/pecoff/include.test (original)
+++ lld/trunk/test/pecoff/include.test Thu Dec 26 02:37:16 2013
@@ -1,7 +1,7 @@
 # RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
 #
-# RUN: not lld -flavor link /out:%t1 /subsystem:console /opt:noref \
-# RUN:   /include:sym1 /include:sym2 -- %t.obj 2> %t1
+# RUN: not lld -flavor link /out:%t1 /include:sym1 /include:sym2 \
+# RUN:   /subsystem:console -- %t.obj 2> %t1
 # RUN: FileCheck %s < %t1
 
 CHECK: Undefined Symbol: command line option /include : sym1





More information about the llvm-commits mailing list