Delete SplitInputSection.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 21 Jul 2016 13:32:37 +0000 (13:32 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 21 Jul 2016 13:32:37 +0000 (13:32 +0000)
This opens the way for having a different Piece type for EhInputSection.

llvm-svn: 276275

lld/ELF/InputSection.cpp
lld/ELF/InputSection.h

index 23c4f3d..57550ee 100644 (file)
@@ -429,15 +429,9 @@ void InputSection<ELFT>::replace(InputSection<ELFT> *Other) {
 }
 
 template <class ELFT>
-SplitInputSection<ELFT>::SplitInputSection(
-    elf::ObjectFile<ELFT> *File, const Elf_Shdr *Header,
-    typename InputSectionBase<ELFT>::Kind SectionKind)
-    : InputSectionBase<ELFT>(File, Header, SectionKind) {}
-
-template <class ELFT>
 EhInputSection<ELFT>::EhInputSection(elf::ObjectFile<ELFT> *F,
                                      const Elf_Shdr *Header)
-    : SplitInputSection<ELFT>(F, Header, InputSectionBase<ELFT>::EHFrame) {
+    : InputSectionBase<ELFT>(F, Header, InputSectionBase<ELFT>::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.
@@ -511,7 +505,7 @@ static std::vector<SectionPiece> splitNonStrings(ArrayRef<uint8_t> Data,
 template <class ELFT>
 MergeInputSection<ELFT>::MergeInputSection(elf::ObjectFile<ELFT> *F,
                                            const Elf_Shdr *Header)
-    : SplitInputSection<ELFT>(F, Header, InputSectionBase<ELFT>::Merge) {}
+    : InputSectionBase<ELFT>(F, Header, InputSectionBase<ELFT>::Merge) {}
 
 template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() {
   ArrayRef<uint8_t> Data = this->getSectionData();
@@ -533,14 +527,14 @@ bool MergeInputSection<ELFT>::classof(const InputSectionBase<ELFT> *S) {
 
 // Do binary search to get a section piece at a given input offset.
 template <class ELFT>
-SectionPiece *SplitInputSection<ELFT>::getSectionPiece(uintX_t Offset) {
-  auto *This = static_cast<const SplitInputSection<ELFT> *>(this);
+SectionPiece *MergeInputSection<ELFT>::getSectionPiece(uintX_t Offset) {
+  auto *This = static_cast<const MergeInputSection<ELFT> *>(this);
   return const_cast<SectionPiece *>(This->getSectionPiece(Offset));
 }
 
 template <class ELFT>
 const SectionPiece *
-SplitInputSection<ELFT>::getSectionPiece(uintX_t Offset) const {
+MergeInputSection<ELFT>::getSectionPiece(uintX_t Offset) const {
   ArrayRef<uint8_t> D = this->getSectionData();
   StringRef Data((const char *)D.data(), D.size());
   uintX_t Size = Data.size();
@@ -643,11 +637,6 @@ template class elf::InputSection<ELF32BE>;
 template class elf::InputSection<ELF64LE>;
 template class elf::InputSection<ELF64BE>;
 
-template class elf::SplitInputSection<ELF32LE>;
-template class elf::SplitInputSection<ELF32BE>;
-template class elf::SplitInputSection<ELF64LE>;
-template class elf::SplitInputSection<ELF64BE>;
-
 template class elf::EhInputSection<ELF32LE>;
 template class elf::EhInputSection<ELF32BE>;
 template class elf::EhInputSection<ELF64LE>;
index 107aa03..69a80e0 100644 (file)
@@ -116,29 +116,8 @@ public:
   uint32_t Live : 1;
 };
 
-// Usually sections are copied to the output as atomic chunks of data,
-// but some special types of sections are split into small pieces of data
-// and each piece is copied to a different place in the output.
-// This class represents such special sections.
-template <class ELFT> class SplitInputSection : public InputSectionBase<ELFT> {
-  typedef typename ELFT::Shdr Elf_Shdr;
-  typedef typename ELFT::uint uintX_t;
-
-public:
-  SplitInputSection(ObjectFile<ELFT> *File, const Elf_Shdr *Header,
-                    typename InputSectionBase<ELFT>::Kind SectionKind);
-
-  // Splittable sections are handled as a sequence of data
-  // rather than a single large blob of data.
-  std::vector<SectionPiece> Pieces;
-
-  // Returns the SectionPiece at a given input section offset.
-  SectionPiece *getSectionPiece(uintX_t Offset);
-  const SectionPiece *getSectionPiece(uintX_t Offset) const;
-};
-
 // This corresponds to a SHF_MERGE section of an input file.
-template <class ELFT> class MergeInputSection : public SplitInputSection<ELFT> {
+template <class ELFT> class MergeInputSection : public InputSectionBase<ELFT> {
   typedef typename ELFT::uint uintX_t;
   typedef typename ELFT::Sym Elf_Sym;
   typedef typename ELFT::Shdr Elf_Shdr;
@@ -157,13 +136,21 @@ public:
 
   void finalizePieces();
 
+  // Splittable sections are handled as a sequence of data
+  // rather than a single large blob of data.
+  std::vector<SectionPiece> Pieces;
+
+  // Returns the SectionPiece at a given input section offset.
+  SectionPiece *getSectionPiece(uintX_t Offset);
+  const SectionPiece *getSectionPiece(uintX_t Offset) const;
+
 private:
   llvm::DenseMap<uintX_t, uintX_t> OffsetMap;
   llvm::DenseSet<uintX_t> LiveOffsets;
 };
 
 // This corresponds to a .eh_frame section of an input file.
-template <class ELFT> class EhInputSection : public SplitInputSection<ELFT> {
+template <class ELFT> class EhInputSection : public InputSectionBase<ELFT> {
 public:
   typedef typename ELFT::Shdr Elf_Shdr;
   typedef typename ELFT::uint uintX_t;
@@ -171,6 +158,10 @@ public:
   static bool classof(const InputSectionBase<ELFT> *S);
   void split();
 
+  // Splittable sections are handled as a sequence of data
+  // rather than a single large blob of data.
+  std::vector<SectionPiece> Pieces;
+
   // Relocation section that refer to this one.
   const Elf_Shdr *RelocSection = nullptr;
 };