[ELF] Rename OutputSection::sectionCommands to commands. NFC
This partially reverts r315409: the description applies to LinkerScript, but not
to OutputSection.
The name "sectionCommands" is used in both LinkerScript::sectionCommands and
OutputSection::sectionCommands, which may lead to confusion.
"commands" in OutputSection has no ambiguity because there are no other types
of commands.
GitOrigin-RevId: 6188fd495744ffea76f481a960df9beacb8ce91b
diff --git a/ELF/AArch64ErrataFix.cpp b/ELF/AArch64ErrataFix.cpp
index b9fd4cd..331a578 100644
--- a/ELF/AArch64ErrataFix.cpp
+++ b/ELF/AArch64ErrataFix.cpp
@@ -630,7 +630,7 @@
for (OutputSection *os : outputSections) {
if (!(os->flags & SHF_ALLOC) || !(os->flags & SHF_EXECINSTR))
continue;
- for (BaseCommand *bc : os->sectionCommands)
+ for (BaseCommand *bc : os->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(bc)) {
std::vector<Patch843419Section *> patches =
patchInputSectionDescription(*isd);
diff --git a/ELF/ARMErrataFix.cpp b/ELF/ARMErrataFix.cpp
index 7762378..bf41f65 100644
--- a/ELF/ARMErrataFix.cpp
+++ b/ELF/ARMErrataFix.cpp
@@ -525,7 +525,7 @@
for (OutputSection *os : outputSections) {
if (!(os->flags & SHF_ALLOC) || !(os->flags & SHF_EXECINSTR))
continue;
- for (BaseCommand *bc : os->sectionCommands)
+ for (BaseCommand *bc : os->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(bc)) {
std::vector<Patch657417Section *> patches =
patchInputSectionDescription(*isd);
diff --git a/ELF/ICF.cpp b/ELF/ICF.cpp
index c139698..b35e46b 100644
--- a/ELF/ICF.cpp
+++ b/ELF/ICF.cpp
@@ -554,7 +554,7 @@
// ICF may fold some input sections assigned to output sections. Remove them.
for (BaseCommand *base : script->sectionCommands)
if (auto *sec = dyn_cast<OutputSection>(base))
- for (BaseCommand *sub_base : sec->sectionCommands)
+ for (BaseCommand *sub_base : sec->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(sub_base))
llvm::erase_if(isd->sections,
[](InputSection *isec) { return !isec->isLive(); });
diff --git a/ELF/LinkerScript.cpp b/ELF/LinkerScript.cpp
index 5e09e5d..d9346c8 100644
--- a/ELF/LinkerScript.cpp
+++ b/ELF/LinkerScript.cpp
@@ -285,7 +285,7 @@
std::make_pair(cmd->sym->section, cmd->sym->value));
continue;
}
- for (BaseCommand *sub_base : cast<OutputSection>(base)->sectionCommands)
+ for (BaseCommand *sub_base : cast<OutputSection>(base)->commands)
if (auto *cmd = dyn_cast<SymbolAssignment>(sub_base))
if (cmd->sym)
ret.try_emplace(cmd->sym,
@@ -360,7 +360,7 @@
auto *sec = cast<OutputSection>(base);
if (sec->constraint != ConstraintKind::NoConstraint)
continue;
- for (BaseCommand *base2 : sec->sectionCommands)
+ for (BaseCommand *base2 : sec->commands)
if (auto *cmd = dyn_cast<SymbolAssignment>(base2))
declareSymbol(cmd);
}
@@ -588,7 +588,7 @@
continue;
std::vector<InputSectionBase *> secs(part.armExidx->exidxSections.begin(),
part.armExidx->exidxSections.end());
- for (BaseCommand *base : outCmd.sectionCommands)
+ for (BaseCommand *base : outCmd.commands)
if (auto *cmd = dyn_cast<InputSectionDescription>(base)) {
std::vector<InputSectionBase *> matches =
computeInputSections(cmd, secs);
@@ -602,7 +602,7 @@
LinkerScript::createInputSectionList(OutputSection &outCmd) {
std::vector<InputSectionBase *> ret;
- for (BaseCommand *base : outCmd.sectionCommands) {
+ for (BaseCommand *base : outCmd.commands) {
if (auto *cmd = dyn_cast<InputSectionDescription>(base)) {
cmd->sectionBases = computeInputSections(cmd, inputSections);
for (InputSectionBase *s : cmd->sectionBases)
@@ -624,7 +624,7 @@
for (InputSectionBase *s : v)
discard(s);
discardSynthetic(*osec);
- osec->sectionCommands.clear();
+ osec->commands.clear();
return false;
}
@@ -638,7 +638,7 @@
if (!matchConstraints(v, osec->constraint)) {
for (InputSectionBase *s : v)
s->parent = nullptr;
- osec->sectionCommands.clear();
+ osec->commands.clear();
return false;
}
@@ -703,7 +703,7 @@
if (auto *cmd = dyn_cast<SymbolAssignment>(base))
addSymbol(cmd);
else
- for (BaseCommand *sub_base : cast<OutputSection>(base)->sectionCommands)
+ for (BaseCommand *sub_base : cast<OutputSection>(base)->commands)
if (auto *cmd = dyn_cast<SymbolAssignment>(sub_base))
addSymbol(cmd);
}
@@ -813,8 +813,7 @@
// end up being linked to the same output section. The casts are fine
// because everything in the map was created by the orphan placement code.
auto *firstIsec = cast<InputSectionBase>(
- cast<InputSectionDescription>(sec->sectionCommands[0])
- ->sectionBases[0]);
+ cast<InputSectionDescription>(sec->commands[0])->sectionBases[0]);
OutputSection *firstIsecOut =
firstIsec->flags & SHF_LINK_ORDER
? firstIsec->getLinkOrderDep()->getOutputSection()
@@ -1059,7 +1058,7 @@
// We visited SectionsCommands from processSectionCommands to
// layout sections. Now, we visit SectionsCommands again to fix
// section offsets.
- for (BaseCommand *base : sec->sectionCommands) {
+ for (BaseCommand *base : sec->commands) {
// This handles the assignments to symbol or to the dot.
if (auto *cmd = dyn_cast<SymbolAssignment>(base)) {
cmd->addr = dot;
@@ -1110,7 +1109,7 @@
if (sec.usedInExpression)
return false;
- for (BaseCommand *base : sec.sectionCommands) {
+ for (BaseCommand *base : sec.commands) {
if (auto cmd = dyn_cast<SymbolAssignment>(base))
// Don't create empty output sections just for unreferenced PROVIDE
// symbols.
diff --git a/ELF/MapFile.cpp b/ELF/MapFile.cpp
index c4690ae..9ae8d7b 100644
--- a/ELF/MapFile.cpp
+++ b/ELF/MapFile.cpp
@@ -179,7 +179,7 @@
os << osec->name << '\n';
// Dump symbols for each input section.
- for (BaseCommand *base : osec->sectionCommands) {
+ for (BaseCommand *base : osec->commands) {
if (auto *isd = dyn_cast<InputSectionDescription>(base)) {
for (InputSection *isec : isd->sections) {
if (auto *ehSec = dyn_cast<EhFrameSection>(isec)) {
diff --git a/ELF/OutputSections.cpp b/ELF/OutputSections.cpp
index cc4f068..8890427 100644
--- a/ELF/OutputSections.cpp
+++ b/ELF/OutputSections.cpp
@@ -100,10 +100,9 @@
void OutputSection::recordSection(InputSectionBase *isec) {
partition = isec->partition;
isec->parent = this;
- if (sectionCommands.empty() ||
- !isa<InputSectionDescription>(sectionCommands.back()))
- sectionCommands.push_back(make<InputSectionDescription>(""));
- auto *isd = cast<InputSectionDescription>(sectionCommands.back());
+ if (commands.empty() || !isa<InputSectionDescription>(commands.back()))
+ commands.push_back(make<InputSectionDescription>(""));
+ auto *isd = cast<InputSectionDescription>(commands.back());
isd->sectionBases.push_back(isec);
}
@@ -166,7 +165,7 @@
// to compute an output offset for each piece of each input section.
void OutputSection::finalizeInputSections() {
std::vector<MergeSyntheticSection *> mergeSections;
- for (BaseCommand *base : sectionCommands) {
+ for (BaseCommand *base : commands) {
auto *cmd = dyn_cast<InputSectionDescription>(base);
if (!cmd)
continue;
@@ -243,7 +242,7 @@
void OutputSection::sort(llvm::function_ref<int(InputSectionBase *s)> order) {
assert(isLive());
- for (BaseCommand *b : sectionCommands)
+ for (BaseCommand *b : commands)
if (auto *isd = dyn_cast<InputSectionDescription>(b))
sortByOrder(isd->sections, order);
}
@@ -367,7 +366,7 @@
// Linker scripts may have BYTE()-family commands with which you
// can write arbitrary bytes to the output. Process them if any.
- for (BaseCommand *base : sectionCommands)
+ for (BaseCommand *base : commands)
if (auto *data = dyn_cast<ByteCommand>(base))
writeInt(buf + data->offset, data->expression().getValue(), data->size);
}
@@ -485,8 +484,8 @@
// Unfortunately, the rules are different from the one for .{init,fini}_array.
// Read the comment above.
void OutputSection::sortCtorsDtors() {
- assert(sectionCommands.size() == 1);
- auto *isd = cast<InputSectionDescription>(sectionCommands[0]);
+ assert(commands.size() == 1);
+ auto *isd = cast<InputSectionDescription>(commands[0]);
llvm::stable_sort(isd->sections, compCtors);
}
@@ -505,7 +504,7 @@
}
InputSection *elf::getFirstInputSection(const OutputSection *os) {
- for (BaseCommand *base : os->sectionCommands)
+ for (BaseCommand *base : os->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(base))
if (!isd->sections.empty())
return isd->sections[0];
@@ -514,7 +513,7 @@
std::vector<InputSection *> elf::getInputSections(const OutputSection *os) {
std::vector<InputSection *> ret;
- for (BaseCommand *base : os->sectionCommands)
+ for (BaseCommand *base : os->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(base))
ret.insert(ret.end(), isd->sections.begin(), isd->sections.end());
return ret;
diff --git a/ELF/OutputSections.h b/ELF/OutputSections.h
index a0f8066..fe9fd4e 100644
--- a/ELF/OutputSections.h
+++ b/ELF/OutputSections.h
@@ -82,7 +82,7 @@
Expr alignExpr;
Expr lmaExpr;
Expr subalignExpr;
- std::vector<BaseCommand *> sectionCommands;
+ std::vector<BaseCommand *> commands;
std::vector<StringRef> phdrs;
llvm::Optional<std::array<uint8_t, 4>> filler;
ConstraintKind constraint = ConstraintKind::NoConstraint;
diff --git a/ELF/Relocations.cpp b/ELF/Relocations.cpp
index 9c22ce7..023a04f 100644
--- a/ELF/Relocations.cpp
+++ b/ELF/Relocations.cpp
@@ -366,10 +366,10 @@
// At this point, sectionBases has been migrated to sections. Append sec to
// sections.
- if (osec->sectionCommands.empty() ||
- !isa<InputSectionDescription>(osec->sectionCommands.back()))
- osec->sectionCommands.push_back(make<InputSectionDescription>(""));
- auto *isd = cast<InputSectionDescription>(osec->sectionCommands.back());
+ if (osec->commands.empty() ||
+ !isa<InputSectionDescription>(osec->commands.back()))
+ osec->commands.push_back(make<InputSectionDescription>(""));
+ auto *isd = cast<InputSectionDescription>(osec->commands.back());
isd->sections.push_back(sec);
osec->commitSection(sec);
@@ -1640,7 +1640,7 @@
for (OutputSection *os : outputSections) {
if (!(os->flags & SHF_ALLOC) || !(os->flags & SHF_EXECINSTR))
continue;
- for (BaseCommand *bc : os->sectionCommands)
+ for (BaseCommand *bc : os->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(bc))
fn(os, isd);
}
@@ -1817,7 +1817,7 @@
// Find InputSectionRange within Target Output Section (TOS) that the
// InputSection (IS) that we need to precede is in.
OutputSection *tos = isec->getParent();
- for (BaseCommand *bc : tos->sectionCommands) {
+ for (BaseCommand *bc : tos->commands) {
auto *isd = dyn_cast<InputSectionDescription>(bc);
if (!isd || isd->sections.empty())
continue;
diff --git a/ELF/ScriptParser.cpp b/ELF/ScriptParser.cpp
index cc18a59..d91caed 100644
--- a/ELF/ScriptParser.cpp
+++ b/ELF/ScriptParser.cpp
@@ -849,7 +849,7 @@
uint64_t withoutFlags = 0;
if (consume("INPUT_SECTION_FLAGS"))
std::tie(withFlags, withoutFlags) = readInputSectionFlags();
- cmd->sectionCommands.push_back(
+ cmd->commands.push_back(
readInputSectionRules(next(), withFlags, withoutFlags));
}
return cmd;
@@ -885,9 +885,9 @@
if (tok == ";") {
// Empty commands are allowed. Do nothing here.
} else if (SymbolAssignment *assign = readAssignment(tok)) {
- cmd->sectionCommands.push_back(assign);
+ cmd->commands.push_back(assign);
} else if (ByteCommand *data = readByteCommand(tok)) {
- cmd->sectionCommands.push_back(data);
+ cmd->commands.push_back(data);
} else if (tok == "CONSTRUCTORS") {
// CONSTRUCTORS is a keyword to make the linker recognize C++ ctors/dtors
// by name. This is for very old file formats such as ECOFF/XCOFF.
@@ -904,7 +904,7 @@
} else if (tok == "INCLUDE") {
readInclude();
} else if (peek() == "(") {
- cmd->sectionCommands.push_back(readInputSectionDescription(tok));
+ cmd->commands.push_back(readInputSectionDescription(tok));
} else {
// We have a file name and no input sections description. It is not a
// commonly used syntax, but still acceptable. In that case, all sections
@@ -914,7 +914,7 @@
// case above.
auto *isd = make<InputSectionDescription>(tok);
isd->sectionPatterns.push_back({{}, StringMatcher("*")});
- cmd->sectionCommands.push_back(isd);
+ cmd->commands.push_back(isd);
}
}
diff --git a/ELF/SyntheticSections.cpp b/ELF/SyntheticSections.cpp
index 3936f0f..0413e31 100644
--- a/ELF/SyntheticSections.cpp
+++ b/ELF/SyntheticSections.cpp
@@ -900,7 +900,7 @@
got.pagesMap) {
const OutputSection *os = p.first;
uint64_t secSize = 0;
- for (BaseCommand *cmd : os->sectionCommands) {
+ for (BaseCommand *cmd : os->commands) {
if (auto *isd = dyn_cast<InputSectionDescription>(cmd))
for (InputSection *isec : isd->sections) {
uint64_t off = alignTo(secSize, isec->alignment);
@@ -3604,7 +3604,7 @@
bool PPC32Got2Section::isNeeded() const {
// See the comment below. This is not needed if there is no other
// InputSection.
- for (BaseCommand *base : getParent()->sectionCommands)
+ for (BaseCommand *base : getParent()->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(base))
for (InputSection *isec : isd->sections)
if (isec != this)
@@ -3618,7 +3618,7 @@
// PPC32PltCallStub::writeTo(). The purpose of this empty synthetic section is
// to collect input sections named ".got2".
uint32_t offset = 0;
- for (BaseCommand *base : getParent()->sectionCommands)
+ for (BaseCommand *base : getParent()->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(base)) {
for (InputSection *isec : isd->sections) {
if (isec == this)
diff --git a/ELF/Writer.cpp b/ELF/Writer.cpp
index da7fd78..59a7519 100644
--- a/ELF/Writer.cpp
+++ b/ELF/Writer.cpp
@@ -729,12 +729,12 @@
auto *sec = dyn_cast<OutputSection>(base);
if (!sec)
continue;
- auto i = llvm::find_if(sec->sectionCommands, [](BaseCommand *base) {
+ auto i = llvm::find_if(sec->commands, [](BaseCommand *base) {
if (auto *isd = dyn_cast<InputSectionDescription>(base))
return !isd->sections.empty();
return false;
});
- if (i == sec->sectionCommands.end())
+ if (i == sec->commands.end())
continue;
InputSectionBase *isec = cast<InputSectionDescription>(*i)->sections[0];
@@ -1420,7 +1420,7 @@
// digit radix sort. The sections may be sorted stably again by a more
// significant key.
if (!order.empty())
- for (BaseCommand *b : sec->sectionCommands)
+ for (BaseCommand *b : sec->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(b))
sortISDBySectionOrder(isd, order);
@@ -1437,8 +1437,8 @@
// addressable range of [.got, .got + 0xFFFC] for GOT-relative relocations.
// To reduce the risk of relocation overflow, .toc contents are sorted so
// that sections having smaller relocation offsets are at beginning of .toc
- assert(sec->sectionCommands.size() == 1);
- auto *isd = cast<InputSectionDescription>(sec->sectionCommands[0]);
+ assert(sec->commands.size() == 1);
+ auto *isd = cast<InputSectionDescription>(sec->commands[0]);
llvm::stable_sort(isd->sections,
[](const InputSection *a, const InputSection *b) -> bool {
return a->file->ppc64SmallCodeModelTocRelocs &&
@@ -1608,7 +1608,7 @@
// Sorting is performed separately.
std::vector<InputSection **> scriptSections;
std::vector<InputSection *> sections;
- for (BaseCommand *base : sec->sectionCommands) {
+ for (BaseCommand *base : sec->commands) {
auto *isd = dyn_cast<InputSectionDescription>(base);
if (!isd)
continue;
@@ -1842,7 +1842,7 @@
// If we reach here, then ss is an unused synthetic section and we want
// to remove it from the corresponding input section description, and
// orphanSections.
- for (BaseCommand *b : os->sectionCommands)
+ for (BaseCommand *b : os->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(b))
isdSet.insert(isd);