[PATCH] D23442: [ELF] - Remove excessive loop in LinkerScript<ELFT>::assignAddresses()
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 12:40:37 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278554: [ELF] - Remove excessive loop in LinkerScript<ELFT>::assignAddresses() (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D23442?vs=67815&id=67885#toc
Repository:
rL LLVM
https://reviews.llvm.org/D23442
Files:
lld/trunk/ELF/LinkerScript.cpp
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -362,39 +362,39 @@
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)
- continue;
+ 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);
+ if (Cmd->AddrExpr)
+ Dot = Cmd->AddrExpr(Dot);
- if (Cmd->AlignExpr)
- Sec->updateAlignment(Cmd->AlignExpr(Dot));
+ if (Cmd->AlignExpr)
+ Sec->updateAlignment(Cmd->AlignExpr(Dot));
- if ((Sec->getFlags() & SHF_TLS) && Sec->getType() == SHT_NOBITS) {
- uintX_t TVA = Dot + ThreadBssOffset;
- TVA = alignTo(TVA, Sec->getAlignment());
- Sec->setVA(TVA);
- assignOffsets(Sec);
- ThreadBssOffset = TVA - Dot + Sec->getSize();
- continue;
- }
+ if ((Sec->getFlags() & SHF_TLS) && Sec->getType() == SHT_NOBITS) {
+ uintX_t TVA = Dot + ThreadBssOffset;
+ TVA = alignTo(TVA, Sec->getAlignment());
+ Sec->setVA(TVA);
+ assignOffsets(Sec);
+ ThreadBssOffset = TVA - Dot + Sec->getSize();
+ continue;
+ }
- if (Sec->getFlags() & SHF_ALLOC) {
- Dot = alignTo(Dot, Sec->getAlignment());
- Sec->setVA(Dot);
- assignOffsets(Sec);
- MinVA = std::min(MinVA, Dot);
- Dot += Sec->getSize();
- continue;
- }
+ 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();
}
// ELF and Program headers need to be right before the first section in
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23442.67885.patch
Type: text/x-patch
Size: 2253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160812/21152796/attachment.bin>
More information about the llvm-commits
mailing list