diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index b8db080ea9a9..d4f7acb2c1dc 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -65,7 +65,7 @@ template static std::string getName(SectionT *Sec) { template typename ELFT::uint InputSectionBase::getOffset(uintX_t Offset) const { - switch (SectionKind) { + switch (kind()) { case Regular: return cast>(this)->OutSecOff + Offset; case EHFrame: @@ -126,7 +126,7 @@ InputSection::InputSection(elf::ObjectFile *F, template bool InputSection::classof(const InputSectionBase *S) { - return S->SectionKind == Base::Regular; + return S->kind() == Base::Regular; } template @@ -446,7 +446,7 @@ EhInputSection::EhInputSection(elf::ObjectFile *F, template bool EhInputSection::classof(const InputSectionBase *S) { - return S->SectionKind == InputSectionBase::EHFrame; + return S->kind() == InputSectionBase::EHFrame; } // Returns the index of the first relocation that points to a region between @@ -570,7 +570,7 @@ template void MergeInputSection::splitIntoPieces() { template bool MergeInputSection::classof(const InputSectionBase *S) { - return S->SectionKind == InputSectionBase::Merge; + return S->kind() == InputSectionBase::Merge; } // Do binary search to get a section piece at a given input offset. @@ -647,7 +647,7 @@ MipsReginfoInputSection::MipsReginfoInputSection(elf::ObjectFile *F, template bool MipsReginfoInputSection::classof(const InputSectionBase *S) { - return S->SectionKind == InputSectionBase::MipsReginfo; + return S->kind() == InputSectionBase::MipsReginfo; } template @@ -672,7 +672,7 @@ MipsOptionsInputSection::MipsOptionsInputSection(elf::ObjectFile *F, template bool MipsOptionsInputSection::classof(const InputSectionBase *S) { - return S->SectionKind == InputSectionBase::MipsOptions; + return S->kind() == InputSectionBase::MipsOptions; } template @@ -690,7 +690,7 @@ MipsAbiFlagsInputSection::MipsAbiFlagsInputSection( template bool MipsAbiFlagsInputSection::classof(const InputSectionBase *S) { - return S->SectionKind == InputSectionBase::MipsAbiFlags; + return S->kind() == InputSectionBase::MipsAbiFlags; } template diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 47d0e29359d2..9e66c6c096b2 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -45,12 +45,19 @@ public: InputSectionData(Kind SectionKind, bool Compressed, bool Live) : SectionKind(SectionKind), Live(Live), Compressed(Compressed) {} - Kind SectionKind; - uint32_t Alignment; - // Used for garbage collection. - bool Live; +private: + unsigned SectionKind : 3; + +public: + Kind kind() const { return (Kind)SectionKind; } + + // Used for garbage collection. + unsigned Live : 1; + + unsigned Compressed : 1; + + uint32_t Alignment; - bool Compressed; // If a section is compressed, this vector has uncompressed section data. SmallVector Uncompressed; diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 278e5c586e5b..4eda44549d9f 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1836,7 +1836,7 @@ OutputSectionFactory::create(InputSectionBase *C, if (Sec) return {Sec, false}; - switch (C->SectionKind) { + switch (C->kind()) { case InputSectionBase::Regular: Sec = new OutputSection(Key.Name, Key.Type, Key.Flags); break;