[ELF] - Remove excessive loop in LinkerScript<ELFT>::assignAddresses()

After 278461 "Create only one section for a name in LinkerScript."
this loop is excessive. 
Patch also reorders code slightly to use early return.

Differential revision: https://reviews.llvm.org/D23442

llvm-svn: 278554
This commit is contained in:
George Rimar 2016-08-12 19:32:45 +00:00
parent 1512f9a0f9
commit b6c52e8dfa
1 changed files with 28 additions and 28 deletions

View File

@ -362,13 +362,13 @@ template <class ELFT> void LinkerScript<ELFT>::assignAddresses() {
continue;
}
// Find all the sections with required name. There can be more than
// one section with such name, if the alignment, flags or type
// attribute differs.
auto *Cmd = cast<OutputSectionCommand>(Base.get());
for (OutputSectionBase<ELFT> *Sec : *OutputSections) {
if (Sec->getName() != Cmd->Name)
auto I = llvm::find_if(*OutputSections, [&](OutputSectionBase<ELFT> *S) {
return S->getName() == Cmd->Name;
});
if (I == OutputSections->end())
continue;
OutputSectionBase<ELFT> *Sec = *I;
if (Cmd->AddrExpr)
Dot = Cmd->AddrExpr(Dot);
@ -385,16 +385,16 @@ template <class ELFT> void LinkerScript<ELFT>::assignAddresses() {
continue;
}
if (Sec->getFlags() & SHF_ALLOC) {
if (!(Sec->getFlags() & SHF_ALLOC)) {
Sec->assignOffsets();
continue;
}
Dot = alignTo(Dot, Sec->getAlignment());
Sec->setVA(Dot);
assignOffsets(Sec);
MinVA = std::min(MinVA, Dot);
Dot += Sec->getSize();
continue;
}
Sec->assignOffsets();
}
}
// ELF and Program headers need to be right before the first section in