Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
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 15:36:00 -0000	[thread overview]
Message-ID: <CAMe9rOpWGMKQ+QqD8ucfv3Z2wh+fyJ7aaRomewDWzE78pJTTwQ@mail.gmail.com> (raw)
In-Reply-To: <1357657280-24150-1-git-send-email-vapier@gentoo.org>

On Tue, Jan 8, 2013 at 7:01 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> The inline assembly fails with x32 targets due to pushq used with a 32bit
> register.  Since the assembler can do the right thing with a "push" insn
> and a 32bit or 64bit register (i.e. it'll pushl or pushq as needed), just
> use that insn.
>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>
> 2012-01-08  Mike Frysinger  <vapier@gentoo.org>
>
>         * common/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Change pushl
>         to push in i386 inline asm and %esp to sp.  Delete __i386__ check
>         and __x86_64__ inline asm.
> ---
> Note: I'm not 100% on the "sp" constraint.  Seems to work, and reading
>         the gcc constraints list looks like it aliases sp/esp/rsp to the same
>         thing.
>
>  gdb/common/linux-ptrace.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/gdb/common/linux-ptrace.c b/gdb/common/linux-ptrace.c
> index 761ef59..abb502c 100644
> --- a/gdb/common/linux-ptrace.c
> +++ b/gdb/common/linux-ptrace.c
> @@ -103,21 +103,11 @@ linux_ptrace_test_ret_to_nx (void)
>                  strerror (errno));
>        else
>         {
> -#if defined __i386__
> -         asm volatile ("pushl %0;"
> -                       ".globl linux_ptrace_test_ret_to_nx_instr;"
> -                       "linux_ptrace_test_ret_to_nx_instr:"
> -                       "ret"
> -                       : : "r" (return_address) : "%esp", "memory");
> -#elif defined __x86_64__
> -         asm volatile ("pushq %0;"
> +         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");
> -#else
> -# error "!__i386__ && !__x86_64__"
> -#endif
> +                       : : "r" (return_address) : "sp", "memory");
>           gdb_assert_not_reached ("asm block did not terminate");
>         }
>

I think we should keep

#else
# error "!__i386__ && !__x86_64__"
#endif

Thanks.

-- 
H.J.


  reply	other threads:[~2013-01-08 15:36 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 [this message]
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
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=CAMe9rOpWGMKQ+QqD8ucfv3Z2wh+fyJ7aaRomewDWzE78pJTTwQ@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