[PATCH] D46196: Split .eh_frame sections in parellel

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 27 09:46:58 PDT 2018


espindola created this revision.
espindola added reviewers: ruiu, grimar.
Herald added subscribers: arichardson, emaste.

We can now split them in the same spot we split merge sections.


https://reviews.llvm.org/D46196

Files:
  ELF/Driver.cpp
  ELF/InputSection.cpp
  ELF/MarkLive.cpp
  ELF/SyntheticSections.cpp
  ELF/SyntheticSections.h


Index: ELF/SyntheticSections.h
===================================================================
--- ELF/SyntheticSections.h
+++ ELF/SyntheticSections.h
@@ -834,7 +834,7 @@
 InputSection *createInterpSection();
 MergeInputSection *createCommentSection();
 void decompressSections();
-void splitSections();
+template <class ELFT> 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<ELFT>();
   if (Sec->Pieces.empty())
     return;
 
@@ -2540,12 +2536,14 @@
                   [](InputSectionBase *Sec) { Sec->maybeDecompress(); });
 }
 
-void elf::splitSections() {
+template <class ELFT> void elf::splitSections() {
   // splitIntoPieces needs to be called on each MergeInputSection
   // before calling finalizeContents().
   parallelForEach(InputSections, [](InputSectionBase *Sec) {
     if (auto *S = dyn_cast<MergeInputSection>(Sec))
       S->splitIntoPieces();
+    else if (auto *Eh = dyn_cast<EhInputSection>(Sec))
+      Eh->split<ELFT>();
   });
 }
 
@@ -2702,6 +2700,11 @@
 template GdbIndexSection *elf::createGdbIndex<ELF64LE>();
 template GdbIndexSection *elf::createGdbIndex<ELF64BE>();
 
+template void elf::splitSections<ELF32LE>();
+template void elf::splitSections<ELF32BE>();
+template void elf::splitSections<ELF64LE>();
+template void elf::splitSections<ELF64BE>();
+
 template void EhFrameSection::addSection<ELF32LE>(InputSectionBase *);
 template void EhFrameSection::addSection<ELF32BE>(InputSectionBase *);
 template void EhFrameSection::addSection<ELF64LE>(InputSectionBase *);
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<ELFT>();
-
   if (EH.AreRelocsRela)
     scanEhFrameSection<ELFT>(EH, EH.template relas<ELFT>(), Fn);
   else
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 <class ELFT> void EhInputSection::split() {
-  // Early exit if already split.
-  if (!Pieces.empty())
-    return;
-
   if (AreRelocsRela)
     split<ELFT>(relas<ELFT>());
   else
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<ELFT>();
   markLive<ELFT>();
   demoteSymbols<ELFT>();
   mergeSections();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46196.144363.patch
Type: text/x-patch
Size: 3368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180427/4c23920c/attachment.bin>


More information about the llvm-commits mailing list