From: Jan Stancek Date: Mon, 24 Aug 2015 13:50:15 +0000 (+0100) Subject: Fix the partial disassembly of a broken three byte instruction at the end of a function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5f40e14d768b94f7fdc050aeba5ee62e6a8d5756;p=binutils-gdb.git Fix the partial disassembly of a broken three byte instruction at the end of a function. opcodes * i386-dis.c (print_insn): Fix decoding of three byte operands. tests * gas/i386/intel.s: Add test of disassembly of a potential three byte instuction at the end of a function. * gas/i386/intel.d: Update expected disassembly. --- diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 2951966c0a2..6b852496958 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-08-24 Jan Stancek + + * gas/i386/intel.s: Add test of disassembly of a potential + three byte instuction at the end of a function. + * gas/i386/intel.d: Update expected disassembly. + 2015-08-21 Nick Clifton PR gas/18581 diff --git a/gas/testsuite/gas/i386/intel.d b/gas/testsuite/gas/i386/intel.d index 45a66a5e41f..d10b4f00bb4 100644 --- a/gas/testsuite/gas/i386/intel.d +++ b/gas/testsuite/gas/i386/intel.d @@ -698,4 +698,8 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 0f 4b 90 90 90 90 90 cmovnp -0x6f6f6f70\(%eax\),%edx [ ]*[a-f0-9]+: 66 0f 4a 90 90 90 90 90 cmovp -0x6f6f6f70\(%eax\),%dx [ ]*[a-f0-9]+: 66 0f 4b 90 90 90 90 90 cmovnp -0x6f6f6f70\(%eax\),%dx +[ ]*[a-f0-9]+: 24 2f and \$0x2f,%al +[ ]*[a-f0-9]+: 0f \.byte 0xf +[a-f0-9]+ : +[ ]*[a-f0-9]+: 0f ba e2 03 bt \$0x3,%edx #pass diff --git a/gas/testsuite/gas/i386/intel.s b/gas/testsuite/gas/i386/intel.s index a3a07b336a4..045d6ae0fd0 100644 --- a/gas/testsuite/gas/i386/intel.s +++ b/gas/testsuite/gas/i386/intel.s @@ -698,3 +698,14 @@ fidivr dword ptr [ebx] cmovpo edx, 0x90909090[eax] cmovpe dx, 0x90909090[eax] cmovpo dx, 0x90909090[eax] + + # Test that disassembly of a partial instruction shows the partial byte: + # https://www.sourceware.org/ml/binutils/2015-08/msg00226.html + .byte 0x24 + .byte 0x2f + .byte 0x0f +barn: + .byte 0x0f + .byte 0xba + .byte 0xe2 + .byte 0x03 diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 89e150fa42d..3529dbc66a1 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2015-08-24 Jan Stancek + + * i386-dis.c (print_insn): Fix decoding of three byte operands. + 2015-08-21 Alexander Fomin PR binutils/18257 diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 055b38f9863..ae18cf2dee0 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -13438,8 +13438,10 @@ print_insn (bfd_vma pc, disassemble_info *info) if (*codep == 0x0f) { unsigned char threebyte; - FETCH_DATA (info, codep + 2); - threebyte = *++codep; + + codep++; + FETCH_DATA (info, codep + 1); + threebyte = *codep; dp = &dis386_twobyte[threebyte]; need_modrm = twobyte_has_modrm[*codep]; codep++;