public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] bpf: disasemble offsets of value 0 as "+0"
@ 2023-07-21 17:58 David Faust
  2023-07-21 18:11 ` Jose E. Marchesi
  0 siblings, 1 reply; 4+ messages in thread
From: David Faust @ 2023-07-21 17:58 UTC (permalink / raw)
  To: binutils, jose.marchesi

This tiny patch makes the BPF disassembler to emit, e.g.

  ldxdw %r1, [%r0+0]

instead of

  ldxdw %r1, [%r00]

when the offset is 0, to avoid confusion.

Tested on bpf-unknown-none.
Maybe obvious, but.. OK?

Thanks.

opcodes/

	* bpf-dis.c (print_insn_bpf): Print 16-bit offsets with value 0
	as "+0".
---
 opcodes/bpf-dis.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opcodes/bpf-dis.c b/opcodes/bpf-dis.c
index a4dc3dc2523..bb63119e813 100644
--- a/opcodes/bpf-dis.c
+++ b/opcodes/bpf-dis.c
@@ -231,7 +231,7 @@ print_insn_bpf (bfd_vma pc, disassemble_info *info)
                   if (p[1] == 'o')
                     (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
                                                   "%s",
-                                                  asm_obase != 10 || offset16 > 0 ? "+" : "");
+						  asm_obase != 10 || offset16 >= 0 ? "+" : "");
                   if (asm_obase == 16 || asm_obase == 8)
                     (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
                                                   asm_obase == 8 ? "0%" PRIo16 : "0x%" PRIx16,
-- 
2.40.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-21 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 17:58 [PATCH] bpf: disasemble offsets of value 0 as "+0" David Faust
2023-07-21 18:11 ` Jose E. Marchesi
2023-07-21 18:54   ` [PATCH v2] " David Faust
2023-07-21 19:21     ` Jose E. Marchesi

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).