[lld] r314654 - [ELF] - Stop removing sections in removeUnusedSyntheticSections().
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 02:11:13 PDT 2017
Author: grimar
Date: Mon Oct 2 02:11:13 2017
New Revision: 314654
URL: http://llvm.org/viewvc/llvm-project?rev=314654&view=rev
Log:
[ELF] - Stop removing sections in removeUnusedSyntheticSections().
That makes code a bit more consistent. Instead of removing sections there
we can just mark them as dead. So that removeEmptyCommands() will
handle the rest.
Differential revision: https://reviews.llvm.org/D38393
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=314654&r1=314653&r2=314654&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Oct 2 02:11:13 2017
@@ -677,6 +677,8 @@ void LinkerScript::adjustSectionsAfterSo
// Try and find an appropriate memory region to assign offsets in.
for (BaseCommand *Base : Opt.Commands) {
if (auto *Sec = dyn_cast<OutputSection>(Base)) {
+ if (!Sec->Live)
+ continue;
Sec->MemRegion = findMemoryRegion(Sec);
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
if (Sec->AlignExpr)
@@ -713,8 +715,6 @@ void LinkerScript::adjustSectionsAfterSo
DefPhdrs = Sec->Phdrs;
}
}
-
- removeEmptyCommands();
}
static OutputSection *findFirstSection(PhdrEntry *Load) {
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=314654&r1=314653&r2=314654&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Oct 2 02:11:13 2017
@@ -1054,8 +1054,7 @@ findOrphanPos(std::vector<BaseCommand *>
}
template <class ELFT> void Writer<ELFT>::sortSections() {
- if (Script->Opt.HasSections)
- Script->adjustSectionsBeforeSorting();
+ Script->adjustSectionsBeforeSorting();
// Don't sort if using -r. It is not necessary and we want to preserve the
// relative order for SHF_LINK_ORDER sections.
@@ -1197,8 +1196,7 @@ static void removeUnusedSyntheticSection
// If there are no other sections in the output section, remove it from the
// output.
if (OS->Commands.empty())
- llvm::erase_if(Script->Opt.Commands,
- [&](BaseCommand *Cmd) { return Cmd == OS; });
+ OS->Live = false;
}
}
@@ -1304,6 +1302,7 @@ template <class ELFT> void Writer<ELFT>:
removeUnusedSyntheticSections();
sortSections();
+ Script->removeEmptyCommands();
// Now that we have the final list, create a list of all the
// OutputSections for convenience.
More information about the llvm-commits
mailing list