mirror of
https://github.com/intel/llvm.git
synced 2026-01-31 07:27:33 +08:00
Do not mutate Script->Opt.Commands from a leaf helper function.
Factory::addInputSec added an output section to Script->Opt.Commands, but that is too subtle. This patch makes it explicit so that it is easy to see when a new element is added to Script->Opt.Commands. llvm-svn: 315129
This commit is contained in:
@@ -417,6 +417,7 @@ void LinkerScript::processCommands(OutputSectionFactory &Factory) {
|
||||
// Add input sections to an output section.
|
||||
for (InputSectionBase *S : V)
|
||||
Factory.addInputSec(S, Sec->Name, Sec);
|
||||
|
||||
assert(Sec->SectionIndex == INT_MAX);
|
||||
Sec->SectionIndex = I;
|
||||
if (Sec->Noload)
|
||||
@@ -466,10 +467,12 @@ void LinkerScript::addOrphanSections(OutputSectionFactory &Factory) {
|
||||
if (OutputSection *Sec = findByName(
|
||||
makeArrayRef(Opt.Commands).slice(0, End), Name)) {
|
||||
Factory.addInputSec(S, Name, Sec);
|
||||
} else {
|
||||
Factory.addInputSec(S, Name, nullptr);
|
||||
assert(S->getOutputSection()->SectionIndex == INT_MAX);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (OutputSection *OS = Factory.addInputSec(S, Name))
|
||||
Script->Opt.Commands.push_back(OS);
|
||||
assert(S->getOutputSection()->SectionIndex == INT_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user