From 124bedbd50f027659b22c41b1ed0fd0bc8571f76 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 10 Oct 2017 03:22:29 +0000 Subject: [PATCH] Add comment to InputSectionBase::File. This patch also moves declarations so that related declarations next to each other. llvm-svn: 315266 --- lld/ELF/InputSection.cpp | 9 --------- lld/ELF/InputSection.h | 30 ++++++++++++++++++------------ 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 9035e555c7ac..94e81593e02f 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -696,10 +696,6 @@ void InputSection::relocateNonAlloc(uint8_t *Buf, ArrayRef Rels) { } } -template ObjFile *InputSectionBase::getFile() const { - return cast_or_null>(File); -} - template void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd) { if (Flags & SHF_ALLOC) { @@ -1031,11 +1027,6 @@ template void InputSection::writeTo(uint8_t *); template void InputSection::writeTo(uint8_t *); template void InputSection::writeTo(uint8_t *); -template ObjFile *InputSectionBase::getFile() const; -template ObjFile *InputSectionBase::getFile() const; -template ObjFile *InputSectionBase::getFile() const; -template ObjFile *InputSectionBase::getFile() const; - template MergeInputSection::MergeInputSection(ObjFile *, const ELF32LE::Shdr *, StringRef); template MergeInputSection::MergeInputSection(ObjFile *, diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index b155e3ec6a6e..686658c629d5 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -102,16 +102,6 @@ protected: // This corresponds to a section of an input file. class InputSectionBase : public SectionBase { public: - static bool classof(const SectionBase *S) { return S->kind() != Output; } - - // The file this section is from. - InputFile *File; - - ArrayRef Data; - uint64_t getOffsetInFile() const; - - static InputSectionBase Discarded; - InputSectionBase() : SectionBase(Regular, "", /*Flags*/ 0, /*Entsize*/ 0, /*Alignment*/ 0, /*Type*/ 0, @@ -130,6 +120,22 @@ public: uint32_t Alignment, ArrayRef Data, StringRef Name, Kind SectionKind); + static bool classof(const SectionBase *S) { return S->kind() != Output; } + + // The file which contains this section. It's dynamic type is always + // ObjFile, but in order to avoid ELFT, we use InputFile as + // its static type. + InputFile *File; + + template ObjFile *getFile() const { + return cast_or_null>(File); + } + + ArrayRef Data; + uint64_t getOffsetInFile() const; + + static InputSectionBase Discarded; + // Input sections are part of an output section. Special sections // like .eh_frame and merge sections are first combined into a // synthetic section that is then added to an output section. In all @@ -140,12 +146,14 @@ public: const void *FirstRelocation = nullptr; unsigned NumRelocations : 31; unsigned AreRelocsRela : 1; + template ArrayRef rels() const { assert(!AreRelocsRela); return llvm::makeArrayRef( static_cast(FirstRelocation), NumRelocations); } + template ArrayRef relas() const { assert(AreRelocsRela); return llvm::makeArrayRef( @@ -166,8 +174,6 @@ public: // Returns the size of this section (even if this is a common or BSS.) size_t getSize() const; - template ObjFile *getFile() const; - InputSection *getLinkOrderDep() const; void maybeUncompress();