From 6ff570a395d22d6f335ea8dd6aaad0471fc09263 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 9 Nov 2016 16:55:07 +0000 Subject: [PATCH] Make Discarded a InputSection. It was quite confusing that it had SectionKind of Regular, but was not actually a InputSection. llvm-svn: 286379 --- lld/ELF/InputFiles.cpp | 2 +- lld/ELF/InputSection.cpp | 3 +++ lld/ELF/InputSection.h | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index bedc279f4df1..aa44fe21d46f 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -446,7 +446,7 @@ elf::ObjectFile::getSection(const Elf_Sym &Sym) const { fatal(getFilename(this) + ": invalid section index: " + Twine(Index)); } - if (S == &InputSectionBase::Discarded) + if (S == &InputSection::Discarded) return S; return S->Repl; } diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index b20825a82d5a..12ff0fd91a4c 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -189,6 +189,9 @@ InputSectionBase *InputSectionBase::getLinkOrderDep() const { return nullptr; } +template +InputSection::InputSection() : InputSectionBase() {} + template InputSection::InputSection(uintX_t Flags, uint32_t Type, uintX_t Addralign, ArrayRef Data, diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 6e863929c7c8..73cbacb6a5dd 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -116,8 +116,6 @@ public: // Returns the size of this section (even if this is a common or BSS.) size_t getSize() const; - static InputSectionBase Discarded; - ObjectFile *getFile() const { return File; } llvm::object::ELFFile getObj() const { return File->getObj(); } uintX_t getOffset(const DefinedRegular &Sym) const; @@ -138,8 +136,6 @@ private: getRawCompressedData(ArrayRef Data); }; -template InputSectionBase InputSectionBase::Discarded; - // SectionPiece represents a piece of splittable section contents. // We allocate a lot of these and binary search on them. This means that they // have to be as compact as possible, which is why we don't store the size (can @@ -238,10 +234,13 @@ template class InputSection : public InputSectionBase { typedef typename ELFT::uint uintX_t; public: + InputSection(); InputSection(uintX_t Flags, uint32_t Type, uintX_t Addralign, ArrayRef Data, StringRef Name); InputSection(ObjectFile *F, const Elf_Shdr *Header, StringRef Name); + static InputSection Discarded; + // Write this section to a mmap'ed file, assuming Buf is pointing to // beginning of the output section. void writeTo(uint8_t *Buf); @@ -287,6 +286,8 @@ private: llvm::TinyPtrVector *> Thunks; }; +template InputSection InputSection::Discarded; + // MIPS .reginfo section provides information on the registers used by the code // in the object file. Linker should collect this information and write a single // .reginfo section in the output file. The output section contains a union of -- 2.34.1