[binutils-gdb] x86/APX: with REX2 map 1 doesn't "chain" to maps 2 or 3

Jan Beulich jbeulich@sourceware.org
Fri Feb 9 07:40:17 GMT 2024


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

commit 41e115853eef32304e3e6fcd7feb4ec116090ee0
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Feb 9 08:39:48 2024 +0100

    x86/APX: with REX2 map 1 doesn't "chain" to maps 2 or 3
    
    Don't wander into three_byte_table[] when REX2 is present.
    
    While there also eliminate related confusion when accessing
    dis386_twobyte[]: There's nothing 3-byte-ish involved there. Dropping
    the odd variable gets things better in sync with 1-byte handling as
    well.

Diff:
---
 opcodes/i386-dis.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 62c37a9dc26..31afa9c9fbc 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -8833,6 +8833,8 @@ get_valid_dis386 (const struct dis386 *dp, instr_info *ins)
       break;
 
     case USE_3BYTE_TABLE:
+      if (ins->last_rex2_prefix >= 0)
+	return &err_opcode;
       if (!fetch_code (ins->info, ins->codep + 2))
 	return &err_opcode;
       vindex = *ins->codep++;
@@ -9550,8 +9552,6 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
   /* REX2.M in rex2 prefix represents map0 or map1.  */
   if (ins.last_rex2_prefix < 0 ? *ins.codep == 0x0f : (ins.rex2 & REX2_M))
     {
-      unsigned char threebyte;
-
       if (!ins.rex2)
 	{
 	  ins.codep++;
@@ -9559,17 +9559,15 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
 	    goto fetch_error_out;
 	}
 
-      threebyte = *ins.codep;
-      dp = &dis386_twobyte[threebyte];
-      ins.need_modrm = twobyte_has_modrm[threebyte];
-      ins.codep++;
+      dp = &dis386_twobyte[*ins.codep];
+      ins.need_modrm = twobyte_has_modrm[*ins.codep];
     }
   else
     {
       dp = &dis386[*ins.codep];
       ins.need_modrm = onebyte_has_modrm[*ins.codep];
-      ins.codep++;
     }
+  ins.codep++;
 
   /* Save sizeflag for printing the extra ins.prefixes later before updating
      it for mnemonic and operand processing.  The prefix names depend


More information about the Binutils-cvs mailing list