[lld] r256448 - Simplify. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 26 02:34:35 PST 2015
Author: ruiu
Date: Sat Dec 26 04:34:33 2015
New Revision: 256448
URL: http://llvm.org/viewvc/llvm-project?rev=256448&view=rev
Log:
Simplify. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=256448&r1=256447&r2=256448&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Dec 26 04:34:33 2015
@@ -850,23 +850,25 @@ template <class ELFT> void Writer<ELFT>:
// This function add Out<ELFT>::* sections to OutputSections.
template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
+ auto Add = [&](OutputSectionBase<ELFT> *C) {
+ if (C)
+ OutputSections.push_back(C);
+ };
+
// This order is not the same as the final output order
// because we sort the sections using their attributes below.
- if (Out<ELFT>::SymTab)
- OutputSections.push_back(Out<ELFT>::SymTab);
- OutputSections.push_back(Out<ELFT>::ShStrTab);
- if (Out<ELFT>::StrTab)
- OutputSections.push_back(Out<ELFT>::StrTab);
+ Add(Out<ELFT>::SymTab);
+ Add(Out<ELFT>::ShStrTab);
+ Add(Out<ELFT>::StrTab);
if (isOutputDynamic()) {
- OutputSections.push_back(Out<ELFT>::DynSymTab);
- if (Out<ELFT>::GnuHashTab)
- OutputSections.push_back(Out<ELFT>::GnuHashTab);
- if (Out<ELFT>::HashTab)
- OutputSections.push_back(Out<ELFT>::HashTab);
- OutputSections.push_back(Out<ELFT>::Dynamic);
- OutputSections.push_back(Out<ELFT>::DynStrTab);
+ Add(Out<ELFT>::DynSymTab);
+ Add(Out<ELFT>::GnuHashTab);
+ Add(Out<ELFT>::HashTab);
+ Add(Out<ELFT>::Dynamic);
+ Add(Out<ELFT>::DynStrTab);
if (Out<ELFT>::RelaDyn->hasRelocs())
- OutputSections.push_back(Out<ELFT>::RelaDyn);
+ Add(Out<ELFT>::RelaDyn);
+
// This is a MIPS specific section to hold a space within the data segment
// of executable file which is pointed to by the DT_MIPS_RLD_MAP entry.
// See "Dynamic section" in Chapter 5 in the following document:
@@ -877,14 +879,14 @@ template <class ELFT> void Writer<ELFT>:
Out<ELFT>::MipsRldMap->setSize(ELFT::Is64Bits ? 8 : 4);
Out<ELFT>::MipsRldMap->updateAlign(ELFT::Is64Bits ? 8 : 4);
OwningSections.emplace_back(Out<ELFT>::MipsRldMap);
- OutputSections.push_back(Out<ELFT>::MipsRldMap);
+ Add(Out<ELFT>::MipsRldMap);
}
}
// We always need to add rel[a].plt to output if it has entries.
// Even during static linking it can contain R_[*]_IRELATIVE relocations.
if (Out<ELFT>::RelaPlt && Out<ELFT>::RelaPlt->hasRelocs()) {
- OutputSections.push_back(Out<ELFT>::RelaPlt);
+ Add(Out<ELFT>::RelaPlt);
Out<ELFT>::RelaPlt->Static = !isOutputDynamic();
}
@@ -899,11 +901,11 @@ template <class ELFT> void Writer<ELFT>:
needsGot = true;
if (needsGot)
- OutputSections.push_back(Out<ELFT>::Got);
+ Add(Out<ELFT>::Got);
if (Out<ELFT>::GotPlt && !Out<ELFT>::GotPlt->empty())
- OutputSections.push_back(Out<ELFT>::GotPlt);
+ Add(Out<ELFT>::GotPlt);
if (!Out<ELFT>::Plt->empty())
- OutputSections.push_back(Out<ELFT>::Plt);
+ Add(Out<ELFT>::Plt);
}
// The linker is expected to define SECNAME_start and SECNAME_end
More information about the llvm-commits
mailing list