[PATCH] D29983: [LLD][ELF] Calculate sizes of SHF_ALLOC Synthetic Sections early
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 07:16:49 PST 2017
> + applySynthetic<ELFT>(Synthetics,
> + [](SyntheticSection<ELFT> *SS) { SS->finalize(); });
For the names, how about:
* startLayout
* updateAllocSize
* endLayout
A more precise set of names would be atLayoutStart, updateAllocSize and
atLayoutEnd, but not sure if it is actually better.
> }
>
> template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
> Index: ELF/SyntheticSections.h
> ===================================================================
> --- ELF/SyntheticSections.h
> +++ ELF/SyntheticSections.h
> @@ -47,6 +47,12 @@
> virtual ~SyntheticSection() = default;
> virtual void writeTo(uint8_t *Buf) = 0;
> virtual size_t getSize() const = 0;
> + // Finalize is split up into 3 parts to accommodate Thunks, early finalize
> + // should do as much as possible including finalizing the section size
"finalizing" is a bit strong since we have updateAllocSize. It should
compute as good a lower bound as possible.
> + // If the size calculation needs to be updated during Thunk creation
incomplete sentence.
> + virtual void updateAllocSize() {}
> + // Runs after all content has been added, must not alter section
> size
and all addresses are know?
> +template <class ELFT> void DynamicSection<ELFT>::earlyFinalize() {
> if (In<ELFT>::RelaDyn->OutSec->Size > 0) {
> bool IsRela = Config->Rela;
> add({IsRela ? DT_RELA : DT_REL, In<ELFT>::RelaDyn});
> @@ -941,13 +941,17 @@
> add({DT_MIPS_RLD_MAP, In<ELFT>::MipsRldMap});
> }
>
> - this->OutSec->Entsize = this->Entsize;
> - this->OutSec->Link = this->Link;
Why does setting the link has to be delayed too?
> +template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
> + this->OutSec->Link = this->Link = StrTabSec.OutSec->SectionIndex;
> + this->OutSec->Entsize = this->Entsize;
> +
> + if (StrTabSec.isDynamic()) {
> + this->OutSec->Info = this->Info = 1;
This can be set early, no?
Cheers,
Rafael
More information about the llvm-commits
mailing list