diff lld/ELF/InputSection.h @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 0572611fdcc8
children c4bab56944e8
line wrap: on
line diff
--- a/lld/ELF/InputSection.h	Tue Jun 15 19:13:43 2021 +0900
+++ b/lld/ELF/InputSection.h	Tue Jun 15 19:15:29 2021 +0900
@@ -52,15 +52,15 @@
   // this but instead this->Repl.
   SectionBase *repl;
 
-  unsigned sectionKind : 3;
+  uint8_t sectionKind : 3;
 
   // The next two bit fields are only used by InputSectionBase, but we
   // put them here so the struct packs better.
 
-  unsigned bss : 1;
+  uint8_t bss : 1;
 
   // Set for sections that should not be folded by ICF.
-  unsigned keepUnique : 1;
+  uint8_t keepUnique : 1;
 
   // The 1-indexed partition that this section is assigned to by the garbage
   // collector, or 0 if this section is dead. Normally there is only one
@@ -134,6 +134,10 @@
   // and shrinking a section.
   unsigned bytesDropped = 0;
 
+  // Whether the section needs to be padded with a NOP filler due to
+  // deleteFallThruJmpInsn.
+  bool nopFiller = false;
+
   void drop_back(uint64_t num) { bytesDropped += num; }
 
   void push_back(uint64_t num) {
@@ -210,17 +214,13 @@
   // The native ELF reloc data type is not very convenient to handle.
   // So we convert ELF reloc records to our own records in Relocations.cpp.
   // This vector contains such "cooked" relocations.
-  std::vector<Relocation> relocations;
-
-  // Indicates that this section needs to be padded with a NOP filler if set to
-  // true.
-  bool nopFiller = false;
+  SmallVector<Relocation, 0> relocations;
 
   // These are modifiers to jump instructions that are necessary when basic
   // block sections are enabled.  Basic block sections creates opportunities to
   // relax jump instructions at basic block boundaries after reordering the
   // basic blocks.
-  std::vector<JumpInstrMod> jumpInstrMods;
+  SmallVector<JumpInstrMod, 0> jumpInstrMods;
 
   // A function compiled with -fsplit-stack calling a function
   // compiled without -fsplit-stack needs its prologue adjusted. Find
@@ -314,7 +314,7 @@
                  unsigned firstRelocation)
       : inputOff(off), sec(sec), size(size), firstRelocation(firstRelocation) {}
 
-  ArrayRef<uint8_t> data() {
+  ArrayRef<uint8_t> data() const {
     return {sec->data().data() + this->inputOff, size};
   }
 
@@ -390,8 +390,15 @@
   template <class ELFT> void copyShtGroup(uint8_t *buf);
 };
 
+#ifdef _WIN32
+static_assert(sizeof(InputSection) <= 192, "InputSection is too big");
+#else
+static_assert(sizeof(InputSection) <= 184, "InputSection is too big");
+#endif
+
 inline bool isDebugSection(const InputSectionBase &sec) {
-  return sec.name.startswith(".debug") || sec.name.startswith(".zdebug");
+  return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 &&
+         (sec.name.startswith(".debug") || sec.name.startswith(".zdebug"));
 }
 
 // The list of all input sections.