diff options
author | Rui Ueyama <ruiu@google.com> | 2014-10-21 21:41:28 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-10-21 21:41:28 +0000 |
commit | 8bae8189b2020d461e5dc3b4cc7e24fbcc8bffeb (patch) | |
tree | 7921962addfeb3fde36a87c68272754a56d34036 /lld/lib/ReaderWriter/PECOFF | |
parent | 0c6fed5716c75285181db8a20e5f84ddec11f76a (diff) | |
download | bcm5719-llvm-8bae8189b2020d461e5dc3b4cc7e24fbcc8bffeb.tar.gz bcm5719-llvm-8bae8189b2020d461e5dc3b4cc7e24fbcc8bffeb.zip |
[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
Diffstat (limited to 'lld/lib/ReaderWriter/PECOFF')
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/EdataPass.cpp | 3 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp index 01339d1db57..368bb75cf9e 100644 --- a/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp @@ -62,7 +62,8 @@ static bool getExportedAtoms(PECOFFLinkingContext &ctx, MutableFile *file, // One can export a symbol with a different name than the symbol // name used in DLL. If such name is specified, use it in the // .edata section. - ret.push_back(TableEntry(desc.externalName, desc.ordinal, atom, desc.noname)); + ret.push_back(TableEntry(desc.getExternalName(), desc.ordinal, atom, + desc.noname)); } std::sort(ret.begin(), ret.end(), [](const TableEntry &a, const TableEntry &b) { diff --git a/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp b/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp index 16d64d4182e..789dff75740 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp @@ -30,7 +30,7 @@ createModuleDefinitionFile(const PECOFFLinkingContext &ctx) { << "EXPORTS\n"; for (const PECOFFLinkingContext::ExportDesc &desc : ctx.getDllExports()) { - os << " " << desc.externalName; + os << " " << desc.getExternalName(); if (!desc.isPrivate) os << " @" << desc.ordinal; if (desc.noname) |