mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Maxim Blinov <maxim.a.blinov@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] IFUNC support
Date: Thu, 9 May 2024 08:35:16 -0400	[thread overview]
Message-ID: <20240509123516.GQ10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAHXVFWk+iqRet+66RsBdgV9KRBkcX6FFcKx=1e3GwMnkVoDhXg@mail.gmail.com>

On Thu, May 09, 2024 at 12:04:28PM +0100, Maxim Blinov wrote:
> Hi all,
> 
> I just wanted to clarify the current status on IFUNCs, specifically
> when generated by the compiler when using the `target_clones` c
> function attribute.
> 
> Am I correct that this is not currently supported by musl? If so,
> would musl ever support this feature, or is it rejected as a matter of
> principle? And lastly, if it is possible, what would it take to
> support this feature?
> 
> I googled around for some previous discussions on the subject and
> found https://www.openwall.com/lists/musl/2022/08/23/7, and also
> https://www.openwall.com/lists/musl/2014/11/11/2, which reports IFUNCs
> as "One feature musl intentionally does not yet support", but I
> suppose I wanted to ask again since this was from 2014 and perhaps
> something has changed since then.

If anything, exclusion of IFUNC is more definite now than in 2014.
They keep showing up as vectors for things to break or even for
disguising backdoors, and none of the prior reasons for excluding it
are really resolvable, nor does it have any performance value over
doing things portably with function pointers.

> I originally stumbled on this issue by observing that the musl dynamic
> linker, for x86_64, currently errors out on IFUNC symbols with
> 
> ```
> unknown relocation 37
> ```
> 
> And on RISC-V it throws up with
> 
> ```
> unsupported relocation type 58
> ```
> 
> which corresponds with the R_RISCV_IRELATIVE relocation.

It sounds like you have an XY problem: wanting target_clones to work.
If GCC was built correctly targeting musl, it should not support ifunc
generation at all; you shouldn't end up with unknown relocations in an
output binary because the compiler should never have emitted them. I'm
not sure, but I think GCC has mechanisms to make this functionality
work in the absence of ifunc. If not, maybe it could be enhanced to do
so.

Rich

  reply	other threads:[~2024-05-09 12:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 11:04 Maxim Blinov
2024-05-09 12:35 ` Rich Felker [this message]
2024-05-09 13:16   ` Maxim Blinov
2024-05-09 13:51     ` Rich Felker

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509123516.GQ10433@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=maxim.a.blinov@gmail.com \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).