summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 8570a807d32..836d36a5149 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1010,11 +1010,14 @@ findOrphanPos(std::vector<BaseCommand *>::iterator B,
Sec->SortRank < CurSec->SortRank)
break;
}
+
+ auto IsLiveSection = [](BaseCommand *Cmd) {
+ auto *OS = dyn_cast<OutputSection>(Cmd);
+ return OS && OS->Live;
+ };
+
auto J = std::find_if(llvm::make_reverse_iterator(I),
- llvm::make_reverse_iterator(B), [](BaseCommand *Cmd) {
- auto *OS = dyn_cast<OutputSection>(Cmd);
- return OS && OS->Live;
- });
+ llvm::make_reverse_iterator(B), IsLiveSection);
I = J.base();
// As a special case, if the orphan section is the last section, put
@@ -1022,8 +1025,7 @@ findOrphanPos(std::vector<BaseCommand *>::iterator B,
// This matches bfd's behavior and is convenient when the linker script fully
// specifies the start of the file, but doesn't care about the end (the non
// alloc sections for example).
- auto NextSec = std::find_if(
- I, E, [](BaseCommand *Cmd) { return isa<OutputSection>(Cmd); });
+ auto NextSec = std::find_if(I, E, IsLiveSection);
if (NextSec == E)
return E;
OpenPOWER on IntegriCloud