diff options
-rw-r--r-- | lld/ELF/LinkerScript.cpp | 3 | ||||
-rw-r--r-- | lld/ELF/OutputSections.cpp | 14 | ||||
-rw-r--r-- | lld/ELF/OutputSections.h | 7 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 1 |
4 files changed, 8 insertions, 17 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 6e7b7756c82..b51cf80ca00 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -543,8 +543,7 @@ template <class ELFT> void LinkerScript<ELFT>::adjustSectionsBeforeSorting() { continue; } - auto *OutSec = new OutputSection<ELFT>(Cmd->Name, Type, Flags); - Out<ELFT>::Pool.emplace_back(OutSec); + auto *OutSec = make<OutputSection<ELFT>>(Cmd->Name, Type, Flags); OutputSections->push_back(OutSec); } } diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 9be3b3b9f4a..131aff520e8 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -10,8 +10,9 @@ #include "OutputSections.h" #include "Config.h" #include "EhFrame.h" -#include "LinkerScript.h" #include "GdbIndex.h" +#include "LinkerScript.h" +#include "Memory.h" #include "Strings.h" #include "SymbolTable.h" #include "Target.h" @@ -1881,24 +1882,23 @@ OutputSectionFactory<ELFT>::create(const SectionKey<ELFT::Is64Bits> &Key, uint32_t Type = C->Type; switch (C->kind()) { case InputSectionBase<ELFT>::Regular: - Sec = new OutputSection<ELFT>(Key.Name, Type, Flags); + Sec = make<OutputSection<ELFT>>(Key.Name, Type, Flags); break; case InputSectionBase<ELFT>::EHFrame: return {Out<ELFT>::EhFrame, false}; case InputSectionBase<ELFT>::Merge: - Sec = new MergeOutputSection<ELFT>(Key.Name, Type, Flags, Key.Alignment); + Sec = make<MergeOutputSection<ELFT>>(Key.Name, Type, Flags, Key.Alignment); break; case InputSectionBase<ELFT>::MipsReginfo: - Sec = new MipsReginfoOutputSection<ELFT>(); + Sec = make<MipsReginfoOutputSection<ELFT>>(); break; case InputSectionBase<ELFT>::MipsOptions: - Sec = new MipsOptionsOutputSection<ELFT>(); + Sec = make<MipsOptionsOutputSection<ELFT>>(); break; case InputSectionBase<ELFT>::MipsAbiFlags: - Sec = new MipsAbiFlagsOutputSection<ELFT>(); + Sec = make<MipsAbiFlagsOutputSection<ELFT>>(); break; } - Out<ELFT>::Pool.emplace_back(Sec); return {Sec, true}; } diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 2e039d09861..36cbf4e3a0a 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -773,9 +773,6 @@ template <class ELFT> struct Out { static OutputSectionBase<ELFT> *PreinitArray; static OutputSectionBase<ELFT> *InitArray; static OutputSectionBase<ELFT> *FiniArray; - - // This pool owns dynamically-allocated output sections. - static std::vector<std::unique_ptr<OutputSectionBase<ELFT>>> Pool; }; template <bool Is64Bits> struct SectionKey { @@ -842,10 +839,6 @@ template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders; template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::PreinitArray; template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::InitArray; template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::FiniArray; - -template <class ELFT> -std::vector<std::unique_ptr<OutputSectionBase<ELFT>>> Out<ELFT>::Pool; - } // namespace elf } // namespace lld diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 2c0057a8e94..2f9dc419c48 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -247,7 +247,6 @@ template <class ELFT> void elf::writeResult() { In<ELFT>::Sections = {BuildId.get()}; Writer<ELFT>().run(); - Out<ELFT>::Pool.clear(); } template <class ELFT> static std::vector<DefinedCommon *> getCommonSymbols() { |