[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
This commit is contained in:
Rui Ueyama 2014-04-30 03:31:46 +00:00
parent bc03586bcc
commit 680210fe7d
2 changed files with 8 additions and 1 deletions

View File

@ -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;
}

View File

@ -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