Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jiawei <jiawei@iscas.ac.cn>
To: Charlie Jenkins <charlie@rivosinc.com>,
	Nelson Chu <nelson@rivosinc.com>,
	 Jan Beulich <jbeulich@suse.com>,
	Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches <gdb-patches@sourceware.org>,
	Binutils <binutils@sourceware.org>
Subject: Re: [PATCH 1/2] RISC-V: Fix abort when displaying .dword
Date: Wed, 12 Feb 2025 13:27:07 +0800	[thread overview]
Message-ID: <843e2e5c-917c-4dec-b96c-c1cdc5ebd241@iscas.ac.cn> (raw)
In-Reply-To: <20250211-fix_gas_abort-v1-1-afd9730f9c51@rivosinc.com>


在 2025/2/12 13:08, Charlie Jenkins 写道:
> In the normal case an instruction won't be split into 5, 6, or 7 byte
> sections. However a .dword disassembled with -D can cause an instruction
> to split across the 6 byte boundary. 6 byte instructions were not
> supported so riscv_disassemble_data() would abort.
>
> Forcing instructions to be at most 4 bytes causes other unintented
> side-effects, so instead add entries to the switch statement to handle
> instructions that are 5, 6, or 7 bytes.
>
> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> Fixes: 6a04e8230707 ("RISC-V: Fix display of partial instructions")
> ---
>   opcodes/riscv-dis.c | 29 ++++++++++++++++++++++++++++-
>   1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
> index 367004d3341e46a5f72253cd70c7c2941912e84d..21bcbd32c7f226d13f1637ad192d8fe3c52e0d7a 100644
> --- a/opcodes/riscv-dis.c
> +++ b/opcodes/riscv-dis.c
> @@ -1325,6 +1325,33 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED,
>   	(info->stream, dis_style_immediate, "0x%08lx",
>   	 (unsigned long) data);
>         break;
> +    case 5:
> +      info->bytes_per_line = 8;
> +      (*info->fprintf_styled_func)
> +	(info->stream, dis_style_assembler_directive, ".dword");
> +      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
> +      (*info->fprintf_styled_func)
> +	(info->stream, dis_style_immediate, "0x%010lx",
> +	 (unsigned long) data);
> +      break;
> +    case 6:
> +      info->bytes_per_line = 8;
> +      (*info->fprintf_styled_func)
> +	(info->stream, dis_style_assembler_directive, ".dword");
> +      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
> +      (*info->fprintf_styled_func)
> +	(info->stream, dis_style_immediate, "0x%012lx",
> +	 (unsigned long) data);
> +      break;
> +    case 7:
> +      info->bytes_per_line = 8;
> +      (*info->fprintf_styled_func)
> +	(info->stream, dis_style_assembler_directive, ".dword");
> +      (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
> +      (*info->fprintf_styled_func)
> +	(info->stream, dis_style_immediate, "0x%014lx",
> +	 (unsigned long) data);
> +      break;
>       case 8:
>         info->bytes_per_line = 8;
>         (*info->fprintf_styled_func)
> @@ -1332,7 +1359,7 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED,
>         (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t");
>         (*info->fprintf_styled_func)
>   	(info->stream, dis_style_immediate, "0x%016llx",
> -	 (unsigned long long) data);
> +	 (unsigned long) data);
>         break;
>       default:
>         abort ();

LGTM, thanks.

Jiawei


  reply	other threads:[~2025-02-12  5:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12  5:08 [PATCH 0/2] RISC-V: Fix abort when displaying data and add test Charlie Jenkins
2025-02-12  5:08 ` [PATCH 1/2] RISC-V: Fix abort when displaying .dword Charlie Jenkins
2025-02-12  5:27   ` Jiawei [this message]
2025-02-12  7:25   ` Alan Modra
2025-02-12  8:06   ` Jan Beulich
2025-02-12  8:57     ` Nelson Chu
2025-02-12 10:06       ` Jan Beulich
2025-02-12 22:15         ` Maciej W. Rozycki
2025-02-13  0:51           ` Charlie Jenkins
2025-02-13  0:52     ` Charlie Jenkins
2025-02-12  5:08 ` [PATCH 2/2] RISC-V: Add testcase for 6 byte instruction Charlie Jenkins
2025-02-12  5:20 ` [PATCH 0/2] RISC-V: Fix abort when displaying data and add test Nelson Chu

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=843e2e5c-917c-4dec-b96c-c1cdc5ebd241@iscas.ac.cn \
    --to=jiawei@iscas.ac.cn \
    --cc=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=charlie@rivosinc.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=nelson@rivosinc.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