[PATCH v4 08/10] csu: Move static pie self relocation later [BZ #27072]
H.J. Lu
hjl.tools@gmail.com
Tue Jan 19 14:48:45 GMT 2021
On Tue, Jan 19, 2021 at 6:37 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
>
>
> On 19/01/2021 11:35, Szabolcs Nagy wrote:
> > The 01/19/2021 11:07, Adhemerval Zanella wrote:
> >> On 18/01/2021 13:25, Szabolcs Nagy via Libc-alpha wrote:
> >>> IFUNC resolvers may depend on tunables and cpu feature setup so
> >>> move static pie self relocation after those.
> >>>
> >>> It is hard to guarantee that the ealy startup code does not rely
> >>> on relocations so this is a bit fragile. It would be more robust
> >>> to handle RELATIVE relocs early and only IRELATIVE relocs later,
> >>> but the current relocation processing code cannot do that.
> >>>
> >>> The early startup code before relocation processing includes
> >>>
> >>> _dl_aux_init (auxvec);
> >>> __libc_init_secure ();
> >>> __tunables_init (__environ);
> >>> ARCH_INIT_CPU_FEATURES ();
> >>>
> >>> These are simple enough that RELATIVE relocs can be avoided.
> >>>
> >>> __ehdr_start may require RELATIVE relocation so it was moved
> >>> later, fortunately ehdr and phdr are not used in the early code.
> >>>
> >>> Fixes bug 27072.
> >>
> >> LGTM, thanks.
> >>
> >> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> >
> >
> > sigh, this is an old version of this patch, i made a
> > mistake putting the series together.
> >
> > the problem is that _dl_phdr is used in ARCH_SETUP_TLS
> > (to get the tls program headers) so the __ehdr_start
> > magic should be before that (this only matters if auxv
> > lacks AT_PHDR for some reason, which should not happen
> > normally on linux, so testing won't show the problem)
>
> By normally do you mean it might happen on a specific kernel version
> or is it architecture specific?
I think we can leave __ehdr_start ASIS since it doesn't need RELATIVE
relocation. I verified it by adding -Wl,-z,report-relative-reloc when building
elf/sln on x86.
--
H.J.
More information about the Libc-alpha
mailing list