[lld] r304861 - Move clearOutputSections earlier. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 19:31:19 PDT 2017
Author: rafael
Date: Tue Jun 6 21:31:19 2017
New Revision: 304861
URL: http://llvm.org/viewvc/llvm-project?rev=304861&view=rev
Log:
Move clearOutputSections earlier. NFC.
This now just requires not calling assignOffsets after it.
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=304861&r1=304860&r2=304861&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jun 6 21:31:19 2017
@@ -1115,10 +1115,8 @@ template <class ELFT> void Writer<ELFT>:
static void applySynthetic(const std::vector<SyntheticSection *> &Sections,
std::function<void(SyntheticSection *)> Fn) {
for (SyntheticSection *SS : Sections)
- if (SS && SS->getParent() && !SS->empty()) {
+ if (SS && SS->getParent() && !SS->empty())
Fn(SS);
- SS->getParent()->assignOffsets();
- }
}
// We need to add input synthetic sections early in createSyntheticSections()
@@ -1233,6 +1231,12 @@ template <class ELFT> void Writer<ELFT>:
Out::ProgramHeaders->Size = sizeof(Elf_Phdr) * Phdrs.size();
}
+ // Compute the size of .rela.dyn and .rela.plt early since we need
+ // them to populate .dynamic.
+ for (SyntheticSection *SS : {In<ELFT>::RelaDyn, In<ELFT>::RelaPlt})
+ if (SS->getParent() && !SS->empty())
+ SS->getParent()->assignOffsets();
+
// Dynamic section must be the last one in this list and dynamic
// symbol table section (DynSymTab) must be the first one.
applySynthetic({InX::DynSymTab, InX::Bss, InX::BssRelRo,
@@ -1268,6 +1272,7 @@ template <class ELFT> void Writer<ELFT>:
for (BaseCommand *Base : Script->Opt.Commands)
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
OutputSectionCommands.push_back(Cmd);
+ clearOutputSections();
// Fill other section headers. The dynamic table is finalized
// at the end because some tags like RELSZ depend on result
@@ -1278,8 +1283,6 @@ template <class ELFT> void Writer<ELFT>:
// createThunks may have added local symbols to the static symbol table
applySynthetic({InX::SymTab, InX::ShStrTab, InX::StrTab},
[](SyntheticSection *SS) { SS->postThunkContents(); });
-
- clearOutputSections();
}
template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
More information about the llvm-commits
mailing list