Make Discarded a InputSection.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 9 Nov 2016 16:55:07 +0000 (16:55 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 9 Nov 2016 16:55:07 +0000 (16:55 +0000)
It was quite confusing that it had SectionKind of Regular, but was not
actually a InputSection.

llvm-svn: 286379

lld/ELF/InputFiles.cpp
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h

index bedc279..aa44fe2 100644 (file)
@@ -446,7 +446,7 @@ elf::ObjectFile<ELFT>::getSection(const Elf_Sym &Sym) const {
     fatal(getFilename(this) + ": invalid section index: " + Twine(Index));
   }
 
-  if (S == &InputSectionBase<ELFT>::Discarded)
+  if (S == &InputSection<ELFT>::Discarded)
     return S;
   return S->Repl;
 }
index b20825a..12ff0fd 100644 (file)
@@ -190,6 +190,9 @@ InputSectionBase<ELFT> *InputSectionBase<ELFT>::getLinkOrderDep() const {
 }
 
 template <class ELFT>
+InputSection<ELFT>::InputSection() : InputSectionBase<ELFT>() {}
+
+template <class ELFT>
 InputSection<ELFT>::InputSection(uintX_t Flags, uint32_t Type,
                                  uintX_t Addralign, ArrayRef<uint8_t> Data,
                                  StringRef Name)
index 6e86392..73cbacb 100644 (file)
@@ -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<ELFT> Discarded;
-
   ObjectFile<ELFT> *getFile() const { return File; }
   llvm::object::ELFFile<ELFT> getObj() const { return File->getObj(); }
   uintX_t getOffset(const DefinedRegular<ELFT> &Sym) const;
@@ -138,8 +136,6 @@ private:
   getRawCompressedData(ArrayRef<uint8_t> Data);
 };
 
-template <class ELFT> InputSectionBase<ELFT> InputSectionBase<ELFT>::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 ELFT> class InputSection : public InputSectionBase<ELFT> {
   typedef typename ELFT::uint uintX_t;
 
 public:
+  InputSection();
   InputSection(uintX_t Flags, uint32_t Type, uintX_t Addralign,
                ArrayRef<uint8_t> Data, StringRef Name);
   InputSection(ObjectFile<ELFT> *F, const Elf_Shdr *Header, StringRef Name);
 
+  static InputSection<ELFT> 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<const Thunk<ELFT> *> Thunks;
 };
 
+template <class ELFT> InputSection<ELFT> InputSection<ELFT>::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