[ELF] - Move DependentSections vector from InputSection to InputSectionBase

I splitted it from D29273.
Since we plan to make relocatable sections as dependent for target ones for
--emit-relocs implementation, this change is required to support .eh_frame case.

EhInputSection inherets from InputSectionBase and not from InputSection.
So for case when it has relocation section, it should be able to access DependentSections
vector.

This case is real for Linux kernel.

Differential revision: https://reviews.llvm.org/D30084

llvm-svn: 295483
This commit is contained in:
George Rimar 2017-02-17 19:34:05 +00:00
parent fae3ac3e9b
commit 647c1685b6
3 changed files with 5 additions and 10 deletions

View File

@ -322,8 +322,7 @@ void elf::ObjectFile<ELFT>::initializeSections(
if (Sec.sh_link >= Sections.size())
fatal(toString(this) + ": invalid sh_link index: " +
Twine(Sec.sh_link));
auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
IS->DependentSections.push_back(Sections[I]);
Sections[Sec.sh_link]->DependentSections.push_back(Sections[I]);
}
}
}

View File

@ -128,6 +128,9 @@ public:
// this but instead this->Repl.
InputSectionBase<ELFT> *Repl;
// InputSections that are dependent on us (reverse dependency for GC)
llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
// Returns the size of this section (even if this is a common or BSS.)
size_t getSize() const;
@ -281,9 +284,6 @@ public:
// to. The writer sets a value.
uint64_t OutSecOff = 0;
// InputSections that are dependent on us (reverse dependency for GC)
llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
static bool classof(const InputSectionData *S);
InputSectionBase<ELFT> *getRelocatedSection();

View File

@ -298,11 +298,7 @@ void LinkerScript<ELFT>::discard(ArrayRef<InputSectionBase<ELFT> *> V) {
S->Live = false;
if (S == In<ELFT>::ShStrTab)
error("discarding .shstrtab section is not allowed");
InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
if (!IS || IS->DependentSections.empty())
continue;
discard(IS->DependentSections);
discard(S->DependentSections);
}
}