unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: Jessica Clarke <jrtc27@jrtc27.com>
Cc: libc-alpha@sourceware.org, kito.cheng@sifive.com,
	Andrew Waterman <andrew@sifive.com>
Subject: Re: [PATCH] riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC.
Date: Thu, 02 Dec 2021 22:44:20 +0100	[thread overview]
Message-ID: <87r1auznpn.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <60359D93-BA59-486D-BCD5-8EB582700FA9@jrtc27.com> (Jessica Clarke's message of "Thu, 2 Dec 2021 21:06:33 +0000")

* Jessica Clarke:

> The intent of the spec is not to make repurposing just ra/sp/gp/tp as
> anything other than their ABI-defined meanings (per table 1 of riscv-cc
> and, in the case of the stack pointer, the alignment required by the
> integer calling convention) legal unless you use STO_RISCV_VARIANT_CC,
> so the glibc requirement, which is also true of FreeBSD for exactly the
> same reasons, is intended to be what is specified. Upon re-reading what
> was written I can see that requirement was lost or forgotten, so I’ll
> look at tightening it up, probably changing
>
>   Any functions that use additional argument registers ...
>
> to
>
>   Any functions that use registers in a way that is incompatible with
>   the register convention of the ABI in use ...
>
> I also note we currently only talk about the run-time linker preserving
> argument registers, and say nothing about preserved registers, nor the
> return address. I’m not sure quite why we do the former (maybe I’ve
> just forgotten a past conversation), I feel like that’s implied by lazy
> binding being an implementation optimisation that must not break the
> calling convention, but if we want to keep that language then it should
> probably be changed to:
>
>   Run-time linkers that use lazy binding must only clobber registers
>   defined as temporary registers for the ABI in use.
>
> Does that all sound sensible, and sufficient, to you?

One further aspect is that glibc has dynamic linker plugins called
auditors, and arbitrary code can run *after* a function has returned.
For that to work, we need save registers used for return values as well.
(The default dynamic linker trampoline sidesteps this because it makes a
tail call to the actual implementation, based on what the core symbol
binding routine in the dynamic linker has returned.)  This is a fairly
obscure feature, and I don't think anyone has a really good solution for
their architecture today.  There might also be better alternatives
(e.g., if you know the signature of the function you are intercepting,
you don't need a general solution for arbitrary calling conventions
anymore).

Do temporary registers overlap with return registers?

Thanks,
Florian


  parent reply	other threads:[~2021-12-02 21:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09  3:47 [PATCH] riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC Hsiangkai Wang
2021-08-11 22:11 ` Palmer Dabbelt
2021-08-11 22:51   ` Jessica Clarke
2021-08-11 23:00   ` Jim Wilson
2021-08-11 23:21     ` Palmer Dabbelt
2021-08-11 23:32       ` Jessica Clarke
2021-08-11 23:52         ` Palmer Dabbelt
2021-08-12  0:54           ` Jessica Clarke
2021-10-25 21:08           ` Jim Wilson
2021-12-02 20:21             ` Palmer Dabbelt
2021-12-02 21:06               ` Jessica Clarke
2021-12-02 21:09                 ` Andrew Waterman
2021-12-02 21:44                 ` Florian Weimer via Libc-alpha [this message]
2021-12-02 22:08                   ` Jessica Clarke
2021-10-29  0:20 ` DJ Delorie 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=87r1auznpn.fsf@oldenburg.str.redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=andrew@sifive.com \
    --cc=fweimer@redhat.com \
    --cc=jrtc27@jrtc27.com \
    --cc=kito.cheng@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).