[llvm] r316319 - Fix for Bug 30718 - Failure to disassemble certain MOV with rex.R. The issue was in illegal segment register index.

Andrew V. Tischenko via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 02:36:33 PDT 2017


Author: avt77
Date: Mon Oct 23 02:36:33 2017
New Revision: 316319

URL: http://llvm.org/viewvc/llvm-project?rev=316319&view=rev
Log:
Fix for Bug 30718 - Failure to disassemble certain MOV with rex.R. The issue was in illegal segment register index.
Differential Revision: https://reviews.llvm.org/D38786

Modified:
    llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
    llvm/trunk/test/MC/Disassembler/X86/x86-64.txt

Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp?rev=316319&r1=316318&r2=316319&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp (original)
+++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp Mon Oct 23 02:36:33 2017
@@ -1453,9 +1453,9 @@ static int readModRM(struct InternalInst
     case TYPE_MM64:                                       \
       return prefix##_MM0 + (index & 0x7);                \
     case TYPE_SEGMENTREG:                                 \
-      if (index > 5)                                      \
+      if ((index & 7) > 5)                                \
         *valid = 0;                                       \
-      return prefix##_ES + index;                         \
+      return prefix##_ES + (index & 7);                   \
     case TYPE_DEBUGREG:                                   \
       return prefix##_DR0 + index;                        \
     case TYPE_CONTROLREG:                                 \

Modified: llvm/trunk/test/MC/Disassembler/X86/x86-64.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/x86-64.txt?rev=316319&r1=316318&r2=316319&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/X86/x86-64.txt (original)
+++ llvm/trunk/test/MC/Disassembler/X86/x86-64.txt Mon Oct 23 02:36:33 2017
@@ -482,6 +482,9 @@
 # CHECK:  xchgw   %di, %ax
 0x66 0x3e 0x97
 
+# CHECK: movq    %rdx, %cs
+0x4c 0x8e 0xca
+
 # CHECK: movw    %bx, %cs:(%rsi,%rbp)
 0x2e 0x66 0x89 0x1c 0x2e
 # CHECK: movl    %ebx, %cs:(%esi,%ebp)




More information about the llvm-commits mailing list