[lld] r295483 - [ELF] - Move DependentSections vector from InputSection to InputSectionBase

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 11:34:05 PST 2017


Author: grimar
Date: Fri Feb 17 13:34:05 2017
New Revision: 295483

URL: http://llvm.org/viewvc/llvm-project?rev=295483&view=rev
Log:
[ELF] - Move DependentSections vector from InputSection to InputSectionBase

I splitted it from D29273.
Since we plan to make relocatable sections as dependent for target ones for
--emit-relocs implementation, this change is required to support .eh_frame case.

EhInputSection inherets from InputSectionBase and not from InputSection.
So for case when it has relocation section, it should be able to access DependentSections
vector.

This case is real for Linux kernel.

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

Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=295483&r1=295482&r2=295483&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Feb 17 13:34:05 2017
@@ -322,8 +322,7 @@ void elf::ObjectFile<ELFT>::initializeSe
       if (Sec.sh_link >= Sections.size())
         fatal(toString(this) + ": invalid sh_link index: " +
               Twine(Sec.sh_link));
-      auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
-      IS->DependentSections.push_back(Sections[I]);
+      Sections[Sec.sh_link]->DependentSections.push_back(Sections[I]);
     }
   }
 }

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=295483&r1=295482&r2=295483&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Fri Feb 17 13:34:05 2017
@@ -128,6 +128,9 @@ public:
   // this but instead this->Repl.
   InputSectionBase<ELFT> *Repl;
 
+  // InputSections that are dependent on us (reverse dependency for GC)
+  llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
+
   // Returns the size of this section (even if this is a common or BSS.)
   size_t getSize() const;
 
@@ -281,9 +284,6 @@ public:
   // to. The writer sets a value.
   uint64_t OutSecOff = 0;
 
-  // InputSections that are dependent on us (reverse dependency for GC)
-  llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
-
   static bool classof(const InputSectionData *S);
 
   InputSectionBase<ELFT> *getRelocatedSection();

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=295483&r1=295482&r2=295483&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Feb 17 13:34:05 2017
@@ -298,11 +298,7 @@ void LinkerScript<ELFT>::discard(ArrayRe
     S->Live = false;
     if (S == In<ELFT>::ShStrTab)
       error("discarding .shstrtab section is not allowed");
-
-    InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
-    if (!IS || IS->DependentSections.empty())
-      continue;
-    discard(IS->DependentSections);
+    discard(S->DependentSections);
   }
 }
 




More information about the llvm-commits mailing list