From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25261 invoked by alias); 12 May 2012 23:16:09 -0000 Received: (qmail 25253 invoked by uid 22791); 12 May 2012 23:16:08 -0000 X-SWARE-Spam-Status: No, hits=-4.9 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-f169.google.com (HELO mail-qc0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 12 May 2012 23:15:54 +0000 Received: by qcsd16 with SMTP id d16so3222619qcs.0 for ; Sat, 12 May 2012 16:15:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.174.134 with SMTP id t6mr4683882qaz.83.1336864553670; Sat, 12 May 2012 16:15:53 -0700 (PDT) Received: by 10.229.169.130 with HTTP; Sat, 12 May 2012 16:15:53 -0700 (PDT) In-Reply-To: <201205122116.q4CLG6lN019181@glazunov.sibelius.xs4all.nl> References: <20120511192133.GA4947@intel.com> <201205112011.q4BKB5Mi012054@glazunov.sibelius.xs4all.nl> <201205122116.q4CLG6lN019181@glazunov.sibelius.xs4all.nl> Date: Sat, 12 May 2012 23:16:00 -0000 Message-ID: Subject: Re: PATCH: Support x32 siginfo_t conversion From: "H.J. Lu" To: Mark Kettenis Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2012-05/txt/msg00488.txt.bz2 On Sat, May 12, 2012 at 2:16 PM, Mark Kettenis wr= ote: >> Date: Fri, 11 May 2012 13:55:29 -0700 >> From: "H.J. Lu" >> >> On Fri, May 11, 2012 at 1:11 PM, Mark Kettenis = wrote: >> >> Date: Fri, 11 May 2012 12:21:33 -0700 >> >> From: "H.J. Lu" >> >> >> >> Hi, >> >> >> >> This patch implements x32 siginfo_t conversion. =A0Tested on Linux/x8= 6-64. >> >> OK to install? >> >> >> >> Thanks. >> >> >> >> >> >> H.J. >> >> -- >> >> =A0 =A0 =A0 * amd64-linux-nat.c (compat_x32_clock_t): New. >> >> =A0 =A0 =A0 (compat_x32_siginfo_t): Likewise. >> >> =A0 =A0 =A0 (compat_x32_siginfo_from_siginfo): Likewise. >> >> =A0 =A0 =A0 (siginfo_from_compat_x32_siginfo): Likewise. >> >> =A0 =A0 =A0 (amd64_linux_siginfo_fixup): Call compat_x32_siginfo_from= _siginfo >> >> =A0 =A0 =A0 and siginfo_from_compat_x32_siginfo for x32. >> >> >> >> diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c >> >> index 3be8404..97c9a49 100644 >> >> --- a/gdb/amd64-linux-nat.c >> >> +++ b/gdb/amd64-linux-nat.c >> >> @@ -591,6 +591,67 @@ typedef struct compat_siginfo >> >> =A0 =A0} _sifields; >> >> =A0} compat_siginfo_t; >> >> >> >> +/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. =A0*/ >> >> +typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t; >> > >> > Sorry, but that isn't acceptable. >> > >> > Is your X32 ABI really that broken? >> > >> >> +typedef struct compat_x32_siginfo >> >> +{ >> >> + =A0int si_signo; >> >> + =A0int si_errno; >> >> + =A0int si_code; >> >> + >> >> + =A0union >> >> + =A0{ >> >> + =A0 =A0int _pad[((128 / sizeof (int)) - 3)]; >> >> + >> >> + =A0 =A0/* kill() */ >> >> + =A0 =A0struct >> >> + =A0 =A0{ >> >> + =A0 =A0 =A0unsigned int _pid; >> >> + =A0 =A0 =A0unsigned int _uid; >> >> + =A0 =A0} _kill; >> >> + >> >> + =A0 =A0/* POSIX.1b timers */ >> >> + =A0 =A0struct >> >> + =A0 =A0{ >> >> + =A0 =A0 =A0compat_timer_t _tid; >> >> + =A0 =A0 =A0int _overrun; >> >> + =A0 =A0 =A0compat_sigval_t _sigval; >> >> + =A0 =A0} _timer; >> >> + >> >> + =A0 =A0/* POSIX.1b signals */ >> >> + =A0 =A0struct >> >> + =A0 =A0{ >> >> + =A0 =A0 =A0unsigned int _pid; >> >> + =A0 =A0 =A0unsigned int _uid; >> >> + =A0 =A0 =A0compat_sigval_t _sigval; >> >> + =A0 =A0} _rt; >> >> + >> >> + =A0 =A0/* SIGCHLD */ >> >> + =A0 =A0struct >> >> + =A0 =A0{ >> >> + =A0 =A0 =A0unsigned int _pid; >> >> + =A0 =A0 =A0unsigned int _uid; >> >> + =A0 =A0 =A0int _status; >> >> + =A0 =A0 =A0compat_x32_clock_t _utime; >> >> + =A0 =A0 =A0compat_x32_clock_t _stime; >> >> + =A0 =A0} _sigchld; >> >> + >> >> + =A0 =A0/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ >> >> + =A0 =A0struct >> >> + =A0 =A0{ >> >> + =A0 =A0 =A0unsigned int _addr; >> >> + =A0 =A0} _sigfault; >> >> + >> >> + =A0 =A0/* SIGPOLL */ >> >> + =A0 =A0struct >> >> + =A0 =A0{ >> >> + =A0 =A0 =A0int _band; >> >> + =A0 =A0 =A0int _fd; >> >> + =A0 =A0} _sigpoll; >> >> + =A0} _sifields; >> >> +} compat_x32_siginfo_t __attribute__ ((__aligned__ (8))); >> > >> > Same here. =A0I don't think you need alignment here, even with the bro= ken ABI. >> > >> > If it really is too late to fix the X32 ABI, you'll have to write this >> > portably by splitting _utime and _stime into two 32-bit variables and >> > write code that correctly sets the upper and lower 32-bits. >> > >> > >> >> X32 ABI choice is done on purpose. =A0X32 siginfo_t has >> >> typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t; >> >> typedef struct compat_x32_siginfo >> { >> =A0 int si_signo; >> =A0 int si_errno; >> =A0 int si_code; >> >> =A0 union >> =A0 { >> ... >> =A0 =A0 /* SIGCHLD */ >> =A0 =A0 struct >> =A0 =A0 { >> =A0 =A0 =A0 unsigned int _pid; >> =A0 =A0 =A0 unsigned int _uid; >> =A0 =A0 =A0 int _status; >> =A0 =A0 =A0 compat_x32_clock_t _utime; >> =A0 =A0 =A0 compat_x32_clock_t _stime; >> =A0 =A0 } _sigchld; >> ... >> } compat_x32_siginfo_t __attribute__ ((__aligned__ (8))); >> >> struct info is aligned at 8 bytes and type of _utime/_stime is aligned >> at 4 bytes. =A0However, =A0_utime offset is 3 * 4 + 3 * 4 =3D=3D 24 byte= s. So >> in reality, the addresses of _utime/_stime are 8 bytes aligned. =A0There >> are no needs to split _utime and _stime into two 32-bit variables >> since their addresses are 64bits aligned. > > But there is no way you can easily express that syntax with standard C > syntax[1]. =A0That's why you had to resort to using GCC's __attribute__ > syntax. =A0For GDB you'll have to figure out a way to do this without > using __attribute__ ((__aligned__ (...))). > > My recommendation would be to define a compat_x32 structure just for > SIGCHLD (without using a union) and use the normal 32-bit comap > structure for all the other conversions. > This is in amd64-linux-nat.c. All native Linux/amd64 compilers support __attribute__ ((__aligned__ (...))). In any case, I will use a struct wi= th 2 ints. Thanks. --=20 H.J.