From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: Alan Modra via Libc-alpha <libc-alpha@sourceware.org>
Cc: Fangrui Song <i@maskray.me>,
binutils@sourceware.org, Alan Modra <amodra@gmail.com>
Subject: Re: ifunc resolving
Date: Wed, 20 Jan 2021 10:33:40 +0100 [thread overview]
Message-ID: <87lfco6jgr.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210119223153.GZ26219@bubble.grove.modra.org> (Alan Modra via Libc-alpha's message of "Wed, 20 Jan 2021 09:01:53 +1030")
* Alan Modra via Libc-alpha:
> On Tue, Jan 19, 2021 at 03:59:54PM +0100, Florian Weimer via Binutils wrote:
>> We have two positions that still need to be reconciled:
>>
>> * IFUNC resolvers must not themselves have relocation dependencies
>> because they can be called at any time during relocation. This
>> restricts the functionality available to an IFUNC resolver.
>
> On many architectures this cannot be achieved without hand-crafted
> assembly. The reason is obvious. Ifunc resolvers return an address.
> Compilers load addresses from the GOT, particularly for PIC. GOT
> entries need relocation.
Yes, this works best for what glibc considers PI_STATIC_AND_HIDDEN
architectures.
>
>> * IFUNC resolvers may have relocation dependencies, but they may only be
>> called after the object that contains them has been relocated. This
>> restricts how IFUNC symbols can be used (interposition is limited,
>> correct dependency ordering via DT_NEEDED is required).
>
> No interposition in practice, because the object doing the interposing
> is almost always relocated later.
Right, and that was hard for glibc.
>> I do not think we have ever achieved consensus which position is the
>> correct one.
>
> There is a third possibility. If ld.so defers all irelative and other
> relocations using ifunc symbols until all non-ifunc relocations have
> been performed, globally, then ifunc resolvers would only have the
> restriction that they not call other ifuncs.
>
> That idea was floated a very long time ago. For some reason it is
> too hard or too slow to do in ld.so.
It's not too hard, I wrote a patch. I didn't mention it because it was
rejected. It seemed about the only thing for which we had consensus. 8-/
My patch did not find an appropriate order in all cases. I think that's
more or less unavoidable if IFUNC resolvers depend on relocations
against other IFUNC resolvers. It would have nicely covered all
internal glibc uses at the time.
> If it's too hard for glibc itself, it's too hard for anyone to use
> anywhere.
Agreed, it's difficult to argue against that.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
next prev parent reply other threads:[~2021-01-20 9:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 22:04 ifunc resolving Fangrui Song
2021-01-18 22:53 ` H.J. Lu via Libc-alpha
2021-01-19 14:59 ` Florian Weimer via Libc-alpha
2021-01-19 22:31 ` Alan Modra via Libc-alpha
2021-01-20 9:33 ` Florian Weimer via Libc-alpha [this message]
2021-01-20 16:13 ` Zack Weinberg
2021-01-20 16:17 ` Florian Weimer via Libc-alpha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfco6jgr.fsf@oldenburg.str.redhat.com \
--to=libc-alpha@sourceware.org \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=fweimer@redhat.com \
--cc=i@maskray.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).