This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [committed, PATCH] PR binutis/18386: callw with 0x66 prefix incorrectly disassembled in 64-bit mode
- From: "Jan Beulich" <JBeulich at suse dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: "Binutils" <binutils at sourceware dot org>
- Date: Mon, 11 May 2015 12:29:39 +0100
- Subject: Re: [committed, PATCH] PR binutis/18386: callw with 0x66 prefix incorrectly disassembled in 64-bit mode
- Authentication-results: sourceware.org; auth=none
- References: <20150509135213 dot GA720 at gmail dot com> <555076520200007800078B8F at mail dot emea dot novell dot com> <CAMe9rOpRdCftue3uFgaejAYZbi=kC91y7sXkfWg-8py3Nmy5kw at mail dot gmail dot com>
>>> On 11.05.15 at 13:04, <hjl.tools@gmail.com> wrote:
> On Mon, May 11, 2015 at 12:28 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>>> On 09.05.15 at 15:52, <hjl.tools@gmail.com> wrote:
>>> The operand size prefix (0x66) is ignored for 32-bit PC-relative call,
>>> jmp and jcc in 64-bit mode.
>>
>> Now that's again a change that should have been discussed
>> before committing: While it is correct for the Intel implementation
>> of x86-64, it isn't for AMD's original (and I'd tend to say that the
>> latter is more correct, since afaik there's nowhere that exceptions
>> are being made for the meaning of the operand size prefix).
>
> It is also correct for AMD.
Very certainly not, based on practical observation: This code
x86_64:
mov rcx, rsp
.byte 0x66, 0xe8, 0x00, 0x00, 0x90, 0x90
xchg rcx, rsp
ret
yields
Reading symbols from /home/jbeulich/x86-64...done.
(gdb) break x86_64
Breakpoint 1 at 0x400520
(gdb) r
Starting program: /home/jbeulich/x86-64
Failed to read a valid object file image from memory.
Breakpoint 1, 0x0000000000400520 in x86_64 ()
(gdb) x/5i $pc
=> 0x400520 <x86_64>: mov rcx,rsp
0x400523 <x86_64+3>: call 0x527
0x400527 <x86_64+7>: nop
0x400528 <x86_64+8>: nop
0x400529 <x86_64+9>: xchg rcx,rsp
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000527 in ?? ()
with RSP also decremented by just 2.
Jan