parent
187b67a533
commit
0543343170
|
@ -344,7 +344,7 @@ void ObjFile<ELFT>::initializeSections(
|
||||||
fatal(toString(this) + ": invalid sh_link index: " +
|
fatal(toString(this) + ": invalid sh_link index: " +
|
||||||
Twine(Sec.sh_link));
|
Twine(Sec.sh_link));
|
||||||
this->Sections[Sec.sh_link]->DependentSections.push_back(
|
this->Sections[Sec.sh_link]->DependentSections.push_back(
|
||||||
this->Sections[I]);
|
cast<InputSection>(this->Sections[I]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ public:
|
||||||
InputSectionBase *Repl;
|
InputSectionBase *Repl;
|
||||||
|
|
||||||
// InputSections that are dependent on us (reverse dependency for GC)
|
// InputSections that are dependent on us (reverse dependency for GC)
|
||||||
llvm::TinyPtrVector<InputSectionBase *> DependentSections;
|
llvm::TinyPtrVector<InputSection *> DependentSections;
|
||||||
|
|
||||||
// Returns the size of this section (even if this is a common or BSS.)
|
// Returns the size of this section (even if this is a common or BSS.)
|
||||||
size_t getSize() const;
|
size_t getSize() const;
|
||||||
|
|
|
@ -219,13 +219,13 @@ getComparator(SortSectionPolicy K) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper function for the SORT() command.
|
// A helper function for the SORT() command.
|
||||||
static bool matchConstraints(ArrayRef<InputSectionBase *> Sections,
|
static bool matchConstraints(ArrayRef<InputSection *> Sections,
|
||||||
ConstraintKind Kind) {
|
ConstraintKind Kind) {
|
||||||
if (Kind == ConstraintKind::NoConstraint)
|
if (Kind == ConstraintKind::NoConstraint)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool IsRW = llvm::any_of(
|
bool IsRW = llvm::any_of(
|
||||||
Sections, [](InputSectionBase *Sec) { return Sec->Flags & SHF_WRITE; });
|
Sections, [](InputSection *Sec) { return Sec->Flags & SHF_WRITE; });
|
||||||
|
|
||||||
return (IsRW && Kind == ConstraintKind::ReadWrite) ||
|
return (IsRW && Kind == ConstraintKind::ReadWrite) ||
|
||||||
(!IsRW && Kind == ConstraintKind::ReadOnly);
|
(!IsRW && Kind == ConstraintKind::ReadOnly);
|
||||||
|
@ -311,8 +311,8 @@ LinkerScript::computeInputSections(const InputSectionDescription *Cmd) {
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkerScript::discard(ArrayRef<InputSectionBase *> V) {
|
void LinkerScript::discard(ArrayRef<InputSection *> V) {
|
||||||
for (InputSectionBase *S : V) {
|
for (InputSection *S : V) {
|
||||||
S->Live = false;
|
S->Live = false;
|
||||||
if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab ||
|
if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab ||
|
||||||
S == InX::DynStrTab)
|
S == InX::DynStrTab)
|
||||||
|
@ -321,19 +321,16 @@ void LinkerScript::discard(ArrayRef<InputSectionBase *> V) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<InputSectionBase *>
|
std::vector<InputSection *>
|
||||||
LinkerScript::createInputSectionList(OutputSection &OutCmd) {
|
LinkerScript::createInputSectionList(OutputSection &OutCmd) {
|
||||||
std::vector<InputSectionBase *> Ret;
|
std::vector<InputSection *> Ret;
|
||||||
|
|
||||||
for (BaseCommand *Base : OutCmd.SectionCommands) {
|
for (BaseCommand *Base : OutCmd.SectionCommands) {
|
||||||
auto *Cmd = dyn_cast<InputSectionDescription>(Base);
|
if (auto *Cmd = dyn_cast<InputSectionDescription>(Base)) {
|
||||||
if (!Cmd)
|
Cmd->Sections = computeInputSections(Cmd);
|
||||||
continue;
|
Ret.insert(Ret.end(), Cmd->Sections.begin(), Cmd->Sections.end());
|
||||||
|
}
|
||||||
Cmd->Sections = computeInputSections(Cmd);
|
|
||||||
Ret.insert(Ret.end(), Cmd->Sections.begin(), Cmd->Sections.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +362,7 @@ void LinkerScript::processSectionCommands(OutputSectionFactory &Factory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto *Sec = dyn_cast<OutputSection>(SectionCommands[I])) {
|
if (auto *Sec = dyn_cast<OutputSection>(SectionCommands[I])) {
|
||||||
std::vector<InputSectionBase *> V = createInputSectionList(*Sec);
|
std::vector<InputSection *> V = createInputSectionList(*Sec);
|
||||||
|
|
||||||
// The output section name `/DISCARD/' is special.
|
// The output section name `/DISCARD/' is special.
|
||||||
// Any input section assigned to it is discarded.
|
// Any input section assigned to it is discarded.
|
||||||
|
@ -405,8 +402,8 @@ void LinkerScript::processSectionCommands(OutputSectionFactory &Factory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add input sections to an output section.
|
// Add input sections to an output section.
|
||||||
for (InputSectionBase *S : V)
|
for (InputSection *S : V)
|
||||||
Sec->addSection(cast<InputSection>(S));
|
Sec->addSection(S);
|
||||||
|
|
||||||
assert(Sec->SectionIndex == INT_MAX);
|
assert(Sec->SectionIndex == INT_MAX);
|
||||||
Sec->SectionIndex = I;
|
Sec->SectionIndex = I;
|
||||||
|
|
|
@ -207,7 +207,7 @@ class LinkerScript final {
|
||||||
std::vector<InputSection *>
|
std::vector<InputSection *>
|
||||||
computeInputSections(const InputSectionDescription *);
|
computeInputSections(const InputSectionDescription *);
|
||||||
|
|
||||||
std::vector<InputSectionBase *> createInputSectionList(OutputSection &Cmd);
|
std::vector<InputSection *> createInputSectionList(OutputSection &Cmd);
|
||||||
|
|
||||||
std::vector<size_t> getPhdrIndices(OutputSection *Sec);
|
std::vector<size_t> getPhdrIndices(OutputSection *Sec);
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ public:
|
||||||
|
|
||||||
bool hasPhdrsCommands() { return !PhdrsCommands.empty(); }
|
bool hasPhdrsCommands() { return !PhdrsCommands.empty(); }
|
||||||
uint64_t getDot() { return Dot; }
|
uint64_t getDot() { return Dot; }
|
||||||
void discard(ArrayRef<InputSectionBase *> V);
|
void discard(ArrayRef<InputSection *> V);
|
||||||
|
|
||||||
ExprValue getSymbolValue(const Twine &Loc, StringRef S);
|
ExprValue getSymbolValue(const Twine &Loc, StringRef S);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue