summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-04-30 03:31:46 +0000
committerRui Ueyama <ruiu@google.com>2014-04-30 03:31:46 +0000
commit680210fe7de053f4745c01e8dbe99bd113f2c93a (patch)
treec290d17c1d4d579d13758a882d59e013ac80837a
parentbc03586bccd22d034810f3f58090ef53ed3c4e75 (diff)
downloadbcm5719-llvm-680210fe7de053f4745c01e8dbe99bd113f2c93a.tar.gz
bcm5719-llvm-680210fe7de053f4745c01e8dbe99bd113f2c93a.zip
[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. llvm-svn: 207605
-rw-r--r--lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp3
-rw-r--r--lld/test/pecoff/Inputs/drectve.obj.yaml6
2 files changed, 8 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
index d9117d05a5e..ff8ed1b4204 100644
--- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
@@ -114,7 +114,8 @@ bool PECOFFLinkingContext::createImplicitFiles(
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;
}
diff --git a/lld/test/pecoff/Inputs/drectve.obj.yaml b/lld/test/pecoff/Inputs/drectve.obj.yaml
index cc0c8255d46..22ec63f96e3 100644
--- a/lld/test/pecoff/Inputs/drectve.obj.yaml
+++ b/lld/test/pecoff/Inputs/drectve.obj.yaml
@@ -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
OpenPOWER on IntegriCloud