diff options
-rw-r--r-- | lld/ELF/OutputSections.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/OutputSections.h | 7 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 1 |
3 files changed, 8 insertions, 2 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 3485737a4ce..8371fe473ba 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1765,7 +1765,7 @@ OutputSectionFactory<ELFT>::create(InputSectionBase<ELFT> *C, case InputSectionBase<ELFT>::Layout: llvm_unreachable("Invalid section type"); } - OwningSections.emplace_back(Sec); + Out<ELFT>::Pool.emplace_back(Sec); return {Sec, true}; } diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index e915127c5a3..cf1f2f0cd9c 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -752,6 +752,9 @@ 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 { @@ -779,7 +782,6 @@ private: Key createKey(InputSectionBase<ELFT> *C, StringRef OutsecName); llvm::SmallDenseMap<Key, OutputSectionBase<ELFT> *> Map; - std::vector<std::unique_ptr<OutputSectionBase<ELFT>>> OwningSections; }; template <class ELFT> BuildIdSection<ELFT> *Out<ELFT>::BuildId; @@ -813,6 +815,9 @@ 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 ac716c5ec6b..416ef76a45d 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -221,6 +221,7 @@ template <class ELFT> void elf::writeResult() { Out<ELFT>::FiniArray = nullptr; Writer<ELFT>().run(); + Out<ELFT>::Pool.clear(); } template <class ELFT> |