[PATCH] [PATCH] riscv: Fix jal immediate encoding for constant offsets
Nelson Chu
nelson@rivosinc.com
Mon Jun 16 15:58:10 GMT 2025
Yeah Jan is correct, it seems things do not change. According to,
https://github.com/riscv-non-isa/riscv-asm-manual/blob/main/src/asm-manual.adoc#function-calls,
the operand of call, and the first operand of jal are symbols, so if you
write jal/call 4, it means the absolute address 4 rather than offset 4.
This has been used and discussed for several years, I would suggest not
changing it even if the spec wants to, otherwise many codes will be faulty
and break compatibles.
Thanks
Nelson
On Mon, Jun 16, 2025 at 11:18 PM Jan Beulich <jbeulich@suse.com> wrote:
> On 16.06.2025 17:03, Mingzhu Yan wrote:
> > This patch corrects an issue in the riscv gas where
> > JMP instructions with constant, non-symbolic PC-relative
> > offsets were incorrectly assembled with a zero immediate.
> >
> > Previously, an instruction like j 4 would incorrectly assemble to
> > 0 0000006f j 0 <.text>
> >
> > But now, it is
> > 0: 0040006f j 4 <.text+0x4>
>
> Which isn't correct, imo. If you want to express the latter, the source
> ought to be "j .+4". Whereas "j 4" means a jump to absolute address 4.
> Unless there's anything in the RISC-V assembler spec that makes it
> different in this regard from any other target I know of.
>
> Jan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20250616/5c0ad27e/attachment.htm>
More information about the Binutils
mailing list