From: Florian Weimer <fweimer@redhat.com>
To: Kito Cheng <kito.cheng@sifive.com>
Cc: Yangyu Chen <cyy@cyyself.name>,
Palmer Dabbelt <palmer@rivosinc.com>,
libc-alpha@sourceware.org, vincent.chen@sifive.com,
schwab@suse.de
Subject: Re: [PATCH v2] RISC-V: Fix IFUNC resolver cannot access gp pointer
Date: Wed, 30 Oct 2024 11:42:04 +0100 [thread overview]
Message-ID: <87a5elg9dv.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CALLt3Tj06ytycyu2Xwf=02MUwrPLbK3-3i+XvA+djNtC2=9eQQ@mail.gmail.com> (Kito Cheng's message of "Wed, 30 Oct 2024 18:26:56 +0800")
* Kito Cheng:
> HI Florian:
>
> On Wed, Oct 30, 2024 at 5:22 PM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * Kito Cheng:
>>
>> > Do you remember if there are any other issues that need to be resolved
>> > other than the GP issue?
>>
>> In certain cases, IFUNC resolvers can be invoked when the object that
>> provides has not been relocated yet. That's impossible to address
>> from within the IFUNC resolver. (For the GP issue, the IFUNC resolver
>> could just assume that GP isn't defined, I think.)
>
> Hmmmm, I am a little surprised that since we are kinda learning the
> function multi-version (FMV) from AArch64[1] and x86[2], they both
> will reference global variables during the FMV IFUNC resolver, or is
> it just bad design from your point of view?
The default code model for AArch64 and x86-64 uses more or less direct
PC-relative addressing for local data references. For this reason, that
data is in libgcc.a, with hidden visibility. On x86-64, there is a
large code model that requires a register like GP, but every function is
required to set it up if it needs it (including PLT stubs, and %r11 is
reserved for that purposes).
The use of the GP register makes RISC-V a HIDDEN_VAR_NEEDS_DYNAMIC_RELOC
target in glibc's terms, and those can't use any data references in
IFUNC resolvers (unless you ban cyclic references, LD_PRELOAD etc.).
Thanks,
Florian
next prev parent reply other threads:[~2024-10-30 10:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 17:01 Yangyu Chen
2024-10-30 2:58 ` Yangyu Chen
2024-10-30 3:10 ` Palmer Dabbelt
2024-10-30 6:50 ` Yangyu Chen
2024-10-30 7:36 ` Kito Cheng
2024-10-30 9:22 ` Florian Weimer
2024-10-30 10:26 ` Kito Cheng
2024-10-30 10:42 ` Florian Weimer [this message]
2024-10-30 10:48 ` Kito Cheng
2024-10-30 11:09 ` Florian Weimer
2024-10-30 18:28 ` Yangyu Chen
2024-10-31 10:07 ` Kito Cheng
2024-10-31 10:32 ` Florian Weimer
2024-10-31 10:35 ` Yangyu Chen
2024-10-31 10:51 ` Florian Weimer
2024-11-13 10:29 ` Yangyu Chen
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=87a5elg9dv.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=cyy@cyyself.name \
--cc=kito.cheng@sifive.com \
--cc=libc-alpha@sourceware.org \
--cc=palmer@rivosinc.com \
--cc=schwab@suse.de \
--cc=vincent.chen@sifive.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).