From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17517 invoked by alias); 11 Sep 2013 12:56:03 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 17474 invoked by uid 89); 11 Sep 2013 12:56:03 -0000 Received: from e23smtp08.au.ibm.com (HELO e23smtp08.au.ibm.com) (202.81.31.141) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 11 Sep 2013 12:56:03 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_VIA_APNIC,RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 X-HELO: e23smtp08.au.ibm.com Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Sep 2013 22:52:28 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 11 Sep 2013 22:52:26 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 5DA632BB0052 for ; Wed, 11 Sep 2013 22:55:47 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8BCdF5g7733606 for ; Wed, 11 Sep 2013 22:39:15 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8BCtkUU016967 for ; Wed, 11 Sep 2013 22:55:46 +1000 Received: from [9.80.14.61] ([9.80.14.61]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8BCtgqJ016917; Wed, 11 Sep 2013 22:55:44 +1000 Message-ID: <1378904143.3730.46.camel@gnopaine> Subject: Re: [PATCH, PowerPC] Fix PR57949 (ABI alignment issue) From: Bill Schmidt To: Alan Modra Cc: gcc-patches@gcc.gnu.org, libffi-discuss@sourceware.org, dje@gcc.gnu.org Date: Wed, 11 Sep 2013 12:56:00 -0000 In-Reply-To: <20130911113845.GF2643@bubble.grove.modra.org> References: <1376494321.17852.17.camel@oc8801110288.ibm.com> <20130911113845.GF2643@bubble.grove.modra.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13091112-5140-0000-0000-000003D0646E X-SW-Source: 2013/txt/msg00160.txt.bz2 On Wed, 2013-09-11 at 21:08 +0930, Alan Modra wrote: > On Wed, Aug 14, 2013 at 10:32:01AM -0500, Bill Schmidt wrote: > > This fixes a long-standing problem with GCC's implementation of the > > PPC64 ELF ABI. If a structure contains a member requiring 128-bit > > alignment, and that structure is passed as a parameter, the parameter > > currently receives only 64-bit alignment. This is an error, and is > > incompatible with correct code generated by the IBM XL compilers. > > This caused multiple failures in the libffi testsuite: > libffi.call/cls_align_longdouble.c > libffi.call/cls_align_longdouble_split.c > libffi.call/cls_align_longdouble_split2.c > libffi.call/nested_struct5.c > > Fixed by making the same alignment adjustment in libffi to structures > passed by value. Bill, I think your patch needs to go on all active > gcc branches as otherwise we'll need different versions of libffi for > the next gcc releases. Hm, the libffi case is unfortunate. :( The alternative is to leave libffi alone, and require code that calls these interfaces with "bad" structs passed by value to be built using -mcompat-align-parm, which was provided for such compatibility issues. Hopefully there is a small number of cases where this can happen, and this could be documented with libffi and gcc. What do you think? Thanks, Bill > > The following was bootstrapped and regression checked powerpc64-linux. > OK for mainline, and the 4.7 and 4.8 branches when/if Bill's patch > goes in there? > > * src/powerpc/ffi.c (ffi_prep_args64): Align FFI_TYPE_STRUCT. > (ffi_closure_helper_LINUX64): Likewise. > > Index: libffi/src/powerpc/ffi.c > =================================================================== > --- libffi/src/powerpc/ffi.c (revision 202428) > +++ libffi/src/powerpc/ffi.c (working copy) > @@ -462,6 +462,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long > double **d; > } p_argv; > unsigned long gprvalue; > + unsigned long align; > > stacktop.c = (char *) stack + bytes; > gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64; > @@ -532,6 +533,10 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long > #endif > > case FFI_TYPE_STRUCT: > + align = (*ptr)->alignment; > + if (align > 16) > + align = 16; > + next_arg.ul = ALIGN (next_arg.ul, align); > words = ((*ptr)->size + 7) / 8; > if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul) > { > @@ -1349,6 +1354,7 @@ ffi_closure_helper_LINUX64 (ffi_closure *closure, > long i, avn; > ffi_cif *cif; > ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64; > + unsigned long align; > > cif = closure->cif; > avalue = alloca (cif->nargs * sizeof (void *)); > @@ -1399,6 +1405,10 @@ ffi_closure_helper_LINUX64 (ffi_closure *closure, > break; > > case FFI_TYPE_STRUCT: > + align = arg_types[i]->alignment; > + if (align > 16) > + align = 16; > + pst = ALIGN (pst, align); > #ifndef __LITTLE_ENDIAN__ > /* Structures with size less than eight bytes are passed > left-padded. */ > >