[PECOFF] Fix exported symbol in the import library
authorRui Ueyama <ruiu@google.com>
Tue, 21 Oct 2014 21:41:28 +0000 (21:41 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 21 Oct 2014 21:41:28 +0000 (21:41 +0000)
commit8bae8189b2020d461e5dc3b4cc7e24fbcc8bffeb
tree7921962addfeb3fde36a87c68272754a56d34036
parent0c6fed5716c75285181db8a20e5f84ddec11f76a
[PECOFF] Fix exported symbol in the import library

There are two ways to specify a symbol to be exported in the module
definition file.

1) EXPORT <external name> = <symbol>
2) EXPORT <symbol>

In (1), you give both external name and internal name. In that case,
the linker tries to find a symbol using the internal name, and write
that address to the export table with the external name. Thus, from
the outer world, the symbol seems to be exported as the external name.

In (2), internal name is basically the same as the external name
with an exception: if you give an undecorated symbol to the EXPORT
directive, and if the linker finds a decorated symbol, the external
name for the symbol will become the decorated symbol.

LLD didn't implement that exception correctly. This patch fixes that.

llvm-svn: 220333
lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/lib/Driver/WinLinkDriver.cpp
lld/lib/Driver/WinLinkModuleDef.cpp
lld/lib/ReaderWriter/PECOFF/EdataPass.cpp
lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp
lld/test/pecoff/export.test