public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: David Faust <david.faust@oracle.com>
To: binutils@sourceware.org, jose.marchesi@oracle.com
Subject: [PATCH] bpf: disasemble offsets of value 0 as "+0"
Date: Fri, 21 Jul 2023 10:58:55 -0700	[thread overview]
Message-ID: <20230721175855.6460-1-david.faust@oracle.com> (raw)

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


             reply	other threads:[~2023-07-21 17:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 17:58 David Faust [this message]
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

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=20230721175855.6460-1-david.faust@oracle.com \
    --to=david.faust@oracle.com \
    --cc=binutils@sourceware.org \
    --cc=jose.marchesi@oracle.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).