[PATCH] x32: Use THREAD_SELF for RSEQ_* accessors

Uros Bizjak ubizjak@gmail.com
Fri Aug 22 15:46:25 GMT 2025


On Fri, Aug 22, 2025 at 3:44 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Use THREAD_SELF to get the %fs register to work around the GCC bug:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121613
>
> with the negative offset from the %fs register.
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  sysdeps/x86_64/x32/nptl/rseq-access.h | 110 ++++++++++++--------------
>  1 file changed, 49 insertions(+), 61 deletions(-)
>
> diff --git a/sysdeps/x86_64/x32/nptl/rseq-access.h b/sysdeps/x86_64/x32/nptl/rseq-access.h
> index 8386ebd4bf..0baf4e8ea1 100644
> --- a/sysdeps/x86_64/x32/nptl/rseq-access.h
> +++ b/sysdeps/x86_64/x32/nptl/rseq-access.h
> @@ -16,70 +16,58 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> +/* Read member of the RSEQ area directly.  */
> +#define RSEQ_GETMEM(member) \
> +  ({                                                           \
> +     _Static_assert (sizeof (RSEQ_SELF()->member) == 1         \
> +                    || sizeof (RSEQ_SELF()->member) == 4       \
> +                    || sizeof (RSEQ_SELF()->member) == 8,      \
> +                    "size of rseq data");                      \
> +     void *__self = THREAD_SELF;                               \
> +     asm ("" ::: "memory");                                    \

You can use:

  asm ("" : "+r" (__self));

to keep the value in the register without clobbering all the memory.

Uros.


More information about the Libc-alpha mailing list