Convert EhOutputSection to be a synthetic section.

With this we complete the transition out of special output sections,
and with the previous patches it should be possible to merge
OutputSectionBase and OuputSection.

llvm-svn: 296023
This commit is contained in:
Rafael Espindola
2017-02-23 22:06:28 +00:00
parent e199f285b0
commit 66b4e21534
9 changed files with 282 additions and 278 deletions

View File

@@ -318,7 +318,6 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
SHF_ALLOC | SHF_WRITE);
In<ELFT>::DynStrTab = make<StringTableSection<ELFT>>(".dynstr", true);
In<ELFT>::Dynamic = make<DynamicSection<ELFT>>();
Out<ELFT>::EhFrame = make<EhOutputSection<ELFT>>();
In<ELFT>::RelaDyn = make<RelocationSection<ELFT>>(
Config->Rela ? ".rela.dyn" : ".rel.dyn", Config->ZCombreloc);
In<ELFT>::ShStrTab = make<StringTableSection<ELFT>>(".shstrtab", false);
@@ -444,6 +443,11 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
Add(In<ELFT>::EhFrameHdr);
}
if (!Config->Relocatable) {
In<ELFT>::EhFrame = make<EhFrameSection<ELFT>>();
Add(In<ELFT>::EhFrame);
}
if (In<ELFT>::SymTab)
Add(In<ELFT>::SymTab);
Add(In<ELFT>::ShStrTab);
@@ -1088,10 +1092,10 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
// Define __rel[a]_iplt_{start,end} symbols if needed.
addRelIpltSymbols();
if (!Out<ELFT>::EhFrame->empty()) {
OutputSections.push_back(Out<ELFT>::EhFrame);
Out<ELFT>::EhFrame->finalize();
}
// This responsible for splitting up .eh_frame section into
// pieces. The relocation scan uses those peaces, so this has to be
// earlier.
finalizeSynthetic<ELFT>({In<ELFT>::EhFrame});
// Scan relocations. This must be done after every symbol is declared so that
// we can correctly decide if a dynamic relocation is needed.
@@ -1323,7 +1327,7 @@ template <class ELFT> std::vector<PhdrEntry> Writer<ELFT>::createPhdrs() {
Ret.push_back(std::move(RelRo));
// PT_GNU_EH_FRAME is a special section pointing on .eh_frame_hdr.
if (!Out<ELFT>::EhFrame->empty() && In<ELFT>::EhFrameHdr)
if (!In<ELFT>::EhFrame->empty() && In<ELFT>::EhFrameHdr)
AddHdr(PT_GNU_EH_FRAME, In<ELFT>::EhFrameHdr->OutSec->getPhdrFlags())
->add(In<ELFT>::EhFrameHdr->OutSec);
@@ -1827,7 +1831,7 @@ template <class ELFT> void Writer<ELFT>::writeSections() {
// The .eh_frame_hdr depends on .eh_frame section contents, therefore
// it should be written after .eh_frame is written.
if (!Out<ELFT>::EhFrame->empty() && EhFrameHdr)
if (EhFrameHdr)
EhFrameHdr->writeTo(Buf + EhFrameHdr->Offset);
}