From 6eae9f2c670d8124faafa28b65eb1c95c554b64b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 21 Jul 2016 13:32:37 +0000 Subject: [PATCH] Delete SplitInputSection. This opens the way for having a different Piece type for EhInputSection. llvm-svn: 276275 --- lld/ELF/InputSection.cpp | 21 +++++---------------- lld/ELF/InputSection.h | 37 ++++++++++++++----------------------- 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 23c4f3d..57550ee 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -429,15 +429,9 @@ void InputSection::replace(InputSection *Other) { } 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 @@ static std::vector splitNonStrings(ArrayRef Data, 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 @@ bool MergeInputSection::classof(const InputSectionBase *S) { // 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::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; diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 107aa03..69a80e0 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -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 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 @@ public: 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 @@ public: 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; }; -- 2.7.4