[lld] r304952 - Use OutputSectionCommands in assignOffsets.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 7 16:08:55 PDT 2017
Author: rafael
Date: Wed Jun 7 18:08:55 2017
New Revision: 304952
URL: http://llvm.org/viewvc/llvm-project?rev=304952&view=rev
Log:
Use OutputSectionCommands in assignOffsets.
This allows moving clearOutputSections earlier.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=304952&r1=304951&r2=304952&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Jun 7 18:08:55 2017
@@ -101,9 +101,12 @@ void OutputSection::addSection(InputSect
// 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;
}
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=304952&r1=304951&r2=304952&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Jun 7 18:08:55 2017
@@ -1216,12 +1216,6 @@ 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();
-
if (!Script->Opt.HasSections)
Script->fabricateDefaultCommands();
for (BaseCommand *Base : Script->Opt.Commands)
@@ -1229,6 +1223,12 @@ template <class ELFT> void Writer<ELFT>:
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,
More information about the llvm-commits
mailing list