Simplify output section ownership management.
One reason why we are (ab)using OutputSectionFactory class is because it owns output sections. Technically there's no need to have it own sections. So, this patch transfers the ownership to Out<ELFT>. llvm-svn: 278452
This commit is contained in:
parent
a6707f56b5
commit
bdf836db1b
|
@ -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};
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ template <class ELFT> void elf::writeResult() {
|
|||
Out<ELFT>::FiniArray = nullptr;
|
||||
|
||||
Writer<ELFT>().run();
|
||||
Out<ELFT>::Pool.clear();
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
|
|
Loading…
Reference in New Issue