From: Rui Ueyama Date: Tue, 22 Jul 2014 22:55:06 +0000 (+0000) Subject: [PECOFF] Parameterize ResovalbeSymbols object. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97d7c29fbc100eb5c8a0ce0025b9d8beb173088a;p=platform%2Fupstream%2Fllvm.git [PECOFF] Parameterize ResovalbeSymbols object. So that it can be shared by multiple input files. llvm-svn: 213699 --- diff --git a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h index 131d55d..14576e26 100644 --- a/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h +++ b/lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h @@ -232,14 +232,13 @@ private: // next visit. class ExportedSymbolRenameFile : public impl::VirtualArchiveLibraryFile { public: - ExportedSymbolRenameFile(const PECOFFLinkingContext &ctx) - : VirtualArchiveLibraryFile("") { + ExportedSymbolRenameFile(const PECOFFLinkingContext &ctx, + std::shared_ptr syms) + : VirtualArchiveLibraryFile(""), _syms(syms) { for (const PECOFFLinkingContext::ExportDesc &desc : ctx.getDllExports()) _exportedSyms.insert(desc.name); } - void addResolvableSymbols(File *file) { _syms.add(file); } - const File *find(StringRef sym, bool dataSymbolOnly) const override { if (_exportedSyms.count(sym) == 0) return nullptr; @@ -254,7 +253,7 @@ private: // by @number suffix. bool findSymbolWithAtsignSuffix(std::string sym, std::string &res) const { sym.append("@"); - const std::set &defined = _syms.defined(); + const std::set &defined = _syms->defined(); auto it = defined.lower_bound(sym); for (auto e = defined.end(); it != e; ++it) { if (!StringRef(*it).startswith(sym)) @@ -271,7 +270,7 @@ private: } std::set _exportedSyms; - mutable ResolvableSymbols _syms; + mutable std::shared_ptr _syms; mutable llvm::BumpPtrAllocator _alloc; }; diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index 67cc919..0ac9869 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -119,14 +119,15 @@ bool PECOFFLinkingContext::createImplicitFiles( getInputGraph().insertElementAt(std::move(impFileNode), InputGraph::Position::END); + std::shared_ptr syms( + new pecoff::ResolvableSymbols()); + getInputGraph().registerObserver([=](File *file) { syms->add(file); }); + // Create a file for dllexported symbols. std::unique_ptr exportNode(new SimpleFileNode("")); - pecoff::ExportedSymbolRenameFile *renameFile = - new pecoff::ExportedSymbolRenameFile(*this); + auto *renameFile = new pecoff::ExportedSymbolRenameFile(*this, syms); exportNode->appendInputFile(std::unique_ptr(renameFile)); getLibraryGroup()->addFile(std::move(exportNode)); - getInputGraph().registerObserver( - [=](File *file) { renameFile->addResolvableSymbols(file); }); return true; }