forked from OSchip/llvm-project
Remove `Compressed` member from InputSectionData.
This value is used only once, and we can compute a value. So we don't need to save it. llvm-svn: 290164
This commit is contained in:
parent
97c96cb4ed
commit
c207a89c91
|
@ -827,7 +827,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
|
|||
[](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();
|
||||
|
|
|
@ -46,13 +46,6 @@ static ArrayRef<uint8_t> getSectionContents(elf::ObjectFile<ELFT> *File,
|
|||
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,
|
||||
|
@ -60,7 +53,7 @@ InputSectionBase<ELFT>::InputSectionBase(elf::ObjectFile<ELFT> *File,
|
|||
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) {
|
||||
|
@ -135,6 +128,10 @@ typename ELFT::uint InputSectionBase<ELFT>::getOffset(uintX_t Offset) const {
|
|||
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>
|
||||
|
|
|
@ -45,9 +45,9 @@ public:
|
|||
// 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;
|
||||
|
@ -57,7 +57,6 @@ public:
|
|||
|
||||
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;
|
||||
|
@ -94,8 +93,7 @@ public:
|
|||
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;
|
||||
}
|
||||
|
@ -140,6 +138,9 @@ public:
|
|||
// 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.
|
||||
|
|
Loading…
Reference in New Issue