// 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), Compressed(Compressed),
- Name(Name), Data(Data) {}
+ : SectionKind(SectionKind), Live(Live), Assigned(false),
+ Compressed(Compressed), Name(Name), Data(Data) {}
private:
unsigned SectionKind : 3;
public:
Kind kind() const { return (Kind)SectionKind; }
- unsigned Live : 1; // for garbage collection
- unsigned Compressed : 1;
+ 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;
size_t SizeBefore = I->Sections.size();
for (InputSectionBase<ELFT> *S : Symtab<ELFT>::X->Sections) {
- if (!S->Live || S->OutSec)
+ if (!S->Live || S->Assigned)
continue;
StringRef Filename;
Filename = sys::path::filename(F->getName());
if (I->FilePat.match(Filename) && !Pat.ExcludedFilePat.match(Filename) &&
- Pat.SectionPat.match(S->Name))
+ Pat.SectionPat.match(S->Name)) {
I->Sections.push_back(S);
+ S->Assigned = true;
+ }
}
// Sort sections as instructed by SORT-family commands and --sort-section
sortSections(Begin, End, Pat.SortOuter);
}
}
-
- // We do not add duplicate input sections, so mark them with a dummy output
- // section for now.
- for (InputSectionData *S : I->Sections) {
- auto *S2 = static_cast<InputSectionBase<ELFT> *>(S);
- S2->OutSec = (OutputSectionBase *)-1;
- }
}
template <class ELFT>
Ret.push_back(static_cast<InputSectionBase<ELFT> *>(S));
}
- // After we created final list we should now set OutSec pointer to null,
- // instead of -1. Otherwise we may get a crash when writing relocs, in
- // case section is discarded by linker script
- for (InputSectionBase<ELFT> *S : Ret)
- S->OutSec = nullptr;
-
return Ret;
}
if (!matchConstraints<ELFT>(V, Cmd->Constraint)) {
for (InputSectionBase<ELFT> *S : V)
- S->OutSec = nullptr;
+ S->Assigned = false;
Opt.Commands.erase(Iter);
--I;
continue;