[lld] r207605 - [PECOFF] Fix priority of locally imported symbols.

Rui Ueyama ruiu at google.com
Tue Apr 29 20:31:46 PDT 2014


Author: ruiu
Date: Tue Apr 29 22:31:46 2014
New Revision: 207605

URL: http://llvm.org/viewvc/llvm-project?rev=207605&view=rev
Log:
[PECOFF] Fix priority of locally imported symbols.

Linker should create _imp_ symbols for local use only when such
symbols cannot be resolved in any other way. If it overrides real
imported symbols, such symbols remain virtually unresolved without
error, causing odd issues. I observed that a program linked with
LLD entered an infinite loop before reaching main() because of
this issue.

This patch moves the virtual file creating _imp_ symbols to the
very end of the input file list. Previously, the file is at the end
of the library file group. Linker might revisit the group many times,
so it was not really at the end of the input file list.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/test/pecoff/Inputs/drectve.obj.yaml

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=207605&r1=207604&r2=207605&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Tue Apr 29 22:31:46 2014
@@ -114,7 +114,8 @@ bool PECOFFLinkingContext::createImplici
   std::unique_ptr<SimpleFileNode> impFileNode(new SimpleFileNode("imp"));
   impFileNode->appendInputFile(
       std::unique_ptr<File>(new pecoff::LocallyImportedSymbolFile(*this)));
-  getLibraryGroup()->addFile(std::move(impFileNode));
+  getInputGraph().insertElementAt(std::move(impFileNode),
+                                  InputGraph::Position::END);
   return true;
 }
 

Modified: lld/trunk/test/pecoff/Inputs/drectve.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/drectve.obj.yaml?rev=207605&r1=207604&r2=207605&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/drectve.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/drectve.obj.yaml Tue Apr 29 22:31:46 2014
@@ -58,6 +58,12 @@ symbols:
     SimpleType:      IMAGE_SYM_TYPE_NULL
     ComplexType:     IMAGE_SYM_DTYPE_NULL
     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
+  - Name:            _fn
+    Value:           0
+    SectionNumber:   0
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
   - Name:            .drectve
     Value:           0
     SectionNumber:   2





More information about the llvm-commits mailing list