[ELF] Make Partition members unique_ptr and remove associate make<XXX>

See D116143 for benefits. My lld executable (x86-64) is 103+KiB smaller.
This commit is contained in:
Fangrui Song
2021-12-22 21:34:25 -08:00
parent 9f3aca7eae
commit e48b1c8a27
5 changed files with 62 additions and 56 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)
if (&s == in.shStrTab.get() || &s == mainPart->relrDyn.get())
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)
if (&s == mainPart->gnuHashTab.get())
mainPart->gnuHashTab = nullptr;
if (&s == mainPart->hashTab)
if (&s == mainPart->hashTab.get())
mainPart->hashTab = nullptr;
s.markDead();