[PATCH] D39007: [ELF] - Cleanup of setReservedSymbolSections(). NFC.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 08:46:03 PDT 2017
grimar created this revision.
Herald added a subscriber: emaste.
I suggest following cleanup to avoid duplication and make code more readable.
https://reviews.llvm.org/D39007
Files:
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -907,21 +907,19 @@
LastRO = P;
}
+ auto SetSection = [](ArrayRef<DefinedRegular *> V, OutputSection *OS) {
+ for (DefinedRegular *DR : V)
+ if (DR)
+ DR->Section = OS;
+ };
+
// _end is the first location after the uninitialized data region.
- if (Last) {
- if (ElfSym::End1)
- ElfSym::End1->Section = Last->LastSec;
- if (ElfSym::End2)
- ElfSym::End2->Section = Last->LastSec;
- }
+ if (Last)
+ SetSection({ElfSym::End1, ElfSym::End2}, Last->LastSec);
// _etext is the first location after the last read-only loadable segment.
- if (LastRO) {
- if (ElfSym::Etext1)
- ElfSym::Etext1->Section = LastRO->LastSec;
- if (ElfSym::Etext2)
- ElfSym::Etext2->Section = LastRO->LastSec;
- }
+ if (LastRO)
+ SetSection({ElfSym::Etext1, ElfSym::Etext2}, LastRO->LastSec);
// _edata points to the end of the last non SHT_NOBITS section.
if (LastRW) {
@@ -934,10 +932,8 @@
if (OutputSections[I]->Type == SHT_NOBITS)
break;
- if (ElfSym::Edata1)
- ElfSym::Edata1->Section = OutputSections[I - 1];
- if (ElfSym::Edata2)
- ElfSym::Edata2->Section = OutputSections[I - 1];
+ if (I > 0)
+ SetSection({ElfSym::Edata1, ElfSym::Edata2}, OutputSections[I - 1]);
}
if (ElfSym::Bss)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39007.119333.patch
Type: text/x-patch
Size: 1429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171017/c4ba634b/attachment.bin>
More information about the llvm-commits
mailing list