[PATCH 5/7] opcodes: microblaze: disassemble the word 0
Samuel Price
thesamprice@gmail.com
Mon Nov 9 04:08:09 GMT 2026
objdump stops disassembling a section at the first zero word, such as
the padding ".align 3" leaves after a single instruction.
read_insn_microblaze returns the instruction word, or 0 when the read
fails, so its two callers cannot tell a failed read from the word 0 and
return -1 for both.
The word 0 is "add r0, r0, r0". UG984 makes it illegal only on a core
built with C_OPCODE_0x0_ILLEGAL.
Make read_insn_microblaze return false when the read fails and pass the
word back through a new argument, and test that in both callers. A
failed read still reports the memory error.
opcodes/
* microblaze-dis.c (read_insn_microblaze): Return a bool and
store the instruction through a new INSTP argument.
(print_insn_microblaze): Adjust.
Signed-off-by: Sam Price <thesamprice@gmail.com>
Assisted-by: Claude (Anthropic)
---
opcodes/microblaze-dis.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
index 6e0957c029f..3158ef74fb0 100644
--- a/opcodes/microblaze-dis.c
+++ b/opcodes/microblaze-dis.c
@@ -197,9 +197,13 @@ get_field_special (struct string_buf *buf, long instr,
return p;
}
-static unsigned long
+/* Read the instruction at MEMADDR into *INSTP and find its table entry.
+ Return false if the memory cannot be read. */
+
+static bool
read_insn_microblaze (bfd_vma memaddr,
struct disassemble_info *info,
+ unsigned long *instp,
const struct op_code_struct **opr)
{
unsigned char ibytes[4];
@@ -212,7 +216,7 @@ read_insn_microblaze (bfd_vma memaddr,
if (status != 0)
{
info->memory_error_func (status, memaddr, info);
- return 0;
+ return false;
}
if (info->endian == BFD_ENDIAN_BIG)
@@ -230,7 +234,8 @@ read_insn_microblaze (bfd_vma memaddr,
break;
*opr = op;
- return inst;
+ *instp = inst;
+ return true;
}
@@ -251,16 +256,14 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
buf.which = 0;
info->bytes_per_chunk = 4;
- inst = read_insn_microblaze (memaddr, info, &op);
- if (inst == 0)
+ if (!read_insn_microblaze (memaddr, info, &inst, &op))
return -1;
if (prev_insn_vma == curr_insn_vma)
{
if (memaddr-(info->bytes_per_chunk) == prev_insn_addr)
{
- prev_inst = read_insn_microblaze (prev_insn_addr, info, &pop);
- if (prev_inst == 0)
+ if (!read_insn_microblaze (prev_insn_addr, info, &prev_inst, &pop))
return -1;
if (pop->instr == imm)
{
--
2.39.5 (Apple Git-154)
More information about the Binutils
mailing list