From f1652d4c60291c20b153915cf334bf323cd82df5 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 27 Apr 2018 18:17:36 +0000 Subject: [PATCH] Split .eh_frame sections in parellel. We can now split them in the same spot we split merge sections. llvm-svn: 331064 --- lld/ELF/Driver.cpp | 2 +- lld/ELF/InputSection.cpp | 4 ---- lld/ELF/MarkLive.cpp | 4 ---- lld/ELF/SyntheticSections.cpp | 13 ++++++++----- lld/ELF/SyntheticSections.h | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 2c29c51..bcf4eeb 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1304,7 +1304,7 @@ template void LinkerDriver::link(opt::InputArgList &Args) { // Do size optimizations: garbage collection, merging of SHF_MERGE sections // and identical code folding. decompressSections(); - splitSections(); + splitSections(); markLive(); demoteSymbols(); mergeSections(); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 7b64621a..9612c29 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -836,10 +836,6 @@ static unsigned getReloc(IntTy Begin, IntTy Size, const ArrayRef &Rels, // .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 diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index d7cc74e..afdb69e 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -159,10 +159,6 @@ scanEhFrameSection(EhInputSection &EH, 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 diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 306bee4..6f91a64 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -460,10 +460,6 @@ template void EhFrameSection::addSection(InputSectionBase *C) { 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 @@ void elf::decompressSections() { [](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 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 *); diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index bd442a5..f27b91b 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -834,7 +834,7 @@ private: InputSection *createInterpSection(); MergeInputSection *createCommentSection(); void decompressSections(); -void splitSections(); +template void splitSections(); void mergeSections(); Defined *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value, -- 2.7.4