[ELF] Remove one inputSections loop. NFC

This commit is contained in:
Fangrui Song 2022-07-29 00:03:50 -07:00
parent 52cd00cabf
commit 4db7c7dbb4
2 changed files with 5 additions and 3 deletions

View File

@ -2779,9 +2779,6 @@ void LinkerDriver::link(opt::InputArgList &args) {
for (SectionCommand *cmd : script->sectionCommands)
if (auto *osd = dyn_cast<OutputDesc>(cmd))
osd->osec.finalizeInputSections();
llvm::erase_if(inputSections, [](InputSectionBase *s) {
return isa<MergeInputSection>(s);
});
}
// Two input sections with different output sections should not be folded.

View File

@ -846,7 +846,11 @@ void LinkerScript::addOrphanSections() {
// to be created before we create relocation output section, so we want
// to create target sections first. We do not want priority handling
// for synthetic sections because them are special.
size_t n = 0;
for (InputSectionBase *isec : inputSections) {
if (!isa<MergeInputSection>(isec))
inputSections[n++] = isec;
// In -r links, SHF_LINK_ORDER sections are added while adding their parent
// sections because we need to know the parent's output section before we
// can select an output section for the SHF_LINK_ORDER section.
@ -863,6 +867,7 @@ void LinkerScript::addOrphanSections() {
if (depSec->flags & SHF_LINK_ORDER)
add(depSec);
}
inputSections.resize(n);
// If no SECTIONS command was given, we should insert sections commands
// before others, so that we can handle scripts which refers them,