From: Alan Modra via Libc-alpha <libc-alpha@sourceware.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: Fangrui Song <i@maskray.me>,
libc-alpha@sourceware.org, binutils@sourceware.org
Subject: Re: ifunc resolving
Date: Wed, 20 Jan 2021 09:01:53 +1030 [thread overview]
Message-ID: <20210119223153.GZ26219@bubble.grove.modra.org> (raw)
In-Reply-To: <87sg6xezv9.fsf@oldenburg.str.redhat.com>
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.
> * 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.
> 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.
> We have removed several IFUNC resolvers with IFUNC dependencies from
> glibc itself because we could not follow the interposition/dependency
> rules for the second approach.
Right, I'm inclined to say ifunc has a fatal design flaw without
deferred relocation processing. If it's too hard for glibc itself,
it's too hard for anyone to use anywhere.
> Due to the x86-specific checks we have, those architectures currently
> land in the second category. I do not know if other architecture
> maintainers agree.
>
> 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
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2021-01-19 22:32 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 [this message]
2021-01-20 9:33 ` Florian Weimer via Libc-alpha
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=20210119223153.GZ26219@bubble.grove.modra.org \
--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).