forked from OSchip/llvm-project
Simplify setting the Live bit in SectionPiece. NFC.
llvm-svn: 283340
This commit is contained in:
parent
d836a9d5f1
commit
939e9493bf
|
@ -533,12 +533,13 @@ std::vector<SectionPiece>
|
||||||
MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) {
|
MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) {
|
||||||
std::vector<SectionPiece> V;
|
std::vector<SectionPiece> V;
|
||||||
size_t Off = 0;
|
size_t Off = 0;
|
||||||
|
bool IsAlloca = this->getSectionHdr()->sh_flags & SHF_ALLOC;
|
||||||
while (!Data.empty()) {
|
while (!Data.empty()) {
|
||||||
size_t End = findNull(Data, EntSize);
|
size_t End = findNull(Data, EntSize);
|
||||||
if (End == StringRef::npos)
|
if (End == StringRef::npos)
|
||||||
fatal(getName(this) + ": string is not null terminated");
|
fatal(getName(this) + ": string is not null terminated");
|
||||||
size_t Size = End + EntSize;
|
size_t Size = End + EntSize;
|
||||||
V.emplace_back(Off, Data.slice(0, Size));
|
V.emplace_back(Off, Data.slice(0, Size), !IsAlloca);
|
||||||
Data = Data.slice(Size);
|
Data = Data.slice(Size);
|
||||||
Off += Size;
|
Off += Size;
|
||||||
}
|
}
|
||||||
|
@ -573,16 +574,9 @@ template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() {
|
||||||
else
|
else
|
||||||
this->Pieces = splitNonStrings(Data, EntSize);
|
this->Pieces = splitNonStrings(Data, EntSize);
|
||||||
|
|
||||||
if (Config->GcSections) {
|
if (Config->GcSections && this->getSectionHdr()->sh_flags & SHF_ALLOC)
|
||||||
if (this->getSectionHdr()->sh_flags & SHF_ALLOC) {
|
for (uintX_t Off : LiveOffsets)
|
||||||
for (uintX_t Off : LiveOffsets)
|
this->getSectionPiece(Off)->Live = true;
|
||||||
this->getSectionPiece(Off)->Live = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (SectionPiece &Piece : this->Pieces)
|
|
||||||
Piece.Live = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
|
|
|
@ -122,9 +122,9 @@ template <class ELFT> InputSectionBase<ELFT> InputSectionBase<ELFT>::Discarded;
|
||||||
|
|
||||||
// SectionPiece represents a piece of splittable section contents.
|
// SectionPiece represents a piece of splittable section contents.
|
||||||
struct SectionPiece {
|
struct SectionPiece {
|
||||||
SectionPiece(size_t Off, ArrayRef<uint8_t> Data)
|
SectionPiece(size_t Off, ArrayRef<uint8_t> Data, bool Live = false)
|
||||||
: InputOff(Off), Data((const uint8_t *)Data.data()), Size(Data.size()),
|
: InputOff(Off), Data((const uint8_t *)Data.data()), Size(Data.size()),
|
||||||
Live(!Config->GcSections) {}
|
Live(Live || !Config->GcSections) {}
|
||||||
|
|
||||||
ArrayRef<uint8_t> data() { return {Data, Size}; }
|
ArrayRef<uint8_t> data() { return {Data, Size}; }
|
||||||
size_t size() const { return Size; }
|
size_t size() const { return Size; }
|
||||||
|
|
Loading…
Reference in New Issue