From: "H.J. Lu" <hjl.tools@gmail.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com
Subject: Re: [PATCH] gdb: x86: fix x32 builds with inline asm
Date: Tue, 08 Jan 2013 17:50:00 -0000 [thread overview]
Message-ID: <CAMe9rOoBgpgoaStNgoo7M3okFgQGF7R4SkDo9WVZ+5surSOo-A@mail.gmail.com> (raw)
In-Reply-To: <201301081245.14528.vapier@gentoo.org>
On Tue, Jan 8, 2013 at 9:45 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 08 January 2013 11:54:32 H.J. Lu wrote:
>> On Tue, Jan 8, 2013 at 7:59 AM, Mike Frysinger <vapier@gentoo.org> wrote:
>> > On Tuesday 08 January 2013 10:01:20 Mike Frysinger wrote:
>> >> + asm volatile ("push %0;"
>> >> ".globl linux_ptrace_test_ret_to_nx_instr;"
>> >> "linux_ptrace_test_ret_to_nx_instr:"
>> >> "ret"
>> >> - : : "r" (return_address) : "%rsp", "memory");
>> >> + : : "r" (return_address) : "sp", "memory");
>> >
>> > hrm, this works for -m32 and -m64, but doesn't actually help with -mx32.
>> > this doesn't seem to line up with my expectations. can you suggest
>> > something here H.J. Lu ?
>> >
>> > $ cat test.c
>> > main() { asm volatile ("push %0; ret;" : : "r"(main) : "sp", "memory"); }
>> >
>> > $ gcc -m32 test.c
>> > 8: 50 push %eax
>> > 9: c3 ret
>> > $ gcc -m64 test.c
>> > 9: 50 push %rax
>> > a: c3 retq
>> >
>> > $ gcc -mx32 test.c
>> > test.c: Assembler messages:
>> > test.c:2: Error: operand type mismatch for `push'
>>
>> Can you try this?
>>
>> +#ifdef __x86_64__
>> + : : "r" ((uint64_t) (uintptr_t) (return_address))
>
> that seems to work for me, but seems wrong. i guess while most 32/64 bit
> issues can be handled transparently, the stack still only allows
> pushing/popping of 64bit values in x32 mode.
> -mike
I believe it is correct for x32 since "ret" will pop 64bit as return address
for x32.
--
H.J.
next prev parent reply other threads:[~2013-01-08 17:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 14:59 Mike Frysinger
2013-01-08 15:36 ` H.J. Lu
2013-01-08 15:50 ` Mike Frysinger
2013-01-08 17:22 ` Jan Kratochvil
2013-01-08 15:57 ` Mike Frysinger
2013-01-08 16:54 ` H.J. Lu
2013-01-08 17:42 ` Mike Frysinger
2013-01-08 17:50 ` H.J. Lu [this message]
2013-01-08 18:42 ` [PATCH v2] " Mike Frysinger
2013-01-08 18:52 ` Jan Kratochvil
2013-01-08 19:18 ` Mike Frysinger
2013-01-08 19:53 ` Jan Kratochvil
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=CAMe9rOoBgpgoaStNgoo7M3okFgQGF7R4SkDo9WVZ+5surSOo-A@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=vapier@gentoo.org \
/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