ubsan: z8k: index 10 out of bounds for type 'unsigned int const[10]'
[deliverable/binutils-gdb.git] / opcodes / i386-dis.c
index d1d8b55af3e766dc12da361a88b036db658daf55..ce27e0e0b89249edda9841364834b8090a8185da 100644 (file)
@@ -1,5 +1,5 @@
 /* Print i386 instructions for GDB, the GNU debugger.
-   Copyright (C) 1988-2019 Free Software Foundation, Inc.
+   Copyright (C) 1988-2020 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
@@ -101,7 +101,6 @@ static void VPCOM_Fixup (int, int);
 static void OP_0f07 (int, int);
 static void OP_Monitor (int, int);
 static void OP_Mwait (int, int);
-static void OP_Mwaitx (int, int);
 static void NOP_Fixup1 (int, int);
 static void NOP_Fixup2 (int, int);
 static void OP_3DNowSuffix (int, int);
@@ -297,6 +296,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
 #define I1 { OP_I, const_1_mode }
 #define Jb { OP_J, b_mode }
 #define Jv { OP_J, v_mode }
+#define Jdqw { OP_J, dqw_mode }
 #define Cm { OP_C, m_mode }
 #define Dm { OP_D, m_mode }
 #define Td { OP_T, d_mode }
@@ -559,7 +559,8 @@ enum
   v_bndmk_mode,
   /* operand size depends on REX prefixes.  */
   dq_mode,
-  /* registers like dq_mode, memory like w_mode.  */
+  /* registers like dq_mode, memory like w_mode, displacements like
+     v_mode without considering Intel64 ISA.  */
   dqw_mode,
   /* bounds operand */
   bnd_mode,
@@ -964,6 +965,8 @@ enum
   PREFIX_0F01_REG_5_MOD_0,
   PREFIX_0F01_REG_5_MOD_3_RM_0,
   PREFIX_0F01_REG_5_MOD_3_RM_2,
+  PREFIX_0F01_REG_7_MOD_3_RM_2,
+  PREFIX_0F01_REG_7_MOD_3_RM_3,
   PREFIX_0F09,
   PREFIX_0F10,
   PREFIX_0F11,
@@ -3643,6 +3646,17 @@ static const struct dis386 prefix_table[][4] = {
     { "saveprevssp",   { Skip_MODRM }, PREFIX_OPCODE },
   },
 
