diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-07 02:31:19 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-07 02:31:19 +0000 |
| commit | d57c58d75d22a9c7b5922f5d4f7e57d153d67c6a (patch) | |
| tree | d68b7aab44d1723a53006de39e7fab7d5a1a4d5a | |
| parent | 189860c317aa7e9cec20a8de803f36e0eb860a49 (diff) | |
| download | bcm5719-llvm-d57c58d75d22a9c7b5922f5d4f7e57d153d67c6a.tar.gz bcm5719-llvm-d57c58d75d22a9c7b5922f5d4f7e57d153d67c6a.zip | |
Move clearOutputSections earlier. NFC.
This now just requires not calling assignOffsets after it.
llvm-svn: 304861
| -rw-r--r-- | lld/ELF/Writer.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 444384dc8b4..5ee7e20d7e6 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1115,10 +1115,8 @@ template <class ELFT> void Writer<ELFT>::sortSections() { 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>::finalizeSections() { 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>::finalizeSections() { 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>::finalizeSections() { // 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() { |

