This value is used only once, and we can compute a value.
So we don't need to save it.
llvm-svn: 290164
[](InputSectionBase<ELFT> *S) {
if (!S->Live)
return;
- if (S->Compressed)
+ if (S->isCompressed())
S->uncompress();
if (auto *MS = dyn_cast<MergeInputSection<ELFT>>(S))
MS->splitIntoPieces();
return check(File->getObj().getSectionContents(Hdr));
}
-// ELF supports ZLIB-compressed section. Returns true if the section
-// is compressed.
-template <class ELFT>
-static bool isCompressed(typename ELFT::uint Flags, StringRef Name) {
- return (Flags & SHF_COMPRESSED) || Name.startswith(".zdebug");
-}
-
template <class ELFT>
InputSectionBase<ELFT>::InputSectionBase(elf::ObjectFile<ELFT> *File,
uintX_t Flags, uint32_t Type,
uint32_t Info, uintX_t Addralign,
ArrayRef<uint8_t> Data, StringRef Name,
Kind SectionKind)
- : InputSectionData(SectionKind, Name, Data, isCompressed<ELFT>(Flags, Name),
+ : InputSectionData(SectionKind, Name, Data,
!Config->GcSections || !(Flags & SHF_ALLOC)),
File(File), Flags(Flags), Entsize(Entsize), Type(Type), Link(Link),
Info(Info), Repl(this) {
llvm_unreachable("invalid section kind");
}
+template <class ELFT> bool InputSectionBase<ELFT>::isCompressed() const {
+ return (Flags & SHF_COMPRESSED) || Name.startswith(".zdebug");
+}
+
// Returns compressed data and its size when uncompressed.
template <class ELFT>
std::pair<ArrayRef<uint8_t>, uint64_t>
// The garbage collector sets sections' Live bits.
// If GC is disabled, all sections are considered live by default.
InputSectionData(Kind SectionKind, StringRef Name, ArrayRef<uint8_t> Data,
- bool Compressed, bool Live)
- : SectionKind(SectionKind), Live(Live), Assigned(false),
- Compressed(Compressed), Name(Name), Data(Data) {}
+ bool Live)
+ : SectionKind(SectionKind), Live(Live), Assigned(false), Name(Name),
+ Data(Data) {}
private:
unsigned SectionKind : 3;
unsigned Live : 1; // for garbage collection
unsigned Assigned : 1; // for linker script
- unsigned Compressed : 1; // true if section data is compressed
uint32_t Alignment;
StringRef Name;
ArrayRef<uint8_t> Data;
uint32_t Info;
InputSectionBase()
- : InputSectionData(Regular, "", ArrayRef<uint8_t>(), false, false),
- Repl(this) {
+ : InputSectionData(Regular, "", ArrayRef<uint8_t>(), false), Repl(this) {
NumRelocations = 0;
AreRelocsRela = false;
}
// section.
uintX_t getOffset(uintX_t Offset) const;
+ // ELF supports ZLIB-compressed section.
+ // Returns true if the section is compressed.
+ bool isCompressed() const;
void uncompress();
// Returns a source location string. Used to construct an error message.