[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

llvm-svn: 295483
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 8f66d01..c9e775d 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -322,8 +322,7 @@
       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]);
     }
   }
 }
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index ba33156..e647c0b 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -128,6 +128,9 @@
   // 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 @@
   // 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();
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index ac5ac99..8dfbfe8 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -298,11 +298,7 @@
     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);
   }
 }