public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Jessica Clarke <jrtc27@jrtc27.com>,
	Evan Green <evan@rivosinc.com>,
	libc-alpha@sourceware.org, slewis@rivosinc.com,
	vineetg@rivosinc.com, palmer@rivosinc.com
Subject: Re: [PATCH v8 3/6] riscv: Add __riscv_hwprobe pointer to ifunc calls
Date: Mon, 16 Oct 2023 21:46:41 -0700	[thread overview]
Message-ID: <20231017044641.pw2ccr6exvhtmhkk@google.com> (raw)
In-Reply-To: <87v8bszs20.fsf@oldenburg.str.redhat.com>

On 2023-09-29, Florian Weimer wrote:
>* Jessica Clarke:
>
>> Being able to write portable IFUNC resolvers across Linux, BSDs and
>> other similar OSes is valuable, and this would preclude that. In FreeBSD
>> there are no issues with calling functions from IFUNC resolvers; we just
>> process all non-IRELATIVE relocations before IRELATIVE ones.
>
>Even across multiple objects?  In glibc, we rely on relocation order by
>the link editor to put IRELATIVE last, so we don't have that particular
>problem for IRELATIVE, but we have it for regular symbol-based
>relocations that happen to refer to IFUNC symbols because the relocation
>order my not reflect the symbol binding order.
>
>Thanks,
>Florian

As a resolution to
https://sourceware.org/bugzilla/show_bug.cgi?id=13302
("IRELATIVE relocation should come last"), GNU ld places IRELATIVE in
.rela.plt (strange, as IRELATIVE is not lazy).

I think relyong on this is too brittle, as IRELATIVE may be in .rela.dyn .  I have just filed
https://sourceware.org/bugzilla/show_bug.cgi?id=30976
("rtld: resolve ifunc relocations after JUMP_SLOT/GLOB_DAT/etc")
based on my examples at https://maskray.me/blog/2021-01-18-gnu-indirect-function#relocation-resolving-order


FreeBSD rtld uses multiple phases and in my analysis

> The approach turns out to be very robust. Many segfault examples on
> glibc work on FreeBSD.

glibc rtld probably does not need to do so much. Just refactoring the loop in elf/dynamic-link.h
so that IRELATIVE, regardless of .rela.dyn or .rela.plt, will work for
my examples.  Then the outcome will look good enough to me.

   for (int ranges_index = 0; ranges_index < 2; ++ranges_index)

  parent reply	other threads:[~2023-10-17  4:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01 23:52 [PATCH v8 0/6] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green
2023-09-01 23:52 ` [PATCH v8 1/6] riscv: Add Linux hwprobe syscall support Evan Green
2023-09-01 23:52 ` [PATCH v8 2/6] riscv: Add hwprobe vdso call support Evan Green
2023-09-01 23:52 ` [PATCH v8 3/6] riscv: Add __riscv_hwprobe pointer to ifunc calls Evan Green
2023-09-29 18:21   ` Jessica Clarke
2023-09-29 19:40     ` Florian Weimer
2023-09-29 19:49       ` Jessica Clarke
2023-10-17  4:46       ` Fangrui Song [this message]
2023-09-01 23:52 ` [PATCH v8 4/6] riscv: Enable multi-arg ifunc resolvers Evan Green
2023-09-01 23:52 ` [PATCH v8 5/6] riscv: Add ifunc helper method to hwprobe.h Evan Green
2023-09-01 23:52 ` [PATCH v8 6/6] riscv: Add and use alignment-ignorant memcpy Evan Green
2023-09-25 10:28 ` [PATCH v8 0/6] RISC-V: ifunced memcpy using new kernel hwprobe interface Palmer Dabbelt
2023-09-26  2:24   ` enh

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=20231017044641.pw2ccr6exvhtmhkk@google.com \
    --to=maskray@google.com \
    --cc=evan@rivosinc.com \
    --cc=fweimer@redhat.com \
    --cc=jrtc27@jrtc27.com \
    --cc=libc-alpha@sourceware.org \
    --cc=palmer@rivosinc.com \
    --cc=slewis@rivosinc.com \
    --cc=vineetg@rivosinc.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.
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).