Prevent address violation problem when disassembling corrupt aarch64 binary.
[deliverable/binutils-gdb.git] / opcodes / aarch64-gen.c
index ed0834a7ac64a92dda238b74b05f22d0302f8a6b..d2685dc3d1dea71afaec13adc0ae95d79295b27c 100644 (file)
@@ -1,6 +1,6 @@
 /* aarch64-gen.c -- Generate tables and routines for opcode lookup and
    instruction encoding and decoding.
-   Copyright (C) 2012-2016 Free Software Foundation, Inc.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of the GNU opcodes library.
@@ -143,9 +143,9 @@ read_table (const struct aarch64_opcode* table)
       /* F_PSEUDO needs to be used together with F_ALIAS to indicate an alias
         opcode is a programmer friendly pseudo instruction available only in
         the assembly code (thus will not show up in the disassembly).  */
-      assert (pseudo_opcode_p (ent) == FALSE || alias_opcode_p (ent) == TRUE);
+      assert (!pseudo_opcode_p (ent) || alias_opcode_p (ent));
       /* Skip alias (inc. pseudo) opcode.  */
-      if (alias_opcode_p (ent) == TRUE)
+      if (alias_opcode_p (ent))
        {
          index++;
          continue;
@@ -378,13 +378,9 @@ initialize_decoder_tree (void)
 static void __attribute__ ((format (printf, 2, 3)))
 indented_print (unsigned int indent, const char *format, ...)
 {
-  /* 80 number of spaces pluc a NULL terminator.  */
-  static const char spaces[81] =
-    "                                                                                ";
   va_list ap;
   va_start (ap, format);
-  assert (indent <= 80);
-  printf ("%s", &spaces[80 - indent]);
+  printf ("%*s", (int) indent, "");
   vprintf (format, ap);
   va_end (ap);
 }
@@ -691,8 +687,8 @@ opcode_node *
 find_alias_opcode (const aarch64_opcode *opcode)
 {
   int i;
-  /* Assume maximum of 16 disassemble preference candidates.  */
-  const int max_num_aliases = 16;
+  /* Assume maximum of 32 disassemble preference candidates.  */
+  const int max_num_aliases = 32;
   const aarch64_opcode *ent;
   const aarch64_opcode *preferred[max_num_aliases + 1];
   opcode_node head, **next;
@@ -708,7 +704,7 @@ find_alias_opcode (const aarch64_opcode *opcode)
       /* The mask of an alias opcode must be equal to or a super-set (i.e.
         more constrained) of that of the aliased opcode; so is the base
         opcode value.  */
-      if (alias_opcode_p (ent) == TRUE
+      if (alias_opcode_p (ent)
          && (ent->mask & opcode->mask) == opcode->mask
          && (opcode->mask & ent->opcode) == (opcode->mask & opcode->opcode))
        {
@@ -1245,7 +1241,7 @@ main (int argc, char **argv)
     print_divide_result (decoder_tree);
 
   printf ("/* This file is automatically generated by aarch64-gen.  Do not edit!  */\n");
-  printf ("/* Copyright (C) 2012-2016 Free Software Foundation, Inc.\n\
+  printf ("/* Copyright (C) 2012-2017 Free Software Foundation, Inc.\n\
    Contributed by ARM Ltd.\n\
 \n\
    This file is part of the GNU opcodes library.\n\
This page took 0.023677 seconds and 4 git commands to generate.