Skip to content

Commit 4db7c7d

Browse files
committed
[ELF] Remove one inputSections loop. NFC
1 parent 52cd00c commit 4db7c7d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lld/ELF/Driver.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,9 +2779,6 @@ void LinkerDriver::link(opt::InputArgList &args) {
27792779
for (SectionCommand *cmd : script->sectionCommands)
27802780
if (auto *osd = dyn_cast<OutputDesc>(cmd))
27812781
osd->osec.finalizeInputSections();
2782-
llvm::erase_if(inputSections, [](InputSectionBase *s) {
2783-
return isa<MergeInputSection>(s);
2784-
});
27852782
}
27862783

27872784
// Two input sections with different output sections should not be folded.

lld/ELF/LinkerScript.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,11 @@ void LinkerScript::addOrphanSections() {
846846
// to be created before we create relocation output section, so we want
847847
// to create target sections first. We do not want priority handling
848848
// for synthetic sections because them are special.
849+
size_t n = 0;
849850
for (InputSectionBase *isec : inputSections) {
851+
if (!isa<MergeInputSection>(isec))
852+
inputSections[n++] = isec;
853+
850854
// In -r links, SHF_LINK_ORDER sections are added while adding their parent
851855
// sections because we need to know the parent's output section before we
852856
// can select an output section for the SHF_LINK_ORDER section.
@@ -863,6 +867,7 @@ void LinkerScript::addOrphanSections() {
863867
if (depSec->flags & SHF_LINK_ORDER)
864868
add(depSec);
865869
}
870+
inputSections.resize(n);
866871

867872
// If no SECTIONS command was given, we should insert sections commands
868873
// before others, so that we can handle scripts which refers them,

0 commit comments

Comments
 (0)