aboutsummaryrefslogtreecommitdiff
path: root/opcodes/disassemble.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-26 16:26:16 +1030
committerAlan Modra <amodra@gmail.com>2020-03-26 20:02:42 +1030
commit832a580781060f54731fcf654d76ac1332037a47 (patch)
treec1bcb32db186241befa7a78ceec2d2b2cc31e457 /opcodes/disassemble.c
parentff7685105468702de87b75599b1ea88cc309541c (diff)
downloadgdb-832a580781060f54731fcf654d76ac1332037a47.zip
gdb-832a580781060f54731fcf654d76ac1332037a47.tar.gz
gdb-832a580781060f54731fcf654d76ac1332037a47.tar.bz2
Re: H8300 use of uninitialised value
This patch also had some problems. Calculation of maxlen was wrong, and the insn arg loop needed rearranging to work with a correct length. * disassemble.h (opcodes_assert): Declare. (OPCODES_ASSERT): Define. * disassemble.c: Don't include assert.h. Include opintl.h. (opcodes_assert): New function. * h8300-dis.c (bfd_h8_disassemble_init): Use OPCODES_ASSERT. (bfd_h8_disassemble): Reduce size of data array. Correctly calculate maxlen. Omit insn decoding when insn length exceeds maxlen. Exit from nibble loop when looking for E, before accessing next data byte. Move processing of E outside loop. Replace tests of maxlen in loop with assertions.
Diffstat (limited to 'opcodes/disassemble.c')
-rw-r--r--opcodes/disassemble.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
index d49a2b8..25816ef 100644
--- a/opcodes/disassemble.c
+++ b/opcodes/disassemble.c
@@ -21,7 +21,7 @@
#include "sysdep.h"
#include "disassemble.h"
#include "safe-ctype.h"
-#include <assert.h>
+#include "opintl.h"
#ifdef ARCH_all
#define ARCH_aarch64
@@ -832,3 +832,11 @@ disassembler_options_cmp (const char *s1, const char *s2)
return c1 - c2;
}
+
+void
+opcodes_assert (const char *file, int line)
+{
+ opcodes_error_handler (_("assertion fail %s:%d"), file, line);
+ opcodes_error_handler (_("Please report this bug"));
+ abort ();
+}