[PATCH] D16991: Split the creation of program headers in a few steps

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 11:57:33 PST 2016


> Honestly, I dont like the approach to have dummies like that. Thats looks like a hack (more like a hack in compare with 'special' first load).
> Linkerscript allows to put elf header and phdr anywhere afaik. But the question is do we really need to support that ?
> In my patch about PHDRS (http://reviews.llvm.org/D16771) I introduced the restriction about that:
> first phdr is always PT_PHDR and first load must contain elf and phdr headers. It seems your implementation is really close or the same to mine here (at least it assumes them are at start always), but do we really need to have dummies logic then ?
> IMO special first load and less entities looks better here.

I remember seeing that used in a case where it was desired that the
elf and program headers were not part of a PT_LOAD (NaCl). It is
unclear if it needs to be supported, but if it is an "Inventor's
paradox" situation, why not support the more general case?

The problem with having PT_LOAD that is before any section is that we
need special cases in two places:

* The first section in it doesn't need to be page aligned, since it is
not the start of the pt_load.
* Computing its actual position.

Not having a section for the program headers also means PT_PHDR is a
special case. Implementing this patch is how I found the bug I fixed
in r260102.


>
> ================
> Comment at: ELF/Writer.cpp:186
> @@ -162,2 +185,3 @@
> +  Out<ELFT>::ProgramHeaders = &ProgramHeaders;
>
>    Writer<ELFT>(*Symtab).run();
> ----------------
> Let's place them before all other sections as they are usually always go before all other ones ?

Not sure I follow. They are already at the start.

I will upload a rebased/fixed patch.

Cheers,
Rafael


More information about the llvm-commits mailing list