[lld] 286c111 - [ELF] Decrease InputSectionBase::entsize to uint32_t

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 28 19:50:39 PST 2021


Author: Fangrui Song
Date: 2021-11-28T19:50:33-08:00
New Revision: 286c11165e24a7904328804ba10c332277d18b45

URL: https://github.com/llvm/llvm-project/commit/286c11165e24a7904328804ba10c332277d18b45
DIFF: https://github.com/llvm/llvm-project/commit/286c11165e24a7904328804ba10c332277d18b45.diff

LOG: [ELF] Decrease InputSectionBase::entsize to uint32_t

While here, change the sh_addralign argument to uint32_t (InputSection ctor's
argument and the member are uint32_t); add constexpr.

Added: 
    

Modified: 
    lld/ELF/InputSection.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index afbb657806ce..7ddc43916a0f 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -78,7 +78,7 @@ class SectionBase {
   // These corresponds to the fields in Elf_Shdr.
   uint32_t alignment;
   uint64_t flags;
-  uint64_t entsize;
+  uint32_t entsize;
   uint32_t type;
   uint32_t link;
   uint32_t info;
@@ -99,9 +99,9 @@ class SectionBase {
   void markDead() { partition = 0; }
 
 protected:
-  SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
-              uint64_t entsize, uint64_t alignment, uint32_t type,
-              uint32_t info, uint32_t link)
+  constexpr SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
+                        uint32_t entsize, uint32_t alignment, uint32_t type,
+                        uint32_t info, uint32_t link)
       : name(name), repl(this), sectionKind(sectionKind), bss(false),
         keepUnique(false), partition(0), alignment(alignment), flags(flags),
         entsize(entsize), type(type), link(link), info(info) {}
@@ -121,14 +121,14 @@ class InputSectionBase : public SectionBase {
 
   static bool classof(const SectionBase *s) { return s->kind() != Output; }
 
-  // Section index of the relocation section if exists.
-  uint32_t relSecIdx = 0;
-
   // The file which contains this section. Its dynamic type is always
   // ObjFile<ELFT>, but in order to avoid ELFT, we use InputFile as
   // its static type.
   InputFile *file;
 
+  // Section index of the relocation section if exists.
+  uint32_t relSecIdx = 0;
+
   template <class ELFT> ObjFile<ELFT> *getFile() const {
     return cast_or_null<ObjFile<ELFT>>(file);
   }


        


More information about the llvm-commits mailing list