[lld] r315427 - Split a loop into two to make it clear that it did two different things.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 21:01:24 PDT 2017
Author: ruiu
Date: Tue Oct 10 21:01:24 2017
New Revision: 315427
URL: http://llvm.org/viewvc/llvm-project?rev=315427&view=rev
Log:
Split a loop into two to make it clear that it did two different things.
Modified:
lld/trunk/ELF/LinkerScript.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=315427&r1=315426&r2=315427&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Oct 10 21:01:24 2017
@@ -354,6 +354,7 @@ void LinkerScript::processSectionCommand
Ctx = make_unique<AddressState>();
Ctx->OutSec = Aether;
+ // Add input sections to output sections.
for (size_t I = 0; I < SectionCommands.size(); ++I) {
// Handle symbol assignments outside of any output section.
if (auto *Cmd = dyn_cast<SymbolAssignment>(SectionCommands[I])) {
@@ -404,14 +405,21 @@ void LinkerScript::processSectionCommand
// Add input sections to an output section.
for (InputSection *S : V)
Sec->addSection(S);
-
- assert(Sec->SectionIndex == INT_MAX);
- Sec->SectionIndex = I;
- if (Sec->Noload)
- Sec->Type = SHT_NOBITS;
}
}
Ctx = nullptr;
+
+ // Output sections are emitted in the exact same order as
+ // appeared in SECTIONS command, so we know their section indices.
+ for (size_t I = 0; I < SectionCommands.size(); ++I) {
+ auto *Sec = dyn_cast<OutputSection>(SectionCommands[I]);
+ if (!Sec)
+ continue;
+ assert(Sec->SectionIndex == INT_MAX);
+ Sec->SectionIndex = I;
+ if (Sec->Noload)
+ Sec->Type = SHT_NOBITS;
+ }
}
void LinkerScript::fabricateDefaultCommands() {
More information about the llvm-commits
mailing list