From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 6FC34385780D for ; Tue, 10 Nov 2020 19:54:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6FC34385780D Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AAJh1b6193037 for ; Tue, 10 Nov 2020 14:54:01 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 34qpjs47w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Nov 2020 14:54:01 -0500 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0AAJ3aM3193367 for ; Tue, 10 Nov 2020 14:54:01 -0500 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 34qpjs47vj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Nov 2020 14:54:01 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AAJg7I6020548; Tue, 10 Nov 2020 19:54:00 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma04dal.us.ibm.com with ESMTP id 34nk7a2b7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Nov 2020 19:54:00 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AAJrwIL6881892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 19:53:58 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8592E7805F; Tue, 10 Nov 2020 19:53:58 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E03D77805C; Tue, 10 Nov 2020 19:53:56 +0000 (GMT) Received: from [9.160.65.188] (unknown [9.160.65.188]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 10 Nov 2020 19:53:56 +0000 (GMT) Subject: Re: Question about alignment of struct _Unwind_Exception To: Florian Weimer , Matheus Castanho via Libc-alpha Cc: Peter Bergner , Tulio Magno Quites Machado Filho References: <87tuu42a2v.fsf@oldenburg2.str.redhat.com> <7fed9c8e-1682-2f7f-4c95-5140e5f60ebe@linux.ibm.com> <87ft5h9j26.fsf@oldenburg2.str.redhat.com> From: Matheus Castanho Message-ID: <73b8ae27-0251-7199-c7a7-7a58ec9ebee5@linux.ibm.com> Date: Tue, 10 Nov 2020 16:53:55 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <87ft5h9j26.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-10_07:2020-11-10, 2020-11-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100129 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 19:54:04 -0000 On 11/10/20 3:13 PM, Florian Weimer wrote: > * Matheus Castanho via Libc-alpha: > >> diff --git a/sysdeps/generic/unwind.h b/sysdeps/generic/unwind.h >> index b667a5b652..da1b5e6ca7 100644 >> --- a/sysdeps/generic/unwind.h >> +++ b/sysdeps/generic/unwind.h >> @@ -27,6 +27,8 @@ >> extern "C" { >> #endif >> >> +#include >> + >> /* Level 1: Base ABI */ >> >> /* @@@ The IA-64 ABI uses uint64 throughout. Most places this is >> @@ -83,7 +85,7 @@ struct _Unwind_Exception >> /* @@@ The IA-64 ABI says that this structure must be double-word aligned. >> Taking that literally does not make much sense generically. Instead we >> provide the maximum alignment required by any type for the machine. */ >> -} __attribute__((__aligned__)); >> +} __attribute__((__aligned__(UNWIND_EXCEPTION_ALIGN))); > > Can you use an anonymous union to do just what the comment says, > something like this (untested)? > > struct _Unwind_Exception > { > union > { > struct > { > _Unwind_Exception_Class exception_class; > _Unwind_Exception_Cleanup_Fn exception_cleanup; > _Unwind_Word private_1; > _Unwind_Word private_2; > }; > > /* The IA-64 ABI says that this structure must be double-word > aligned. */ > _Unwind_Word unwind_exception_align[2] > __attributed__ ((aligned (2 * sizeof (_Unwind_Word)))); > }; > }; > > The union ensures that the aligned attribute does not reduce alignment > for the entire struct. > > As discussed, it's an internal ABI change on most targets, but that > should be okay. The dependency on BIGGEST_ALIGNMENT is gone. > > Thanks, > Florian > That sounds like a cleaner solution. I tested it on powerpc64le and it fixes the original issue I saw. All tests passing on x86-64 as well. The diff I tested is below, with a simple typo fix. Please feel free to commit under your name since it you provided the solution =) Thanks, Matheus Castanho ---8<--- diff --git a/sysdeps/generic/unwind.h b/sysdeps/generic/unwind.h index b667a5b652..c229603af3 100644 --- a/sysdeps/generic/unwind.h +++ b/sysdeps/generic/unwind.h @@ -75,15 +75,21 @@ typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception { - _Unwind_Exception_Class exception_class; - _Unwind_Exception_Cleanup_Fn exception_cleanup; - _Unwind_Word private_1; - _Unwind_Word private_2; - - /* @@@ The IA-64 ABI says that this structure must be double-word aligned. - Taking that literally does not make much sense generically. Instead we - provide the maximum alignment required by any type for the machine. */ -} __attribute__((__aligned__)); + union + { + struct + { + _Unwind_Exception_Class exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + _Unwind_Word private_1; + _Unwind_Word private_2; + }; + + /* The IA-64 ABI says that this structure must be double-word aligned. */ + _Unwind_Word unwind_exception_align[2] + __attribute__ ((__aligned__ (2 * sizeof (_Unwind_Word)))); + }; +};