From: "Jan Beulich" <JBeulich@suse.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "Binutils" <binutils@sourceware.org>
Subject: Re: [committed, PATCH] PR binutis/18386: callw with 0x66 prefix incorrectly disassembled in 64-bit mode
Date: Mon, 11 May 2015 13:22:00 -0000 [thread overview]
Message-ID: <5550C9360200007800078FA7@mail.emea.novell.com> (raw)
In-Reply-To: <CAMe9rOpzDYMgbBfCbuQBhNHT=VX3u11EpCMqzWFoy5bByfxFRw@mail.gmail.com>
>>> On 11.05.15 at 14:40, <hjl.tools@gmail.com> wrote:
> On Mon, May 11, 2015 at 4:29 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>>> 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.
>>
>
> The displacement is still 32-bit, but stack adjustment is
No, it's not - as you can see from the SEGV happing on address
00000527. If the displacement was 32 bits, then the faulting
address would have been 90900527.
> different. Display it as callq isn't accurate for AMD and
> callw is not correct for both AMD and Intel. I will leave it
> as is since I don't think we should add another instruction
> for this.
>
> BTW, thanks for letting me know. I was using 0x66 as
> nop prefix for call/jmp PIC relaxation. I changed it to
> 0x48 now. Will 0x48 a problem on AMD?
Not as far as I'm aware.
Jan
next prev parent reply other threads:[~2015-05-11 13:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-09 13:52 H.J. Lu
2015-05-11 7:28 ` Jan Beulich
2015-05-11 11:04 ` H.J. Lu
2015-05-11 11:29 ` Jan Beulich
2015-05-11 12:40 ` H.J. Lu
2015-05-11 13:22 ` Jan Beulich [this message]
2015-05-11 13:33 ` H.J. Lu
2015-05-12 9:42 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5550C9360200007800078FA7@mail.emea.novell.com \
--to=jbeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).