[binutils-gdb] RISC-V: Fix disassemble fetch fail return value.

Nelson Chu nelsonc1225@sourceware.org
Tue Mar 21 09:53:38 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e43d8768d909139bf5ec4a97c79a096ed28a4b08

commit e43d8768d909139bf5ec4a97c79a096ed28a4b08
Author: Jiawei <jiawei@iscas.ac.cn>
Date:   Mon Mar 20 11:34:44 2023 +0800

    RISC-V: Fix disassemble fetch fail return value.
    
    This bug reported in
    https://sourceware.org/bugzilla/show_bug.cgi?id=30184
    And discussed in
    https://sourceware.org/pipermail/binutils/2023-February/126213.html
    
    We also checked the implementation of return value in arm and mips.
    So this patch changes the return value to -1, that can fix bugs and maintain
    consistency with other architectures.
    
    opcodes/ChangeLog:
    
            * riscv-dis.c (print_insn_riscv):Change the return value.

Diff:
---
 opcodes/riscv-dis.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 7baba054daa..f431124b423 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -1059,7 +1059,7 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
       if (status != 0)
 	{
 	  (*info->memory_error_func) (status, memaddr, info);
-	  return status;
+	  return -1;
 	}
       insn = (insn_t) bfd_getl16 (packet);
       dump_size = riscv_insn_length (insn);
@@ -1071,7 +1071,7 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
   if (status != 0)
     {
       (*info->memory_error_func) (status, memaddr, info);
-      return status;
+      return -1;
     }
   insn = (insn_t) bfd_get_bits (packet, dump_size * 8, false);


More information about the Binutils-cvs mailing list