[lld] r325879 - Recommit "[ELF] - Do not crash with --emit-relocs and --icf=all together."

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 02:37:33 PST 2018


Author: grimar
Date: Fri Feb 23 02:37:33 2018
New Revision: 325879

URL: http://llvm.org/viewvc/llvm-project?rev=325879&view=rev
Log:
Recommit "[ELF] - Do not crash with --emit-relocs and --icf=all together."

Latest patch version now.

Original commit message:

[ELF] - Do not crash with --emit-relocs and --icf=all together.

Previously we would crash because did not mark .rel[a] sections
as dead and they tried to access parent which was not live
after ICF and therefore was null.

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

Added:
    lld/trunk/test/ELF/emit-relocs-icf.s
      - copied unchanged from r325877, lld/trunk/test/ELF/emit-relocs-icf.s
Modified:
    lld/trunk/ELF/ICF.cpp

Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=325879&r1=325878&r2=325879&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Fri Feb 23 02:37:33 2018
@@ -437,17 +437,14 @@ template <class ELFT> void ICF<ELFT>::ru
     for (size_t I = Begin + 1; I < End; ++I) {
       print("  removing identical section " + toString(Sections[I]));
       Sections[Begin]->replace(Sections[I]);
+
+      // At this point we know sections merged are fully identical and hence
+      // we want to remove duplicate implicit dependencies such as link order
+      // and relocation sections.
+      for (InputSection *IS : Sections[I]->DependentSections)
+        IS->Live = false;
     }
   });
-
-  // Mark ARM Exception Index table sections that refer to folded code
-  // sections as not live. These sections have an implict dependency
-  // via the link order dependency.
-  if (Config->EMachine == EM_ARM)
-    for (InputSectionBase *Sec : InputSections)
-      if (auto *S = dyn_cast<InputSection>(Sec))
-        if (S->Flags & SHF_LINK_ORDER)
-          S->Live = S->getLinkOrderDep()->Live;
 }
 
 // ICF entry point function.




More information about the llvm-commits mailing list