aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorDavid Faust <david.faust@oracle.com>2023-07-21 11:41:43 -0700
committerDavid Faust <david.faust@oracle.com>2023-07-21 11:49:24 -0700
commite8fc65713d6e050348d443f9be7b61e6f54c6371 (patch)
tree7dbac66d0e23fd659ba5c45ab2b948b8e00d4784 /opcodes
parent8a35f6b30a3eac659240f8ea217d351955d3fb3b (diff)
downloadgdb-e8fc65713d6e050348d443f9be7b61e6f54c6371.zip
gdb-e8fc65713d6e050348d443f9be7b61e6f54c6371.tar.gz
gdb-e8fc65713d6e050348d443f9be7b61e6f54c6371.tar.bz2
bpf: disasemble offsets of value 0 as "+0"
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. opcodes/ * bpf-dis.c (print_insn_bpf): Print offsets with value 0 as "+0". gas/ * testsuite/gas/bpf/mem.s: Add tests with offset 0. * testsuite/gas/bpf/mem-pseudoc.s: Likewise. * testsuite/gas/bpf/mem.d: Update accordingly. * testsuite/gas/bpf/mem-be.d: Likewise. * testsuite/gas/bpf/mem-pseudoc.d: Likewise. * testsuite/gas/bpf/mem-be-pseudoc.d: Likewise.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/bpf-dis.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/opcodes/bpf-dis.c b/opcodes/bpf-dis.c
index a4dc3dc..4fe0efc 100644
--- a/opcodes/bpf-dis.c
+++ b/opcodes/bpf-dis.c
@@ -215,7 +215,7 @@ print_insn_bpf (bfd_vma pc, disassemble_info *info)
if (p[1] == 'I')
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
"%s",
- asm_obase != 10 || imm32 > 0 ? "+" : "");
+ asm_obase != 10 || imm32 >= 0 ? "+" : "");
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
asm_obase == 10 ? "%" PRIi32
: asm_obase == 8 ? "%" PRIo32
@@ -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,