Index: ELF/InputSection.h =================================================================== --- ELF/InputSection.h +++ ELF/InputSection.h @@ -116,29 +116,8 @@ 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 SplitInputSection : public InputSectionBase { - typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::uint uintX_t; - -public: - SplitInputSection(ObjectFile *File, const Elf_Shdr *Header, - typename InputSectionBase::Kind SectionKind); - - // Splittable sections are handled as a sequence of data - // rather than a single large blob of data. - std::vector 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 MergeInputSection : public SplitInputSection { +template class MergeInputSection : public InputSectionBase { typedef typename ELFT::uint uintX_t; typedef typename ELFT::Sym Elf_Sym; typedef typename ELFT::Shdr Elf_Shdr; @@ -157,13 +136,21 @@ void finalizePieces(); + // Splittable sections are handled as a sequence of data + // rather than a single large blob of data. + std::vector 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 OffsetMap; llvm::DenseSet LiveOffsets; }; // This corresponds to a .eh_frame section of an input file. -template class EhInputSection : public SplitInputSection { +template class EhInputSection : public InputSectionBase { public: typedef typename ELFT::Shdr Elf_Shdr; typedef typename ELFT::uint uintX_t; @@ -171,6 +158,10 @@ static bool classof(const InputSectionBase *S); void split(); + // Splittable sections are handled as a sequence of data + // rather than a single large blob of data. + std::vector Pieces; + // Relocation section that refer to this one. const Elf_Shdr *RelocSection = nullptr; }; Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -429,15 +429,9 @@ } template -SplitInputSection::SplitInputSection( - elf::ObjectFile *File, const Elf_Shdr *Header, - typename InputSectionBase::Kind SectionKind) - : InputSectionBase(File, Header, SectionKind) {} - -template EhInputSection::EhInputSection(elf::ObjectFile *F, const Elf_Shdr *Header) - : SplitInputSection(F, Header, InputSectionBase::EHFrame) { + : InputSectionBase(F, Header, 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. @@ -511,7 +505,7 @@ template MergeInputSection::MergeInputSection(elf::ObjectFile *F, const Elf_Shdr *Header) - : SplitInputSection(F, Header, InputSectionBase::Merge) {} + : InputSectionBase(F, Header, InputSectionBase::Merge) {} template void MergeInputSection::splitIntoPieces() { ArrayRef Data = this->getSectionData(); @@ -533,14 +527,14 @@ // Do binary search to get a section piece at a given input offset. template -SectionPiece *SplitInputSection::getSectionPiece(uintX_t Offset) { - auto *This = static_cast *>(this); +SectionPiece *MergeInputSection::getSectionPiece(uintX_t Offset) { + auto *This = static_cast *>(this); return const_cast(This->getSectionPiece(Offset)); } template const SectionPiece * -SplitInputSection::getSectionPiece(uintX_t Offset) const { +MergeInputSection::getSectionPiece(uintX_t Offset) const { ArrayRef D = this->getSectionData(); StringRef Data((const char *)D.data(), D.size()); uintX_t Size = Data.size(); @@ -643,11 +637,6 @@ template class elf::InputSection; template class elf::InputSection; -template class elf::SplitInputSection; -template class elf::SplitInputSection; -template class elf::SplitInputSection; -template class elf::SplitInputSection; - template class elf::EhInputSection; template class elf::EhInputSection; template class elf::EhInputSection;