From: Kito Cheng <kito.cheng@gmail.com>
To: Yangyu Chen <cyy@cyyself.name>
Cc: Florian Weimer <fweimer@redhat.com>,
Kito Cheng <kito.cheng@sifive.com>,
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: Thu, 31 Oct 2024 18:07:17 +0800 [thread overview]
Message-ID: <CA+yXCZCN4z7Ta-9uRjLpSQqQ2006kYXBFKNSExQJP88D+Jwyjg@mail.gmail.com> (raw)
In-Reply-To: <tencent_51A6054DB4171CAB702563B643101AC3F909@qq.com>
On Thu, Oct 31, 2024 at 2:29 AM Yangyu Chen <cyy@cyyself.name> wrote:
>
>
>
> > On Oct 30, 2024, at 19:09, Florian Weimer <fweimer@redhat.com> wrote:
> >
> > * Kito Cheng:
> >
> >> Hi Florian:
> >>
> >> Thanks for your explanation! one more question around the
> >> HIDDEN_VAR_NEEDS_DYNAMIC_RELOC,
> >> RISC-V don't set that to 1 but seems to work well so far...?
> >> Is it because the GP register is limited to executable so that we are
> >> safe without that?
> >
> > Yes, exactly. The dynamic linker doesn't use the GP register for its
> > own purposes, and it doesn't impact code generation for the dynamic
> > linker itself.
> >
> > However, the way GP setup is currently handled is highly problematic
> > because the ABI does not give us a proper way to set it up correctly.
> > The use of a dynamic symbol is too fragile and seems to have been added
> > as an afterthought. This should be a dynamic tag in the main
> > executable. If we had that, we could set GP in all relevant calls to
> > application code (of course this assumes that applications do not use GP
> > as a global register variable for a different purpose, but hopefully
> > that's not the case).
> >
> > Thanks,
> > Florian
>
> Thanks for clarifying that!
>
> I proposed an idea to bypass the GP initialization by restricting
> the use of the norelax attribute for all callees of IFUNC. In this
> case, the linker will retain auipc + load/store instructions to
> access global variables based on pc-relative address mode instead
> of relaxing them to a single load/store at a +- 2KB offset from the
> GP.
>
> I'm not sure if this solution is the right way to go. Are there any
> potential edge cases that I might have missed?
That seems the right way to me :)
>
> Thanks,
> Yangyu Chen
>
next prev parent reply other threads:[~2024-10-31 10:07 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
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 [this message]
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=CA+yXCZCN4z7Ta-9uRjLpSQqQ2006kYXBFKNSExQJP88D+Jwyjg@mail.gmail.com \
--to=kito.cheng@gmail.com \
--cc=cyy@cyyself.name \
--cc=fweimer@redhat.com \
--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).