[PATCH] objdump: z80: show symbol names for addresses in disassembly
Zeal8bit
contact@zeal8bit.com
Wed Mar 25 10:12:01 GMT 2026
Hello,
While using objdump to disassemble Z80 ELF binaries, the output shows
addresses for relative (`prt_e`), absolute (`prt_nn`) jumps/calls and
memory load, but no symbol, even if symbol information is available.
For example, objdump would output:
00000000 <software_reset>:
0: f3 di
1: c3 31 01 jp 0x0131
instead of:
00000000 <software_reset>:
0: f3 di
1: c3 31 01 jp 0x0131 <os_entry>
With this patch, the disassembly output will now include any existing
symbol corresponding to the addresses as shown above.
---
opcodes/z80-dis.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/opcodes/z80-dis.c b/opcodes/z80-dis.c
index d5b4c421..d074cadd 100644
--- a/opcodes/z80-dis.c
+++ b/opcodes/z80-dis.c
@@ -117,6 +117,12 @@ prt_e (struct buffer *buf, disassemble_info * info, const char *txt)
int target_addr = (buf->base + 2 + e) & 0xffff;
buf->n_used = buf->n_fetch;
info->fprintf_func (info->stream, "%s0x%04x", txt, target_addr);
+ if (info->symbol_at_address_func)
+ {
+ asymbol *s = info->symbol_at_address_func (target_addr, info);
+ if (s && s->name)
+ info->fprintf_func (info->stream, " <%s>", s->name);
+ }
}
else
buf->n_used = -1;
@@ -139,6 +145,7 @@ prt_nn (struct buffer *buf, disassemble_info * info, const char *txt)
int nn;
unsigned char *p;
int i;
+ asymbol *s;
p = (unsigned char*) buf->data + buf->n_fetch;
if (fetch_data (buf, info, buf->nn_len))
@@ -148,6 +155,12 @@ prt_nn (struct buffer *buf, disassemble_info * info, const char *txt)
while (i--)
nn = nn * 0x100 + p[i];
info->fprintf_func (info->stream, txt, nn);
+ if (info->symbol_at_address_func)
+ {
+ s = info->symbol_at_address_func (nn, info);
+ if (s && s->name)
+ info->fprintf_func (info->stream, " <%s>", s->name);
+ }
buf->n_used = buf->n_fetch;
}
else
--
2.43.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20260325/438d96ce/attachment-0001.htm>
More information about the Binutils
mailing list