From: Charlie Jenkins <charlie@rivosinc.com>
To: jiawei <jiawei@iscas.ac.cn>, Nelson Chu <nelson@rivosinc.com>,
Charlie Jenkins <charlie@rivosinc.com>,
Jan Beulich <jbeulich@suse.com>,
Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches <gdb-patches@sourceware.org>,
Binutils <binutils@sourceware.org>
Subject: [PATCH 1/2] RISC-V: Fix abort when displaying .dword
Date: Tue, 11 Feb 2025 21:08:30 -0800 [thread overview]
Message-ID: <20250211-fix_gas_abort-v1-1-afd9730f9c51@rivosinc.com> (raw)
In-Reply-To: <20250211-fix_gas_abort-v1-0-afd9730f9c51@rivosinc.com>
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 ();
--
2.43.0
next prev parent reply other threads:[~2025-02-12 5:10 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 ` Charlie Jenkins [this message]
2025-02-12 5:27 ` [PATCH 1/2] RISC-V: Fix abort when displaying .dword Jiawei
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=20250211-fix_gas_abort-v1-1-afd9730f9c51@rivosinc.com \
--to=charlie@rivosinc.com \
--cc=aburgess@redhat.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=jbeulich@suse.com \
--cc=jiawei@iscas.ac.cn \
--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