forked from OSchip/llvm-project
[ELF] Refactor how .gnu.hash and .hash are discarded
Switch to the D114180 approach which is simpler and allows gnuHashTab/hashTab to switch to unique_ptr.
This commit is contained in:
parent
b592cbf329
commit
43d927984c
|
@ -564,14 +564,6 @@ void LinkerScript::discard(InputSectionBase &s) {
|
|||
if (&s == in.shStrTab.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)
|
||||
mainPart->gnuHashTab = nullptr;
|
||||
else if (&s == mainPart->hashTab)
|
||||
mainPart->hashTab = nullptr;
|
||||
|
||||
s.markDead();
|
||||
s.parent = nullptr;
|
||||
for (InputSection *sec : s.dependentSections)
|
||||
|
|
|
@ -1464,9 +1464,9 @@ DynamicSection<ELFT>::computeContents() {
|
|||
addInt(DT_STRSZ, part.dynStrTab->getSize());
|
||||
if (!config->zText)
|
||||
addInt(DT_TEXTREL, 0);
|
||||
if (part.gnuHashTab)
|
||||
if (part.gnuHashTab && part.gnuHashTab->getParent())
|
||||
addInSec(DT_GNU_HASH, *part.gnuHashTab);
|
||||
if (part.hashTab)
|
||||
if (part.hashTab && part.hashTab->getParent())
|
||||
addInSec(DT_HASH, *part.hashTab);
|
||||
|
||||
if (isMain) {
|
||||
|
|
Loading…
Reference in New Issue