+  /* PREFIX_0F01_REG_7_MOD_3_RM_2 */
+  {
+    { "monitorx",      { { OP_Monitor, 0 } }, 0  },
+    { "mcommit",       { Skip_MODRM }, 0 },
+  },
+
+  /* PREFIX_0F01_REG_7_MOD_3_RM_3 */
+  {
+    { "mwaitx",                { { OP_Mwait, eBX_reg } }, 0  },
+  },
+
   /* PREFIX_0F09 */
   {
     { "wbinvd",   { XX }, 0 },
@@ -10510,7 +10524,7 @@ static const struct dis386 mod_table[][2] = {
   },
   {
     /* MOD_0F38F9_PREFIX_0 */
-    { "movdiri",       { Em, Gv }, PREFIX_OPCODE },
+    { "movdiri",       { Ev, Gv }, PREFIX_OPCODE },
   },
   {
     /* MOD_62_32BIT */
@@ -10957,7 +10971,7 @@ static const struct dis386 rm_table[][8] = {
   },
   {
     /* RM_C7_REG_7 */
-    { "xbeginT",       { Skip_MODRM, Jv }, 0 },
+    { "xbeginT",       { Skip_MODRM, Jdqw }, 0 },
   },
   {
     /* RM_0F01_REG_0 */
@@ -11016,9 +11030,10 @@ static const struct dis386 rm_table[][8] = {
     /* RM_0F01_REG_7_MOD_3 */
     { "swapgs",                { Skip_MODRM }, 0  },
     { "rdtscp",                { Skip_MODRM }, 0  },
-    { "monitorx",      { { OP_Monitor, 0 } }, 0  },
-    { "mwaitx",                { { OP_Mwaitx,  0 } }, 0  },
+    { PREFIX_TABLE (PREFIX_0F01_REG_7_MOD_3_RM_2) },
+    { PREFIX_TABLE (PREFIX_0F01_REG_7_MOD_3_RM_3) },
     { "clzero",                { Skip_MODRM }, 0  },
+    { "rdpru",         { Skip_MODRM }, 0  },
   },
   {
     /* RM_0F1E_P_1_MOD_3_REG_7 */
@@ -14815,10 +14830,12 @@ OP_J (int bytemode, int sizeflag)
       break;
     case v_mode:
       if (isa64 == amd64)
+    case dqw_mode:
        USED_REX (REX_W);
       if ((sizeflag & DFLAG)
          || (address_mode == mode_64bit
-             && (isa64 != amd64 || (rex & REX_W))))
+             && ((isa64 != amd64 && bytemode != dqw_mode)
+                 || (rex & REX_W))))
        disp = get32s ();
       else
        {
@@ -15504,35 +15521,15 @@ CMP_Fixup (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
 }
 
 static void
-OP_Mwaitx (int bytemode ATTRIBUTE_UNUSED,
-         int sizeflag ATTRIBUTE_UNUSED)
-{
-  /* mwaitx %eax,%ecx,%ebx */
-  if (!intel_syntax)
-    {
-      const char **names = (address_mode == mode_64bit
-                           ? names64 : names32);
-      strcpy (op_out[0], names[0]);
-      strcpy (op_out[1], names[1]);
-      strcpy (op_out[2], names[3]);
-      two_source_ops = 1;
-    }
-  /* Skip mod/rm byte.  */
-  MODRM_CHECK;
-  codep++;
-}
-
-static void
-OP_Mwait (int bytemode ATTRIBUTE_UNUSED,
-         int sizeflag ATTRIBUTE_UNUSED)
+OP_Mwait (int bytemode, int sizeflag ATTRIBUTE_UNUSED)
 {
-  /* mwait %eax,%ecx  */
+  /* mwait %eax,%ecx / mwaitx %eax,%ecx,%ebx  */
   if (!intel_syntax)
     {
-      const char **names = (address_mode == mode_64bit
-                           ? names64 : names32);
-      strcpy (op_out[0], names[0]);
-      strcpy (op_out[1], names[1]);
+      strcpy (op_out[0], names32[0]);
+      strcpy (op_out[1], names32[1]);
+      if (bytemode == eBX_reg)
+       strcpy (op_out[2], names32[3]);
       two_source_ops = 1;
     }
   /* Skip mod/rm byte.  */
@@ -15544,27 +15541,25 @@ static void
 OP_Monitor (int bytemode ATTRIBUTE_UNUSED,
            int sizeflag ATTRIBUTE_UNUSED)
 {
-  /* monitor %eax,%ecx,%edx"  */
+  /* monitor %{e,r,}ax,%ecx,%edx"  */
   if (!intel_syntax)
     {
-      const char **op1_names;
       const char **names = (address_mode == mode_64bit
                            ? names64 : names32);
 
-      if (!(prefixes & PREFIX_ADDR))
-       op1_names = (address_mode == mode_16bit
-                    ? names16 : names);
-      else
+      if (prefixes & PREFIX_ADDR)
        {
          /* Remove "addr16/addr32".  */
          all_prefixes[last_addr_prefix] = 0;
-         op1_names = (address_mode != mode_32bit
-                      ? names32 : names16);
+         names = (address_mode != mode_32bit
+                  ? names32 : names16);
          used_prefixes |= PREFIX_ADDR;
        }
-      strcpy (op_out[0], op1_names[0]);
-      strcpy (op_out[1], names[1]);
-      strcpy (op_out[2], names[2]);
+      else if (address_mode == mode_16bit)
+       names = names16;
+      strcpy (op_out[0], names[0]);
+      strcpy (op_out[1], names32[1]);
+      strcpy (op_out[2], names32[2]);
       two_source_ops = 1;
     }
   /* Skip mod/rm byte.  */
This page took 0.028154 seconds and 4 git commands to generate.