[PATCH] D41143: Fix the type of the Discared section

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 17:09:40 PST 2017


rafael created this revision.
rafael added a reviewer: ruiu.
Herald added a subscriber: emaste.

It is constructed with a kind of Regular and will dyn_cast to InputSection, but is declared to be an InputSectionBase.


https://reviews.llvm.org/D41143

Files:
  ELF/InputSection.cpp
  ELF/InputSection.h


Index: ELF/InputSection.h
===================================================================
--- ELF/InputSection.h
+++ ELF/InputSection.h
@@ -85,12 +85,6 @@
 // This corresponds to a section of an input file.
 class InputSectionBase : public SectionBase {
 public:
-  InputSectionBase()
-      : SectionBase(Regular, "", /*Flags*/ 0, /*Entsize*/ 0, /*Alignment*/ 0,
-                    /*Type*/ 0,
-                    /*Info*/ 0, /*Link*/ 0),
-        NumRelocations(0), AreRelocsRela(false), Repl(this) {}
-
   template <class ELFT>
   InputSectionBase(ObjFile<ELFT> *File, const typename ELFT::Shdr *Header,
                    StringRef Name, Kind SectionKind);
@@ -114,8 +108,6 @@
   ArrayRef<uint8_t> Data;
   uint64_t getOffsetInFile() const;
 
-  static InputSectionBase Discarded;
-
   // True if this section has already been placed to a linker script
   // output section. This is needed because, in a linker script, you
   // can refer to the same section more than once. For example, in
@@ -306,6 +298,7 @@
 // .eh_frame. It also includes the synthetic sections themselves.
 class InputSection : public InputSectionBase {
 public:
+  InputSection();
   InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
                ArrayRef<uint8_t> Data, StringRef Name, Kind K = Regular);
   template <class ELFT>
@@ -337,6 +330,8 @@
   // Called by ICF to merge two input sections.
   void replace(InputSection *Other);
 
+  static InputSection Discarded;
+
 private:
   template <class ELFT, class RelTy>
   void copyRelocations(uint8_t *Buf, llvm::ArrayRef<RelTy> Rels);
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -323,7 +323,9 @@
       .str();
 }
 
-InputSectionBase InputSectionBase::Discarded;
+InputSection InputSection::Discarded;
+
+InputSection::InputSection() : InputSection(0, 0, 0, ArrayRef<uint8_t>(), "") {}
 
 InputSection::InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
                            ArrayRef<uint8_t> Data, StringRef Name, Kind K)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41143.126653.patch
Type: text/x-patch
Size: 2106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171213/70ff5c75/attachment.bin>


More information about the llvm-commits mailing list