summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/InputSection.cpp16
-rw-r--r--lld/ELF/InputSection.h4
2 files changed, 7 insertions, 13 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 8137b16035d..2f265e35ae6 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -533,12 +533,13 @@ std::vector<SectionPiece>
MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) {
std::vector<SectionPiece> V;
size_t Off = 0;
+ bool IsAlloca = this->getSectionHdr()->sh_flags & SHF_ALLOC;
while (!Data.empty()) {
size_t End = findNull(Data, EntSize);
if (End == StringRef::npos)
fatal(getName(this) + ": string is not null terminated");
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);
Off += Size;
}
@@ -573,16 +574,9 @@ template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() {
else
this->Pieces = splitNonStrings(Data, EntSize);
- if (Config->GcSections) {
- if (this->getSectionHdr()->sh_flags & SHF_ALLOC) {
- for (uintX_t Off : LiveOffsets)
- this->getSectionPiece(Off)->Live = true;
- return;
- }
-
- for (SectionPiece &Piece : this->Pieces)
- Piece.Live = true;
- }
+ if (Config->GcSections && this->getSectionHdr()->sh_flags & SHF_ALLOC)
+ for (uintX_t Off : LiveOffsets)
+ this->getSectionPiece(Off)->Live = true;
}
template <class ELFT>
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index ad63e16f69c..34549156f6b 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -122,9 +122,9 @@ template <class ELFT> InputSectionBase<ELFT> InputSectionBase<ELFT>::Discarded;
// SectionPiece represents a piece of splittable section contents.
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()),
- Live(!Config->GcSections) {}
+ Live(Live || !Config->GcSections) {}
ArrayRef<uint8_t> data() { return {Data, Size}; }
size_t size() const { return Size; }
OpenPOWER on IntegriCloud