[lld] r319435 - [ELF] - Handle EhInputSection Live bit in MarkLive.cpp

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 06:01:07 PST 2017


Author: grimar
Date: Thu Nov 30 06:01:06 2017
New Revision: 319435

URL: http://llvm.org/viewvc/llvm-project?rev=319435&view=rev
Log:
[ELF] - Handle EhInputSection Live bit in MarkLive.cpp

Since MarkLive.cpp is the place where we set Live flags for
other sections, it looks correct to do that there.
Benefit is that we stop spreading GC logic outsize of MarkLive.cpp.

Differential revision: https://reviews.llvm.org/D40454

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/MarkLive.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=319435&r1=319434&r2=319435&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Nov 30 06:01:06 2017
@@ -808,12 +808,7 @@ template <class ELFT>
 EhInputSection::EhInputSection(ObjFile<ELFT> *F,
                                const typename ELFT::Shdr *Header,
                                StringRef Name)
-    : InputSectionBase(F, Header, Name, InputSectionBase::EHFrame) {
-  // Mark .eh_frame sections as live by default because there are
-  // usually no relocations that point to .eh_frames. Otherwise,
-  // the garbage collector would drop all .eh_frame sections.
-  this->Live = true;
-}
+    : InputSectionBase(F, Header, Name, InputSectionBase::EHFrame) {}
 
 SyntheticSection *EhInputSection::getParent() const {
   return cast_or_null<SyntheticSection>(Parent);

Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=319435&r1=319434&r2=319435&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Thu Nov 30 06:01:06 2017
@@ -241,11 +241,15 @@ template <class ELFT> static void doGcSe
   // Preserve special sections and those which are specified in linker
   // script KEEP command.
   for (InputSectionBase *Sec : InputSections) {
-    // .eh_frame is always marked as live now, but also it can reference to
-    // sections that contain personality. We preserve all non-text sections
-    // referred by .eh_frame here.
-    if (auto *EH = dyn_cast_or_null<EhInputSection>(Sec))
+    // Mark .eh_frame sections as live because there are usually no relocations
+    // that point to .eh_frames. Otherwise, the garbage collector would drop
+    // all of them. We also want to preserve personality routines and LSDA
+    // referenced by .eh_frame sections, so we scan them for that here.
+    if (auto *EH = dyn_cast_or_null<EhInputSection>(Sec)) {
+      EH->Live = true;
       scanEhFrameSection<ELFT>(*EH, Enqueue);
+    }
+
     if (Sec->Flags & SHF_LINK_ORDER)
       continue;
     if (isReserved<ELFT>(Sec) || Script->shouldKeep(Sec))




More information about the llvm-commits mailing list