[PATCH] ELF: Move readonly_dynrelocs_against_ifunc to elf_link_hash_table

Fangrui Song i@maskray.me
Mon Jun 8 05:00:15 GMT 2020


On Sun, Jun 7, 2020 at 7:10 PM H.J. Lu via Binutils
<binutils@sourceware.org> wrote:
>
> On Sun, Jun 7, 2020 at 6:25 PM Alan Modra <amodra@gmail.com> wrote:
> >
> > On Sat, Jun 06, 2020 at 07:33:48AM -0700, H.J. Lu via Binutils wrote:
> > > All IFUNC targets can use readonly_dynrelocs_against_ifunc to warn
> > > dynamic IFUNC relocations in read-only segment.
> > >
> > > I'd like to check it into master if there are no objections.
> >
> > Do you actually need one of the dynamic ifunc relocations itself to be
> > in a read-only section for this problem to occur?  I don't think so.
> >
> > The problem with IFUNC and TEXTREL occurs when the ifunc resolver
> > function is in a segment that needs to be made writable to apply
> > relocations.  Making a memory region writable typically makes it
> > non-executable (but that might depend on architecture), resulting
> > in segfaults when attempting to run the ifunc resolver to apply
> > dynamic ifunc relocations.  That has nothing to do with where the
> > ifunc dynamic relocation itself occurs.
>
> If there are no IFUNC dynamic relocations in the text segment,
> which may also contain IFUNC resolvers,  we don't need to call
> the IFUNC resolver in the writable text segment.   It is OK to
> have IFUNC relocations with DT_TEXTREL as long as these
> relocations aren't applied to the text segment, which means
> where the IFUNC relocations are matters.
>
> --
> H.J.

We need some examples to understand how this patch works. For IFUNC +
DF_TEXTREL on glibc,
it works since https://sourceware.org/git/?p=glibc.git;a=commit;h=b5c45e83753b27dc538dff2d55d4410c385cf3a4


More information about the Binutils mailing list