From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24395 invoked by alias); 8 Jan 2013 15:36:25 -0000 Received: (qmail 24298 invoked by uid 22791); 8 Jan 2013 15:36:24 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-qc0-f176.google.com (HELO mail-qc0-f176.google.com) (209.85.216.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Jan 2013 15:36:12 +0000 Received: by mail-qc0-f176.google.com with SMTP id n41so702320qco.21 for ; Tue, 08 Jan 2013 07:36:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.177.143 with SMTP id bi15mr29107952qab.14.1357659371808; Tue, 08 Jan 2013 07:36:11 -0800 (PST) Received: by 10.49.12.210 with HTTP; Tue, 8 Jan 2013 07:36:11 -0800 (PST) In-Reply-To: <1357657280-24150-1-git-send-email-vapier@gentoo.org> References: <1357657280-24150-1-git-send-email-vapier@gentoo.org> Date: Tue, 08 Jan 2013 15:36:00 -0000 Message-ID: Subject: Re: [PATCH] gdb: x86: fix x32 builds with inline asm From: "H.J. Lu" To: Mike Frysinger Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00131.txt.bz2 On Tue, Jan 8, 2013 at 7:01 AM, Mike Frysinger 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 > > 2012-01-08 Mike Frysinger > > * 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.