Revert "[ELF] Make Partition/InStruct members unique_ptr and remove associate make<XXX>"

This reverts commit e48b1c8a27.
This reverts commit d019de23a1.

The changes caused memory leaks (non-final classes cannot use unique_ptr).
This commit is contained in:
Fangrui Song
2021-12-22 23:55:11 -08:00
parent d39d2acfdd
commit ad26b0b233
7 changed files with 118 additions and 131 deletions

View File

@@ -561,15 +561,15 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
}
void LinkerScript::discard(InputSectionBase &s) {
if (&s == in.shStrTab.get() || &s == mainPart->relrDyn.get())
if (&s == in.shStrTab || &s == mainPart->relrDyn)
error("discarding " + s.name + " section is not allowed");
// You can discard .hash and .gnu.hash sections by linker scripts. Since
// they are synthesized sections, we need to handle them differently than
// other regular sections.
if (&s == mainPart->gnuHashTab.get())
if (&s == mainPart->gnuHashTab)
mainPart->gnuHashTab = nullptr;
if (&s == mainPart->hashTab.get())
if (&s == mainPart->hashTab)
mainPart->hashTab = nullptr;
s.markDead();