Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -1304,7 +1304,7 @@ // Do size optimizations: garbage collection, merging of SHF_MERGE sections // and identical code folding. decompressSections(); - splitSections(); + splitSections(); markLive(); demoteSymbols(); mergeSections(); Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -836,10 +836,6 @@ // .eh_frame is a sequence of CIE or FDE records. // This function splits an input section into records and returns them. template void EhInputSection::split() { - // Early exit if already split. - if (!Pieces.empty()) - return; - if (AreRelocsRela) split(relas()); else Index: ELF/MarkLive.cpp =================================================================== --- ELF/MarkLive.cpp +++ ELF/MarkLive.cpp @@ -159,10 +159,6 @@ if (!EH.NumRelocations) return; - // Unfortunately we need to split .eh_frame early since some relocations in - // .eh_frame keep other section alive and some don't. - EH.split(); - if (EH.AreRelocsRela) scanEhFrameSection(EH, EH.template relas(), Fn); else Index: ELF/SyntheticSections.h =================================================================== --- ELF/SyntheticSections.h +++ ELF/SyntheticSections.h @@ -834,7 +834,7 @@ InputSection *createInterpSection(); MergeInputSection *createCommentSection(); void decompressSections(); -void splitSections(); +template void splitSections(); void mergeSections(); Defined *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value, Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -460,10 +460,6 @@ for (auto *DS : Sec->DependentSections) DependentSections.push_back(DS); - // .eh_frame is a sequence of CIE or FDE records. This function - // splits it into pieces so that we can call - // SplitInputSection::getSectionPiece on the section. - Sec->split(); if (Sec->Pieces.empty()) return; @@ -2540,12 +2536,14 @@ [](InputSectionBase *Sec) { Sec->maybeDecompress(); }); } -void elf::splitSections() { +template void elf::splitSections() { // splitIntoPieces needs to be called on each MergeInputSection // before calling finalizeContents(). parallelForEach(InputSections, [](InputSectionBase *Sec) { if (auto *S = dyn_cast(Sec)) S->splitIntoPieces(); + else if (auto *Eh = dyn_cast(Sec)) + Eh->split(); }); } @@ -2702,6 +2700,11 @@ template GdbIndexSection *elf::createGdbIndex(); template GdbIndexSection *elf::createGdbIndex(); +template void elf::splitSections(); +template void elf::splitSections(); +template void elf::splitSections(); +template void elf::splitSections(); + template void EhFrameSection::addSection(InputSectionBase *); template void EhFrameSection::addSection(InputSectionBase *); template void EhFrameSection::addSection(InputSectionBase *);