[PATCH] [X86] Fix PR23271 - RIP-relative decoding bug in disassembler.

Douglas Katzman dougk at google.com
Mon Apr 20 07:53:57 PDT 2015


REX.b is not decoded when determining whether the addressing mode is RIP-relative.
Changed some comments that mentioned 'REXW.b' where I think 'REX.b' was meant.

http://reviews.llvm.org/D9110

Files:
  lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
  test/MC/Disassembler/X86/x86-64.txt

Index: lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
===================================================================
--- lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
+++ lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
@@ -1369,13 +1369,14 @@
       switch (rm) {
       case 0x14:
       case 0x4:
-      case 0xc:   /* in case REXW.b is set */
+      case 0xc:   /* in case REX.b is set */
         insn->eaBase = (insn->addressSize == 4 ?
                         EA_BASE_sib : EA_BASE_sib64);
         if (readSIB(insn) || readDisplacement(insn))
           return -1;
         break;
       case 0x5:
+      case 0xd:   /* in case REX.b is set */
         insn->eaBase = EA_BASE_NONE;
         insn->eaDisplacement = EA_DISP_32;
         if (readDisplacement(insn))
@@ -1394,7 +1395,7 @@
       switch (rm) {
       case 0x14:
       case 0x4:
-      case 0xc:   /* in case REXW.b is set */
+      case 0xc:   /* in case REX.b is set */
         insn->eaBase = EA_BASE_sib;
         if (readSIB(insn) || readDisplacement(insn))
           return -1;
Index: test/MC/Disassembler/X86/x86-64.txt
===================================================================
--- test/MC/Disassembler/X86/x86-64.txt
+++ test/MC/Disassembler/X86/x86-64.txt
@@ -301,3 +301,6 @@
 
 # CHECK: movq %rax, 1515870810
 0x67, 0x48 0xa3 0x5a 0x5a 0x5a 0x5a
+
+# CHECK: addq 255(%rip), %rbx
+0x49, 0x03, 0x1d, 0xff, 0x00, 0x00, 0x00

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9110.24023.patch
Type: text/x-patch
Size: 1441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150420/9998f599/attachment.bin>


More information about the llvm-commits mailing list