[PECOFF] Fix module definition file output

Previously we emit two or more identical definitions for an
exported symbol if the same /export option is given more than
once. This patch fixes that bug.

llvm-svn: 218433
This commit is contained in:
Rui Ueyama 2014-09-25 00:52:38 +00:00
parent b35a72ae9e
commit 1b0e68353d
2 changed files with 15 additions and 9 deletions

View File

@ -266,16 +266,12 @@ void PECOFFLinkingContext::addDllExport(ExportDesc &desc) {
// Scan the vector to look for existing entry. It's not very fast,
// but because the number of exported symbol is usually not that
// much, it should be okay.
ExportDesc *existing = nullptr;
for (ExportDesc &e : _dllExports) {
if (e.name == desc.name) {
existing = &e;
break;
}
}
if (existing && !sameExportDesc(*existing, desc)) {
llvm::errs() << "Export symbol '" << desc.name
<< "' specified more than once.\n";
if (e.name != desc.name)
continue;
if (!sameExportDesc(e, desc))
llvm::errs() << "Export symbol '" << desc.name
<< "' specified more than once.\n";
return;
}
_dllExports.push_back(desc);

View File

@ -59,3 +59,13 @@ CHECK6: Export Table:
CHECK6: DLL name: export.test.tmp6.dll
CHECK6: Ordinal RVA Name
CHECK6-NEXT: 1 0x2010 exportfn8
# RUN: lld -flavor link /out:%t6.dll /dll /entry:init \
# RUN: /export:exportfn8 /export:exportfn8 -- %t.obj
# RUN: llvm-objdump -p %t6.dll | FileCheck -check-prefix=DUP %s
DUP: Export Table:
DUP: DLL name: export.test.tmp6.dll
DUP: Ordinal RVA Name
DUP: 1 0x2010 exportfn8
DUP-NOT: 1 0x2010 exportfn8