diff --git a/lld/ELF/AArch64ErrataFix.cpp b/lld/ELF/AArch64ErrataFix.cpp index b9fd4cdbad690..331a5786fc34d 100644 --- a/lld/ELF/AArch64ErrataFix.cpp +++ b/lld/ELF/AArch64ErrataFix.cpp @@ -630,7 +630,7 @@ bool AArch64Err843419Patcher::createFixes() { 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(bc)) { std::vector patches = patchInputSectionDescription(*isd); diff --git a/lld/ELF/ARMErrataFix.cpp b/lld/ELF/ARMErrataFix.cpp index 77623780ffa5a..bf41f65b95dd7 100644 --- a/lld/ELF/ARMErrataFix.cpp +++ b/lld/ELF/ARMErrataFix.cpp @@ -525,7 +525,7 @@ bool ARMErr657417Patcher::createFixes() { 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(bc)) { std::vector patches = patchInputSectionDescription(*isd); diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index c139698069161..b35e46b4fc639 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -554,7 +554,7 @@ template void ICF::run() { // ICF may fold some input sections assigned to output sections. Remove them. for (BaseCommand *base : script->sectionCommands) if (auto *sec = dyn_cast(base)) - for (BaseCommand *sub_base : sec->sectionCommands) + for (BaseCommand *sub_base : sec->commands) if (auto *isd = dyn_cast(sub_base)) llvm::erase_if(isd->sections, [](InputSection *isec) { return !isec->isLive(); }); diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 5e09e5dde39d1..d9346c891006e 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -285,7 +285,7 @@ getSymbolAssignmentValues(const std::vector §ionCommands) { std::make_pair(cmd->sym->section, cmd->sym->value)); continue; } - for (BaseCommand *sub_base : cast(base)->sectionCommands) + for (BaseCommand *sub_base : cast(base)->commands) if (auto *cmd = dyn_cast(sub_base)) if (cmd->sym) ret.try_emplace(cmd->sym, @@ -360,7 +360,7 @@ void LinkerScript::declareSymbols() { auto *sec = cast(base); if (sec->constraint != ConstraintKind::NoConstraint) continue; - for (BaseCommand *base2 : sec->sectionCommands) + for (BaseCommand *base2 : sec->commands) if (auto *cmd = dyn_cast(base2)) declareSymbol(cmd); } @@ -588,7 +588,7 @@ void LinkerScript::discardSynthetic(OutputSection &outCmd) { continue; std::vector secs(part.armExidx->exidxSections.begin(), part.armExidx->exidxSections.end()); - for (BaseCommand *base : outCmd.sectionCommands) + for (BaseCommand *base : outCmd.commands) if (auto *cmd = dyn_cast(base)) { std::vector matches = computeInputSections(cmd, secs); @@ -602,7 +602,7 @@ std::vector LinkerScript::createInputSectionList(OutputSection &outCmd) { std::vector ret; - for (BaseCommand *base : outCmd.sectionCommands) { + for (BaseCommand *base : outCmd.commands) { if (auto *cmd = dyn_cast(base)) { cmd->sectionBases = computeInputSections(cmd, inputSections); for (InputSectionBase *s : cmd->sectionBases) @@ -624,7 +624,7 @@ void LinkerScript::processSectionCommands() { for (InputSectionBase *s : v) discard(s); discardSynthetic(*osec); - osec->sectionCommands.clear(); + osec->commands.clear(); return false; } @@ -638,7 +638,7 @@ void LinkerScript::processSectionCommands() { if (!matchConstraints(v, osec->constraint)) { for (InputSectionBase *s : v) s->parent = nullptr; - osec->sectionCommands.clear(); + osec->commands.clear(); return false; } @@ -703,7 +703,7 @@ void LinkerScript::processSymbolAssignments() { if (auto *cmd = dyn_cast(base)) addSymbol(cmd); else - for (BaseCommand *sub_base : cast(base)->sectionCommands) + for (BaseCommand *sub_base : cast(base)->commands) if (auto *cmd = dyn_cast(sub_base)) addSymbol(cmd); } @@ -813,8 +813,7 @@ addInputSec(StringMap> &map, // 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( - cast(sec->sectionCommands[0]) - ->sectionBases[0]); + cast(sec->commands[0])->sectionBases[0]); OutputSection *firstIsecOut = firstIsec->flags & SHF_LINK_ORDER ? firstIsec->getLinkOrderDep()->getOutputSection() @@ -1059,7 +1058,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) { // 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(base)) { cmd->addr = dot; @@ -1110,7 +1109,7 @@ static bool isDiscardable(const OutputSection &sec) { if (sec.usedInExpression) return false; - for (BaseCommand *base : sec.sectionCommands) { + for (BaseCommand *base : sec.commands) { if (auto cmd = dyn_cast(base)) // Don't create empty output sections just for unreferenced PROVIDE // symbols. diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp index c4690ae5aefdc..9ae8d7b303fa4 100644 --- a/lld/ELF/MapFile.cpp +++ b/lld/ELF/MapFile.cpp @@ -179,7 +179,7 @@ void elf::writeMapFile() { 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(base)) { for (InputSection *isec : isd->sections) { if (auto *ehSec = dyn_cast(isec)) { diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index cc4f0688701a3..8890427cd185c 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -100,10 +100,9 @@ static bool canMergeToProgbits(unsigned type) { void OutputSection::recordSection(InputSectionBase *isec) { partition = isec->partition; isec->parent = this; - if (sectionCommands.empty() || - !isa(sectionCommands.back())) - sectionCommands.push_back(make("")); - auto *isd = cast(sectionCommands.back()); + if (commands.empty() || !isa(commands.back())) + commands.push_back(make("")); + auto *isd = cast(commands.back()); isd->sectionBases.push_back(isec); } @@ -166,7 +165,7 @@ void OutputSection::commitSection(InputSection *isec) { // to compute an output offset for each piece of each input section. void OutputSection::finalizeInputSections() { std::vector mergeSections; - for (BaseCommand *base : sectionCommands) { + for (BaseCommand *base : commands) { auto *cmd = dyn_cast(base); if (!cmd) continue; @@ -243,7 +242,7 @@ bool OutputSection::classof(const BaseCommand *c) { void OutputSection::sort(llvm::function_ref order) { assert(isLive()); - for (BaseCommand *b : sectionCommands) + for (BaseCommand *b : commands) if (auto *isd = dyn_cast(b)) sortByOrder(isd->sections, order); } @@ -367,7 +366,7 @@ template void OutputSection::writeTo(uint8_t *buf) { // 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(base)) writeInt(buf + data->offset, data->expression().getValue(), data->size); } @@ -485,8 +484,8 @@ static bool compCtors(const InputSection *a, const InputSection *b) { // 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(sectionCommands[0]); + assert(commands.size() == 1); + auto *isd = cast(commands[0]); llvm::stable_sort(isd->sections, compCtors); } @@ -505,7 +504,7 @@ int elf::getPriority(StringRef s) { } InputSection *elf::getFirstInputSection(const OutputSection *os) { - for (BaseCommand *base : os->sectionCommands) + for (BaseCommand *base : os->commands) if (auto *isd = dyn_cast(base)) if (!isd->sections.empty()) return isd->sections[0]; @@ -514,7 +513,7 @@ InputSection *elf::getFirstInputSection(const OutputSection *os) { std::vector elf::getInputSections(const OutputSection *os) { std::vector ret; - for (BaseCommand *base : os->sectionCommands) + for (BaseCommand *base : os->commands) if (auto *isd = dyn_cast(base)) ret.insert(ret.end(), isd->sections.begin(), isd->sections.end()); return ret; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index a0f8066143872..fe9fd4ed3785b 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -82,7 +82,7 @@ class OutputSection final : public BaseCommand, public SectionBase { Expr alignExpr; Expr lmaExpr; Expr subalignExpr; - std::vector sectionCommands; + std::vector commands; std::vector phdrs; llvm::Optional> filler; ConstraintKind constraint = ConstraintKind::NoConstraint; diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 9c22ce7d60133..023a04f00450e 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -366,10 +366,10 @@ template static void addCopyRelSymbol(SharedSymbol &ss) { // At this point, sectionBases has been migrated to sections. Append sec to // sections. - if (osec->sectionCommands.empty() || - !isa(osec->sectionCommands.back())) - osec->sectionCommands.push_back(make("")); - auto *isd = cast(osec->sectionCommands.back()); + if (osec->commands.empty() || + !isa(osec->commands.back())) + osec->commands.push_back(make("")); + auto *isd = cast(osec->commands.back()); isd->sections.push_back(sec); osec->commitSection(sec); @@ -1640,7 +1640,7 @@ static void forEachInputSectionDescription( 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(bc)) fn(os, isd); } @@ -1817,7 +1817,7 @@ ThunkSection *ThunkCreator::getISThunkSec(InputSection *isec) { // 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(bc); if (!isd || isd->sections.empty()) continue; diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index cc18a59da2369..d91caed8c6261 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -849,7 +849,7 @@ OutputSection *ScriptParser::readOverlaySectionDescription() { 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 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef outSec) { 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 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef outSec) { } 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 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef outSec) { // case above. auto *isd = make(tok); isd->sectionPatterns.push_back({{}, StringMatcher("*")}); - cmd->sectionCommands.push_back(isd); + cmd->commands.push_back(isd); } } diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 3936f0f0d74f5..0413e3105e963 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -900,7 +900,7 @@ void MipsGotSection::build() { 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(cmd)) for (InputSection *isec : isd->sections) { uint64_t off = alignTo(secSize, isec->alignment); @@ -3604,7 +3604,7 @@ PPC32Got2Section::PPC32Got2Section() 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(base)) for (InputSection *isec : isd->sections) if (isec != this) @@ -3618,7 +3618,7 @@ void PPC32Got2Section::finalizeContents() { // 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(base)) { for (InputSection *isec : isd->sections) { if (isec == this) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index da7fd788d1bd8..59a7519468441 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -729,12 +729,12 @@ template void Writer::addSectionSymbols() { auto *sec = dyn_cast(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(base)) return !isd->sections.empty(); return false; }); - if (i == sec->sectionCommands.end()) + if (i == sec->commands.end()) continue; InputSectionBase *isec = cast(*i)->sections[0]; @@ -1420,7 +1420,7 @@ static void sortSection(OutputSection *sec, // 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(b)) sortISDBySectionOrder(isd, order); @@ -1437,8 +1437,8 @@ static void sortSection(OutputSection *sec, // 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(sec->sectionCommands[0]); + assert(sec->commands.size() == 1); + auto *isd = cast(sec->commands[0]); llvm::stable_sort(isd->sections, [](const InputSection *a, const InputSection *b) -> bool { return a->file->ppc64SmallCodeModelTocRelocs && @@ -1608,7 +1608,7 @@ template void Writer::resolveShfLinkOrder() { // Sorting is performed separately. std::vector scriptSections; std::vector sections; - for (BaseCommand *base : sec->sectionCommands) { + for (BaseCommand *base : sec->commands) { auto *isd = dyn_cast(base); if (!isd) continue; @@ -1842,7 +1842,7 @@ static void removeUnusedSyntheticSections() { // 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(b)) isdSet.insert(isd);