diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-07 23:08:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-07 23:08:55 +0000 |
commit | 7204620d32bc514fc59d3d05abadb13ee0ab817b (patch) | |
tree | e4c280201b29dd85fd6c7b40eb4b98d0b6292622 | |
parent | 27c11dd57ebb99d33491906d5ff7c68539bf4803 (diff) | |
download | bcm5719-llvm-7204620d32bc514fc59d3d05abadb13ee0ab817b.tar.gz bcm5719-llvm-7204620d32bc514fc59d3d05abadb13ee0ab817b.zip |
Use OutputSectionCommands in assignOffsets.
This allows moving clearOutputSections earlier.
llvm-svn: 304952
-rw-r--r-- | lld/ELF/OutputSections.cpp | 7 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 12 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index b655dbd7eef..47042b6eb66 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -101,9 +101,12 @@ void OutputSection::addSection(InputSection *S) { // This function is called after we sort input sections // and scan relocations to setup sections' offsets. void OutputSection::assignOffsets() { + OutputSectionCommand *Cmd = Script->getCmd(this); uint64_t Off = 0; - for (InputSection *S : Sections) - Off = updateOffset(Off, S); + for (BaseCommand *Base : Cmd->Commands) + if (auto *ISD = dyn_cast<InputSectionDescription>(Base)) + for (InputSection *S : ISD->Sections) + Off = updateOffset(Off, S); this->Size = Off; } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 72b6457a889..a8ab1437e4e 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1216,12 +1216,6 @@ 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(); - if (!Script->Opt.HasSections) Script->fabricateDefaultCommands(); for (BaseCommand *Base : Script->Opt.Commands) @@ -1229,6 +1223,12 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() { OutputSectionCommands.push_back(Cmd); clearOutputSections(); + // 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, |