[PATCH v2 5/6] RISC-V: Fix T-Head immediate types on printing

Christoph Müllner christoph.muellner@vrull.eu
Mon Oct 3 11:06:02 GMT 2022


On Mon, Sep 26, 2022 at 2:30 PM Tsukasa OI via Binutils <
binutils@sourceware.org> wrote:

> This commit fixes three minor typing-related issues for
> T-Head immediate values.
>
> 1.  The format string %i is renamed to %d (which is more common).
> 2.  Signed type must be specified when printing with %d.
> 3.  unsigned/signed int it not portable enough for max 32-bit immediates.
>     Instead, we should use unsigned/signed long.
>     The format string is changed accordingly.
>

Tested-by: Christoph Müllner <christoph.muellner@vrull.eu>


>
> opcodes/ChangeLog:
>
>         * riscv-dis.c (print_insn_args): Fix T-Head immediate types on
>         printing.
> ---
>  opcodes/riscv-dis.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
> index 1c75317fad1..df2a6f4e131 100644
> --- a/opcodes/riscv-dis.c
> +++ b/opcodes/riscv-dis.c
> @@ -596,11 +596,11 @@ print_insn_args (const char *oparg, insn_t l,
> bfd_vma pc, disassemble_info *info
>                   oparg--;
>
>                   if (!sign)
> -                   print (info->stream, dis_style_immediate, "%u",
> -                          (unsigned)EXTRACT_U_IMM (n, s, l));
> +                   print (info->stream, dis_style_immediate, "%lu",
> +                          (unsigned long)EXTRACT_U_IMM (n, s, l));
>                   else
> -                   print (info->stream, dis_style_immediate, "%i",
> -                          (unsigned)EXTRACT_S_IMM (n, s, l));
> +                   print (info->stream, dis_style_immediate, "%ld",
> +                          (signed long)EXTRACT_S_IMM (n, s, l));
>                   break;
>                 default:
>                   goto undefined_modifier;
> --
> 2.34.1
>
>


More information about the Binutils mailing list