diff options
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h | 17 | ||||
-rw-r--r-- | lld/test/pecoff/export.test | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h index 409dd640211..4feaec6c753 100644 --- a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h +++ b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h @@ -250,18 +250,16 @@ public: : VirtualArchiveLibraryFile("<export>"), _syms(syms), _ctx(const_cast<PECOFFLinkingContext *>(&ctx)) { for (PECOFFLinkingContext::ExportDesc &desc : _ctx->getDllExports()) - _exportedSyms[desc.name] = &desc; + _exportedSyms.insert(desc.name); } const File *find(StringRef sym, bool dataSymbolOnly) const override { typedef PECOFFLinkingContext::ExportDesc ExportDesc; - auto it = _exportedSyms.find(sym); - if (it == _exportedSyms.end()) + if (_exportedSyms.count(sym) == 0) return nullptr; std::string replace; if (!findDecoratedSymbol(_ctx, _syms.get(), sym.str(), replace)) return nullptr; - ExportDesc *desc = it->second; // We found a decorated symbol. There may be another symbol that // has the same decorated name. If that's the case, we remove the @@ -273,10 +271,15 @@ public: if (isFound != exp.end()) { exp.erase( std::remove_if(exp.begin(), exp.end(), - [&](ExportDesc &e) { return &e == desc; }), + [&](ExportDesc &e) { return e.name == sym; }), exp.end()); } else { - it->second->name = replace; + for (ExportDesc &e : exp) { + if (e.name == sym) { + e.name = replace; + break; + } + } if (_ctx->deadStrip()) _ctx->addDeadStripRoot(_ctx->allocate(replace)); } @@ -285,7 +288,7 @@ public: } private: - std::map<std::string, PECOFFLinkingContext::ExportDesc *> _exportedSyms; + std::set<std::string> _exportedSyms; std::shared_ptr<ResolvableSymbols> _syms; mutable llvm::BumpPtrAllocator _alloc; mutable PECOFFLinkingContext *_ctx; diff --git a/lld/test/pecoff/export.test b/lld/test/pecoff/export.test index cbe8960e26f..dd73c41ba8b 100644 --- a/lld/test/pecoff/export.test +++ b/lld/test/pecoff/export.test @@ -62,6 +62,7 @@ CHECK6: Ordinal RVA Name CHECK6-NEXT: 1 0x2010 ?exportfn8@@YAXXZ # RUN: lld -flavor link /out:%t6.dll /dll /entry:init \ +# RUN: /export:exportfn7 /export:exportfn7@8 \ # RUN: /export:exportfn8 /export:exportfn8 /export:exportfn3 -- %t.obj # RUN: llvm-objdump -p %t6.dll | FileCheck -check-prefix=DUP %s @@ -70,6 +71,7 @@ DUP: DLL name: export.test.tmp6.dll DUP: Ordinal RVA Name DUP-NEXT: 1 0x2010 ?exportfn8@@YAXXZ DUP-NEXT: 2 0x2010 exportfn3@256 +DUP-NEXT: 3 0x2010 exportfn7@8 DUP-NOT: ?exportfn8@@YAXXZ DUP-NOT: exportfn3@256 |