diff options
Diffstat (limited to 'lld/ELF/Writer.cpp')
| -rw-r--r-- | lld/ELF/Writer.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 92888930247..396e9ae1552 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1031,9 +1031,11 @@ findOrphanPos(std::vector<BaseCommand *>::iterator B, Sec->SortRank < CurSec->SortRank) break; } - auto J = std::find_if( - llvm::make_reverse_iterator(I), llvm::make_reverse_iterator(B), - [](BaseCommand *Cmd) { return isa<OutputSection>(Cmd); }); + 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; + }); I = J.base(); // As a special case, if the orphan section is the last section, put |

