[ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.

llvm-svn: 298346
This commit is contained in:
George Rimar 2017-03-21 08:29:48 +00:00
parent 35e846e14d
commit 9353e2dbfb
4 changed files with 7 additions and 14 deletions

View File

@ -162,10 +162,9 @@ uint64_t SectionBase::getOffset(const DefinedRegular &Sym) const {
return getOffset(Sym.Value);
}
template <class ELFT>
InputSectionBase *InputSectionBase::getLinkOrderDep() const {
if ((Flags & SHF_LINK_ORDER) && Link != 0)
return getFile<ELFT>()->getSections()[Link];
return File->getSections()[Link];
return nullptr;
}
@ -830,11 +829,6 @@ template void InputSectionBase::uncompress<ELF32BE>();
template void InputSectionBase::uncompress<ELF64LE>();
template void InputSectionBase::uncompress<ELF64BE>();
template InputSectionBase *InputSectionBase::getLinkOrderDep<ELF32LE>() const;
template InputSectionBase *InputSectionBase::getLinkOrderDep<ELF32BE>() const;
template InputSectionBase *InputSectionBase::getLinkOrderDep<ELF64LE>() const;
template InputSectionBase *InputSectionBase::getLinkOrderDep<ELF64BE>() const;
template InputSectionBase *InputSection::getRelocatedSection<ELF32LE>();
template InputSectionBase *InputSection::getRelocatedSection<ELF32BE>();
template InputSectionBase *InputSection::getRelocatedSection<ELF64LE>();

View File

@ -157,7 +157,7 @@ public:
return getFile<ELFT>()->getObj();
}
template <class ELFT> InputSectionBase *getLinkOrderDep() const;
InputSectionBase *getLinkOrderDep() const;
template <class ELFT> void uncompress();

View File

@ -69,14 +69,13 @@ OutputSection::OutputSection(StringRef Name, uint32_t Type, uint64_t Flags)
/*Info*/ 0,
/*Link*/ 0) {}
template <typename ELFT>
static bool compareByFilePosition(InputSection *A, InputSection *B) {
// Synthetic doesn't have link order dependecy, stable_sort will keep it last
if (A->kind() == InputSectionBase::Synthetic ||
B->kind() == InputSectionBase::Synthetic)
return false;
auto *LA = cast<InputSection>(A->template getLinkOrderDep<ELFT>());
auto *LB = cast<InputSection>(B->template getLinkOrderDep<ELFT>());
auto *LA = cast<InputSection>(A->getLinkOrderDep());
auto *LB = cast<InputSection>(B->getLinkOrderDep());
OutputSection *AOut = LA->OutSec;
OutputSection *BOut = LB->OutSec;
if (AOut != BOut)
@ -86,14 +85,14 @@ static bool compareByFilePosition(InputSection *A, InputSection *B) {
template <class ELFT> void OutputSection::finalize() {
if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {
std::sort(Sections.begin(), Sections.end(), compareByFilePosition<ELFT>);
std::sort(Sections.begin(), Sections.end(), compareByFilePosition);
assignOffsets();
// We must preserve the link order dependency of sections with the
// SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We
// need to translate the InputSection sh_link to the OutputSection sh_link,
// all InputSections in the OutputSection have the same dependency.
if (auto *D = this->Sections.front()->template getLinkOrderDep<ELFT>())
if (auto *D = this->Sections.front()->getLinkOrderDep())
this->Link = D->OutSec->SectionIndex;
}

View File

@ -2196,7 +2196,7 @@ void ARMExidxSentinelSection<ELFT>::writeTo(uint8_t *Buf) {
// Get the InputSection before us, we are by definition last
auto RI = cast<OutputSection>(this->OutSec)->Sections.rbegin();
InputSection *LE = *(++RI);
InputSection *LC = cast<InputSection>(LE->template getLinkOrderDep<ELFT>());
InputSection *LC = cast<InputSection>(LE->getLinkOrderDep());
uint64_t S = LC->OutSec->Addr + LC->getOffset(LC->getSize());
uint64_t P = this->getVA();
Target->relocateOne(Buf, R_ARM_PREL31, S - P);