diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 8fe36eca6a4be9..e8fbab0666ec1f 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1343,10 +1343,6 @@ static size_t findNull(StringRef s, size_t entSize) { llvm_unreachable(""); } -SyntheticSection *MergeInputSection::getParent() const { - return cast_or_null(parent); -} - // Split SHF_STRINGS section. Such section is a sequence of // null-terminated strings. void MergeInputSection::splitStrings(StringRef s, size_t entSize) { diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index d1b889750bbd48..73b2bdaf58be07 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -296,7 +296,9 @@ class MergeInputSection : public InputSectionBase { return const_cast(this)->getSectionPiece(offset); } - SyntheticSection *getParent() const; + SyntheticSection *getParent() const { + return cast_or_null(parent); + } private: void splitStrings(StringRef s, size_t size); @@ -394,6 +396,27 @@ class InputSection : public InputSectionBase { static_assert(sizeof(InputSection) <= 160, "InputSection is too big"); +class SyntheticSection : public InputSection { +public: + SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment, + StringRef name) + : InputSection(nullptr, flags, type, alignment, {}, name, + InputSectionBase::Synthetic) {} + + virtual ~SyntheticSection() = default; + virtual size_t getSize() const = 0; + virtual bool updateAllocSize() { return false; } + // If the section has the SHF_ALLOC flag and the size may be changed if + // thunks are added, update the section size. + virtual bool isNeeded() const { return true; } + virtual void finalizeContents() {} + virtual void writeTo(uint8_t *buf) = 0; + + static bool classof(const SectionBase *sec) { + return sec->kind() == InputSectionBase::Synthetic; + } +}; + inline bool isDebugSection(const InputSectionBase &sec) { return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 && sec.name.startswith(".debug"); diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 2ac89d51e3874a..120532245f6334 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -34,27 +34,6 @@ class Defined; struct PhdrEntry; class SymbolTableBaseSection; -class SyntheticSection : public InputSection { -public: - SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment, - StringRef name) - : InputSection(nullptr, flags, type, alignment, {}, name, - InputSectionBase::Synthetic) {} - - virtual ~SyntheticSection() = default; - virtual void writeTo(uint8_t *buf) = 0; - virtual size_t getSize() const = 0; - virtual void finalizeContents() {} - // If the section has the SHF_ALLOC flag and the size may be changed if - // thunks are added, update the section size. - virtual bool updateAllocSize() { return false; } - virtual bool isNeeded() const { return true; } - - static bool classof(const SectionBase *d) { - return d->kind() == InputSectionBase::Synthetic; - } -}; - struct CieRecord { EhSectionPiece *cie = nullptr; SmallVector fdes;