[lld] 4db7c7d - [ELF] Remove one inputSections loop. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 00:03:55 PDT 2022
Author: Fangrui Song
Date: 2022-07-29T00:03:50-07:00
New Revision: 4db7c7dbb415c67ddd5248c149fc6fa8ac30161d
URL: https://github.com/llvm/llvm-project/commit/4db7c7dbb415c67ddd5248c149fc6fa8ac30161d
DIFF: https://github.com/llvm/llvm-project/commit/4db7c7dbb415c67ddd5248c149fc6fa8ac30161d.diff
LOG: [ELF] Remove one inputSections loop. NFC
Added:
Modified:
lld/ELF/Driver.cpp
lld/ELF/LinkerScript.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 6c0fd3139e87..7dc4ab2f57de 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -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
diff erent output sections should not be folded.
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 9f30117c0279..6028652b2b20 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -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,
More information about the llvm-commits
mailing list