From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12950 invoked by alias); 8 Jan 2013 17:42:58 -0000 Received: (qmail 12855 invoked by uid 22791); 8 Jan 2013 17:42:56 -0000 X-SWARE-Spam-Status: No, hits=-8.9 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Jan 2013 17:42:50 +0000 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 867D633DA0B; Tue, 8 Jan 2013 17:42:49 +0000 (UTC) From: Mike Frysinger To: "H.J. Lu" Subject: Re: [PATCH] gdb: x86: fix x32 builds with inline asm Date: Tue, 08 Jan 2013 17:42:00 -0000 User-Agent: KMail/1.13.7 (Linux/3.7.1; KDE/4.6.5; x86_64; ; ) Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com References: <1357657280-24150-1-git-send-email-vapier@gentoo.org> <201301081059.40723.vapier@gentoo.org> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart6505588.xkT8zkZFcl"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201301081245.14528.vapier@gentoo.org> 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/msg00141.txt.bz2 --nextPart6505588.xkT8zkZFcl Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 1498 On Tuesday 08 January 2013 11:54:32 H.J. Lu wrote: > On Tue, Jan 8, 2013 at 7:59 AM, Mike Frysinger 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"); > >=20 > > hrm, this works for -m32 and -m64, but doesn't actually help with -mx32= .=20 > > this doesn't seem to line up with my expectations. can you suggest > > something here H.J. Lu ? > >=20 > > $ cat test.c > > main() { asm volatile ("push %0; ret;" : : "r"(main) : "sp", "memory");= } > >=20 > > $ gcc -m32 test.c > > 8: 50 push %eax > > 9: c3 ret > > $ gcc -m64 test.c > > 9: 50 push %rax > > a: c3 retq > >=20 > > $ gcc -mx32 test.c > > test.c: Assembler messages: > > test.c:2: Error: operand type mismatch for `push' >=20 > 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=20 issues can be handled transparently, the stack still only allows=20 pushing/popping of 64bit values in x32 mode. -mike --nextPart6505588.xkT8zkZFcl Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. Content-length: 836 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJQ7FsqAAoJEEFjO5/oN/WBXGMQALmb71y7VfDANzAX5yiDKb9R gQ1VlVr5n5XoEOGN36E/hMEW3rCuIwKMoes0djNsdQrmsjb1VZtEMuhwog2DORCw jpak8+UQi33jU1QBJCUwk1aEO3JJ4VWmdnwVKyaGJo9rm3k59fQ1ct/e9xrEgYkG 2wM1NcD1EAx0aHvVZjyRz4gxLnyh+UXZfbkgp5dm6FLFjOaC4cLOwDaI2sxaOVbV 9Msr5aTT8AEc6VXLAF1l5PPw0SFGiC1gAZlc9j/u0/pQeAq8sy6qF+Qg94AgAsWb 3R2Hhm9l1HC/6Q3IIy3rbnzMiuew5BtdNV+v0ku4Z8kPLEV3tLpaYiJ1XR6pRuHd 9FuCpKbVGo7RZgXj+AQaop8MSiYrm3pMRzgNH2kgfqfxlOyTi1l9/J1iceEhmQDy cIZPNDrgvkkWp23GHp4vK8f2xFU0i40nUzLaNjb7v0UdfhRX/PVle04j+Nhd8FoA 5oJwD+6s/XuYo2uMAabEZoI6h3b3PdxzbafmUJoavnEl9g9vZ3pCMhrXGpjcwkZ3 j82J/LlyqkqoXYCx6FAnRrwcBqFpktZ/O49aKa1+Llt1hnLa7/kcW8Xmyzit0y07 8080DCzufi42qtjlvXpbKKzyAqX4+ULNEpXYA0Yy1KOcOfUZ4VRNBq8+XSyQSfgf 17jSGFNulBIWKQZR/FJc =2dY5 -----END PGP SIGNATURE----- --nextPart6505588.xkT8zkZFcl--