Re: [PATCH -tip] x86/asm: Use %a instead of %c(%%rip) in rip_rel_ptr()

From: Uros Bizjak
Date: Mon May 05 2025 - 02:15:42 EST


On Mon, May 5, 2025 at 7:48 AM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:
>
> On Mon, 5 May 2025 at 04:59, H. Peter Anvin <hpa@xxxxxxxxx> wrote:
> >
> > On 5/4/25 11:43, Uros Bizjak wrote:
> > > The "a" asm operand modifier substitutes a memory reference, with the
> > > actual operand treated as address. For x86_64, when a symbol is
> > > provided, the "a" modifier emits "sym(%rip)" instead of "sym".
> > >
>
> Clang does not
>
> https://godbolt.org/z/5Y58T45f5
>
> > > No functional changes intended.
> > >
>
> NAK. There is a functional change with Clang, which does not emit
> %(rip), and this is the whole point of this thing.

Hm... I tested clang with "int foo" and only -O2, where it produced
the desired assembly. GCC works in all cases.

Let's keep the function as is then.

Thanks,
Uros.