Index: lld/trunk/ELF/LinkerScript.h =================================================================== --- lld/trunk/ELF/LinkerScript.h +++ lld/trunk/ELF/LinkerScript.h @@ -92,12 +92,13 @@ public: typedef PhdrEntry Phdr; + std::vector *> + createSections(OutputSectionFactory &Factory); + StringRef getOutputSection(InputSectionBase *S); ArrayRef getFiller(StringRef Name); bool isDiscarded(InputSectionBase *S); bool shouldKeep(InputSectionBase *S); - std::vector>> - createSections(OutputSectionFactory &Factory); void assignAddresses(ArrayRef *> S); int compareSections(StringRef A, StringRef B); void addScriptedSymbols(); Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -208,9 +208,10 @@ } template -std::vector>> +std::vector *> LinkerScript::createSections(OutputSectionFactory &Factory) { - std::vector>> Result; + std::vector *> Result; + // Add input section to output section. If there is no output section yet, // then create it and add to output section list. auto AddInputSec = [&](InputSectionBase *C, StringRef Name) { @@ -218,7 +219,7 @@ bool IsNew; std::tie(Sec, IsNew) = Factory.create(C, Name); if (IsNew) - Result.emplace_back(Sec); + Result.push_back(Sec); Sec->addSection(C); }; Index: lld/trunk/ELF/OutputSections.h =================================================================== --- lld/trunk/ELF/OutputSections.h +++ lld/trunk/ELF/OutputSections.h @@ -685,6 +685,7 @@ Key createKey(InputSectionBase *C, StringRef OutsecName); llvm::SmallDenseMap *> Map; + std::vector>> OwningSections; }; template BuildIdSection *Out::BuildId; Index: lld/trunk/ELF/OutputSections.cpp =================================================================== --- lld/trunk/ELF/OutputSections.cpp +++ lld/trunk/ELF/OutputSections.cpp @@ -1770,6 +1770,7 @@ Sec = new MipsOptionsOutputSection(); break; } + OwningSections.emplace_back(Sec); return {Sec, true}; } Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -48,7 +48,7 @@ void copyLocalSymbols(); void addReservedSymbols(); - std::vector>> createSections(); + std::vector *> createSections(); void finalizeSections(); void addPredefinedSections(); bool needsGot(); @@ -218,13 +218,9 @@ copyLocalSymbols(); addReservedSymbols(); - std::vector>> Sections = - ScriptConfig->DoLayout ? Script::X->createSections(Factory) - : createSections(); - - for (std::unique_ptr> &S : Sections) - OutputSections.push_back(S.get()); - + OutputSections = ScriptConfig->DoLayout + ? Script::X->createSections(Factory) + : createSections(); finalizeSections(); if (HasError) return; @@ -637,9 +633,8 @@ } template -std::vector>> -Writer::createSections() { - std::vector>> Result; +std::vector *> Writer::createSections() { + std::vector *> Result; for (const std::unique_ptr> &F : Symtab.getObjectFiles()) { @@ -652,8 +647,7 @@ bool IsNew; std::tie(Sec, IsNew) = Factory.create(C, getOutputSectionName(C)); if (IsNew) - Result.emplace_back(Sec); - + Result.push_back(Sec); Sec->addSection(C); } }