]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/h8300-dis.c
Avoid crash in dwarf2_init_complex_target_type
[thirdparty/binutils-gdb.git] / opcodes / h8300-dis.c
index 0d260de68e0cb5772b5695d12e6db1aa63a79948..75d429e6204b7c8a6ec5a0472563a291367708a7 100644 (file)
@@ -1,6 +1,5 @@
 /* Disassemble h8300 instructions.
-   Copyright 1993, 1994, 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2010  Free Software Foundation, Inc.
+   Copyright (C) 1993-2019 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
@@ -24,7 +23,7 @@
 #include "sysdep.h"
 #define h8_opcodes h8ops
 #include "opcode/h8300.h"
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "opintl.h"
 #include "libiberty.h"
 
@@ -60,7 +59,8 @@ bfd_h8_disassemble_init (void)
 
       if (i & 1)
        {
-         fprintf (stderr, "Internal error, h8_disassemble_init.\n");
+         /* xgettext:c-format */
+         opcodes_error_handler (_("internal error, h8_disassemble_init"));
          abort ();
        }
 
@@ -270,14 +270,14 @@ print_one_arg (disassemble_info *info,
        {
          outfn (stream, ".%s%d (0x%lx)",
                   (short) cst > 0 ? "+" : "",
-                  (short) cst, 
+                  (short) cst,
                   (long)(addr + (short) cst + len));
        }
       else
        {
          outfn (stream, ".%s%d (0x%lx)",
                   (char) cst > 0 ? "+" : "",
-                  (char) cst, 
+                  (char) cst,
                   (long)(addr + (char) cst + len));
        }
     }
@@ -286,19 +286,19 @@ print_one_arg (disassemble_info *info,
 
   else if ((x & MODE) == INDEXB)
     /* Always take low half of reg.  */
-    outfn (stream, "@(0x%x:%d,%s.b)", cst, cstlen, 
+    outfn (stream, "@(0x%x:%d,%s.b)", cst, cstlen,
           regnames[rdisp_n < 8 ? rdisp_n + 8 : rdisp_n]);
 
   else if ((x & MODE) == INDEXW)
     /* Always take low half of reg.  */
-    outfn (stream, "@(0x%x:%d,%s.w)", cst, cstlen, 
+    outfn (stream, "@(0x%x:%d,%s.w)", cst, cstlen,
           wregnames[rdisp_n < 8 ? rdisp_n : rdisp_n - 8]);
 
   else if ((x & MODE) == INDEXL)
     outfn (stream, "@(0x%x:%d,%s.l)", cst, cstlen, lregnames[rdisp_n]);
 
   else if (x & CTRL)
-    outfn (stream, cregnames[rn]);
+    outfn (stream, "%s", cregnames[rn]);
 
   else if ((x & MODE) == CCR)
     outfn (stream, "ccr");
@@ -461,8 +461,8 @@ bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach)
                       || (looking_for & MODE) == INDEXW
                       || (looking_for & MODE) == INDEXL)
                {
-                 extract_immediate (stream, looking_for, thisnib, 
-                                    data + len / 2, cst + opnr, 
+                 extract_immediate (stream, looking_for, thisnib,
+                                    data + len / 2, cst + opnr,
                                     cstlen + opnr, q);
                  /* Even address == bra, odd == bra/s.  */
                  if (q->how == O (O_BRAS, SB))
@@ -530,8 +530,8 @@ bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach)
                {
                  int i = len / 2;
 
-                 cst[opnr] = ((data[i] << 24) 
-                              | (data[i + 1] << 16) 
+                 cst[opnr] = ((data[i] << 24)
+                              | (data[i + 1] << 16)
                               | (data[i + 2] << 8)
                               | (data[i + 3]));
 
@@ -541,14 +541,10 @@ bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach)
                {
                  int i = len / 2;
 
-                 cst[opnr] = 
+                 cst[opnr] =
                    (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);
                  cstlen[opnr] = 24;
                }
-             else if (looking_for & IGNORE)
-               {
-                 ;
-               }
              else if (looking_for & DISPREG)
                {
                  dispregno[opnr] = thisnib & 7;
@@ -634,21 +630,21 @@ bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach)
                      if (args[1] == (op_type) E)
                        {
                          /* Short form.  */
-                         print_one_arg (info, addr, args[0], cst[0], 
-                                        cstlen[0], dispregno[0], regno[0], 
+                         print_one_arg (info, addr, args[0], cst[0],
+                                        cstlen[0], dispregno[0], regno[0],
                                         pregnames, qi->length);
                          outfn (stream, ",er%d", dispregno[0]);
                        }
                      else
                        {
                          outfn (stream, "@(0x%x:%d,", cst[0], cstlen[0]);
-                         print_one_arg (info, addr, args[1], cst[1], 
-                                        cstlen[1], dispregno[1], regno[1], 
+                         print_one_arg (info, addr, args[1], cst[1],
+                                        cstlen[1], dispregno[1], regno[1],
                                         pregnames, qi->length);
                          outfn (stream, ".%c),",
                                 (args[0] & MODE) == INDEXB ? 'b' : 'w');
-                         print_one_arg (info, addr, args[2], cst[2], 
-                                        cstlen[2], dispregno[2], regno[2], 
+                         print_one_arg (info, addr, args[2], cst[2],
+                                        cstlen[2], dispregno[2], regno[2],
                                         pregnames, qi->length);
                        }
                      return qi->length;
@@ -670,7 +666,7 @@ bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach)
                        return qi->length;
                      }
 
-                   for (nargs = 0; 
+                   for (nargs = 0;
                         nargs < 3 && args[nargs] != (op_type) E;
                         nargs++)
                      {