From nobody Wed Mar 09 17:25:50 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BBC5E1A0BFD6; Wed, 9 Mar 2022 17:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KDJxp3vB9z4kSl; Wed, 9 Mar 2022 17:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646846750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I3ITon0IctPjaXrsPkPPPexGlL27XdZTZ8NdxgGcW0g=; b=yZ8wXrOW1V/RjjqNCaNB0Sd3QNoyNtQPQDuVQsrfoD/8Ov4NpB3JhO2WXBWAOEBx1bvhQ7 nFBGiMCNMMYn7leODfkkn5kLhRV4PkO/eZig0wGuvr0LYa0DSESFPkKgF7N1R700GfnLLZ miWVM6zzX8IIXR7MCu+SwMd+oFadSwXKrb0psjf32fBOlqnVfFNGTy/MZ2npNY4GnnG3kQ K0uSkXjffAljULsZD4bcl+bqM5glJosbwJ0n2jM2FP2ku8m8yJC3ttA3fSbXjl3aPjF+HE unGOUHD49QONLp5+YxxYbiM8qh9YCZLwED6Q9XWmzii4utwKcZHHri7X4aejDQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 657A215295; Wed, 9 Mar 2022 17:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 229HPo1t080008; Wed, 9 Mar 2022 17:25:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 229HPoAr080007; Wed, 9 Mar 2022 17:25:50 GMT (envelope-from git) Date: Wed, 9 Mar 2022 17:25:50 GMT Message-Id: <202203091725.229HPoAr080007@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 72df847a94bc - main - Remove compat hacks from libcxxrt's _Unwind_Exception List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72df847a94bccee245a3316e4f848482b9ac2ac2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646846750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I3ITon0IctPjaXrsPkPPPexGlL27XdZTZ8NdxgGcW0g=; b=haUJPZMzzbt9oybA6qHye+N+zPvRSV8VGpzhlpckugAECZnzzIG456R+Bxov0R2gcO6Zsv VYj3Cf7aAOOeXO/rLJEI29FH/+smm75IhnOdmuDJ0nf2D3751SyvWf83+OpcWtqR0/mIJe 7Cfb6Ky2l+B4qbDKypeXla4aX2ubXkywZKyaxF1FfqYAJb+Xirf2n9S0iTfXGLq4SFd49E nthOeGzc/s6fi2OrX3Wqdzqjl43pQ48PFlvm0bh5BpCVvbFol9pMoE/EC36nZmhr27QIPE DZyEQUzTH5oldEnA3m3PGsqmrB8m1NSIBk15eEtKyIYzDnYq3HFbX2VWNyTtnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646846750; a=rsa-sha256; cv=none; b=bGUcjDLU952gstPJ2ERldqFGCQP0953Nc9JfKtaou1+Z1iG6IyyiI0Lgy8i/VlspD1JpF4 3uA5ZZSCstSz5fZwnStn+G2r+XJoheE1zYUr3ZCyIvR5fGaOFwbNFcayi+5YoJsIAzdOu2 KqMmS8AIIeJp3Zn74EfpgQ5tE7E274QMwl1Txv233ToZ2chpYIi7xhNjBYdISPrGHE7ihP NuVFzr98aPrWqXOK2NVu7B8HDakBcJqNB5KR0cKBB01eCluNIQ7gtewWSURk4E1akcBuGl pVy1MBfjlm2Oid2nHUzJrlrTjdjnm1M0Q0C/sBJttGnn9Bo/d+YYpYF9rUs5sw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=72df847a94bccee245a3316e4f848482b9ac2ac2 commit 72df847a94bccee245a3316e4f848482b9ac2ac2 Author: Dimitry Andric AuthorDate: 2022-03-08 21:53:16 +0000 Commit: Dimitry Andric CommitDate: 2022-03-09 17:25:18 +0000 Remove compat hacks from libcxxrt's _Unwind_Exception This reverts 9097e3cbcac4, which was in itself a revert of upstream libcxxrt commits 88bdf6b290da ("Specify double-word alignment for ARM unwind") and b96169641f79 ("Updated Itanium unwind"), and a reapplication of our commit 3c4fd2463bb2 ("libcxxrt: add padding in __cxa_allocate_* to fix alignment"). The editors/libreoffice port will be patched to be able to cope with the standards-compliant alignment of _Unwind_Exception and consequently, that of __cxa_exception. The layouts and sizes of these structures should then be completely the same for libcxxrt, libunwind and libc++abi. PR: 262008 Reviewed by: emaste, jhb, theraven MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D34488 --- contrib/libcxxrt/exception.cc | 30 ++++++------------------------ contrib/libcxxrt/unwind-arm.h | 2 +- contrib/libcxxrt/unwind-itanium.h | 9 ++++++--- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc index 0de878e9e6db..0fb26ddb4ed2 100644 --- a/contrib/libcxxrt/exception.cc +++ b/contrib/libcxxrt/exception.cc @@ -572,19 +572,6 @@ static void free_exception(char *e) } } -#ifdef __LP64__ -/** - * There's an ABI bug in __cxa_exception: unwindHeader requires 16-byte - * alignment but it was broken by the addition of the referenceCount. - * The unwindHeader is at offset 0x58 in __cxa_exception. In order to keep - * compatibility with consumers of the broken __cxa_exception, explicitly add - * padding on allocation (and account for it on free). - */ -static const int exception_alignment_padding = 8; -#else -static const int exception_alignment_padding = 0; -#endif - /** * Allocates an exception structure. Returns a pointer to the space that can * be used to store an object of thrown_size bytes. This function will use an @@ -593,19 +580,16 @@ static const int exception_alignment_padding = 0; */ extern "C" void *__cxa_allocate_exception(size_t thrown_size) { - size_t size = exception_alignment_padding + sizeof(__cxa_exception) + - thrown_size; + size_t size = thrown_size + sizeof(__cxa_exception); char *buffer = alloc_or_die(size); - return buffer + exception_alignment_padding + sizeof(__cxa_exception); + return buffer+sizeof(__cxa_exception); } extern "C" void *__cxa_allocate_dependent_exception(void) { - size_t size = exception_alignment_padding + - sizeof(__cxa_dependent_exception); + size_t size = sizeof(__cxa_dependent_exception); char *buffer = alloc_or_die(size); - return buffer + exception_alignment_padding + - sizeof(__cxa_dependent_exception); + return buffer+sizeof(__cxa_dependent_exception); } /** @@ -633,8 +617,7 @@ extern "C" void __cxa_free_exception(void *thrown_exception) } } - free_exception(reinterpret_cast(ex) - - exception_alignment_padding); + free_exception(reinterpret_cast(ex)); } static void releaseException(__cxa_exception *exception) @@ -661,8 +644,7 @@ void __cxa_free_dependent_exception(void *thrown_exception) { releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex))); } - free_exception(reinterpret_cast(ex) - - exception_alignment_padding); + free_exception(reinterpret_cast(ex)); } /** diff --git a/contrib/libcxxrt/unwind-arm.h b/contrib/libcxxrt/unwind-arm.h index 6eb9d9e45981..ec81237e573b 100644 --- a/contrib/libcxxrt/unwind-arm.h +++ b/contrib/libcxxrt/unwind-arm.h @@ -97,7 +97,7 @@ struct _Unwind_Exception } pr_cache; /** Force alignment of next item to 8-byte boundary */ long long int :0; -}; +} __attribute__((__aligned__(8))); /* Unwinding functions */ _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *ucbp); diff --git a/contrib/libcxxrt/unwind-itanium.h b/contrib/libcxxrt/unwind-itanium.h index 1ee0cf0e81c4..199d91de283d 100644 --- a/contrib/libcxxrt/unwind-itanium.h +++ b/contrib/libcxxrt/unwind-itanium.h @@ -79,9 +79,12 @@ struct _Unwind_Exception { uint64_t exception_class; _Unwind_Exception_Cleanup_Fn exception_cleanup; - unsigned long private_1; - unsigned long private_2; - } ; + uintptr_t private_1; + uintptr_t private_2; +#if __SIZEOF_POINTER__ == 4 + uint32_t reserved[3]; +#endif + } __attribute__((__aligned__)); extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *); extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,