From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>
Cc: binutils@sourceware.org
Subject: [RFC PATCH 0/2] gdb, opcodes: Add -M isa disassembler option to RISC-V
Date: Sat, 5 Feb 2022 19:24:09 +0900 [thread overview]
Message-ID: <cover.1644056624.git.research_trasio@irq.a4lg.com> (raw)
*** NOTE ***
PATCH 1 contains non-RISC-V (GDB-related) changes.
This patchset adds support for -M isa=ISA diassembler option to RISC-V.
The background is simple. This patchset enables disassembling non-GC
instructions on binary files (without .riscv.attributes section).
However, this isn't that simple as it requires non-arch changes.
[PATCH 1: gdb, opcodes: Add non-enum disassembler options]
There is a portable mechanism for disassembler options and used on some
architectures:
- ARC
- Arm
- MIPS
- PowerPC
- RISC-V
- S/390
However, it only supports following forms:
- [NAME]
- [NAME]=[ENUM_VALUE]
Valid values for [ENUM_VALUE] must be predefined in
`disasm_option_arg_t.values'. For instance, for -M cpu=[CPU] in ARC
architecture, opcodes/arc-dis.c builds valid CPU model list from
include/elf/arc-cpu.def.
In PATCH 1 of this patchset, it adds following format:
- [NAME]=[ARBITRARY_VALUE] (however cannot contain ",")
This is identified by `NULL' value of `disasm_option_arg_t.values'
(normally, this is a non-NULL pointer to a NULL-terminated list).
Note that this patch modifies following architectures (that use
similar code to print disassembler help message) for consistency:
- ARC
- MIPS
- RISC-V
In the future, adding "verify" function to disasm_option_arg_t (or some)
might be an option as it may provide flexible argument validation.
[PATCH 2: RISC-V: Add -M isa disassembler option]
-M isa=ISA is very simple. But we have multiple ways to set proper
XLEN for given situation.
In this patch, I propose following precedence rules (objdump/gdb):
1. XLEN-specified arch (-m riscv:rv[32|64] / set arch riscv:rv[32|64])
2. ISA option (-M isa=rv[32|64]... / set disassembler-options isa=...)
3. ELF class in the "ELF header" (note that this must be the last
because dummy "ELF header" exists even in binary files)
This enables XLEN switching by ISA option on architecture riscv but not
on riscv:rv32 or riscv:rv64 (architecture with fixed XLEN is preferred).
I preferred not to warn if XLEN in above three conflict because of
"dummy ELF header" described above and possible dynamic capability when
used together with GDB. Still, adding it might be an option.
Tsukasa OI (2):
gdb, opcodes: Add non-enum disassembler options
RISC-V: Add -M isa disassembler option
gdb/disasm.c | 4 ++++
include/dis-asm.h | 3 ++-
opcodes/arc-dis.c | 2 ++
opcodes/mips-dis.c | 2 ++
opcodes/riscv-dis.c | 34 +++++++++++++++++++++++++++-------
5 files changed, 37 insertions(+), 8 deletions(-)
base-commit: eb06e60a982e3903161252edf8fb8ae0c018c467
--
2.32.0
next reply other threads:[~2022-02-05 10:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-05 10:24 Tsukasa OI [this message]
2022-02-05 10:24 ` [RFC PATCH 1/2] gdb, opcodes: Add non-enum disassembler options Tsukasa OI
2022-02-05 10:24 ` [RFC PATCH 2/2] RISC-V: Add -M isa disassembler option Tsukasa OI
2022-02-24 18:00 ` Palmer Dabbelt
2022-02-06 2:10 ` [RFC PATCH v2 0/2] gdb, opcodes: Add isa disassembler option to RISC-V Tsukasa OI
2022-02-06 2:10 ` [RFC PATCH v2 1/2] gdb, opcodes: Add non-enum disassembler options Tsukasa OI
2022-02-06 2:10 ` [RFC PATCH v2 2/2] RISC-V: Add isa disassembler option Tsukasa OI
2022-02-07 6:47 ` [RFC PATCH v2 0/2] gdb, opcodes: Add isa disassembler option to RISC-V Nelson Chu
2022-02-07 9:58 ` Tsukasa OI
2022-02-07 10:06 ` Kito Cheng
2022-02-07 10:19 ` Tsukasa OI
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=cover.1644056624.git.research_trasio@irq.a4lg.com \
--to=research_trasio@irq.a4lg.com \
--cc=binutils@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).