[ELF] Shuffle SectionBase fields. NFC

Move frequently used fields (e.g. sectionKind, partition) to the top. My x86-64 lld executable is 600+B smaller.
This commit is contained in:
Fangrui Song 2022-11-20 21:23:30 +00:00
parent ad485b71b5
commit 898b6c5f3a
1 changed files with 7 additions and 7 deletions

View File

@ -50,8 +50,6 @@ public:
Kind kind() const { return (Kind)sectionKind; } Kind kind() const { return (Kind)sectionKind; }
StringRef name;
uint8_t sectionKind : 3; uint8_t sectionKind : 3;
// The next two bit fields are only used by InputSectionBase, but we // The next two bit fields are only used by InputSectionBase, but we
@ -62,17 +60,19 @@ public:
// Set for sections that should not be folded by ICF. // Set for sections that should not be folded by ICF.
uint8_t keepUnique : 1; uint8_t keepUnique : 1;
uint8_t partition = 1;
uint32_t type;
StringRef name;
// The 1-indexed partition that this section is assigned to by the garbage // 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 // collector, or 0 if this section is dead. Normally there is only one
// partition, so this will either be 0 or 1. // partition, so this will either be 0 or 1.
uint8_t partition = 1;
elf::Partition &getPartition() const; elf::Partition &getPartition() const;
// These corresponds to the fields in Elf_Shdr. // These corresponds to the fields in Elf_Shdr.
uint32_t alignment;
uint64_t flags; uint64_t flags;
uint32_t alignment;
uint32_t entsize; uint32_t entsize;
uint32_t type;
uint32_t link; uint32_t link;
uint32_t info; uint32_t info;
@ -95,8 +95,8 @@ protected:
constexpr SectionBase(Kind sectionKind, StringRef name, uint64_t flags, constexpr SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
uint32_t entsize, uint32_t alignment, uint32_t type, uint32_t entsize, uint32_t alignment, uint32_t type,
uint32_t info, uint32_t link) uint32_t info, uint32_t link)
: name(name), sectionKind(sectionKind), bss(false), keepUnique(false), : sectionKind(sectionKind), bss(false), keepUnique(false), type(type),
alignment(alignment), flags(flags), entsize(entsize), type(type), name(name), flags(flags), alignment(alignment), entsize(entsize),
link(link), info(info) {} link(link), info(info) {}
}; };