From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2049) id 942453858C56; Thu, 13 Oct 2022 11:58:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 942453858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665662330; bh=6LfVxP/RtZ0s9Jd93rG7ExgiSa88/Glvb8jlr5DGm+M=; h=From:To:Subject:Date:From; b=BIr7dl2cQEccoYqX2WnVFgb/Y51ULIoqUJuOEIOMKoyLqAYabn3s4ig14BVqLs1m9 aiKk91b6Z0DixIQX4QUxwI5/ZKNh9wmtqcq15KpoxMdbrMkBpm3XW6PkA4ykPcnOEO V4ZPFsGi6VChtTaz7iZcqrVccU+nxhVDcST20oqU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthew Malcomson To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Testism adjustments for pure capability X-Act-Checkin: gcc X-Git-Author: Matthew Malcomson X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 78df431c4dd59a636106f47a04c684be6c7dc713 X-Git-Newrev: d6a3de7701325735daac7a49005c978cc28e97da Message-Id: <20221013115850.942453858C56@sourceware.org> Date: Thu, 13 Oct 2022 11:58:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d6a3de7701325735daac7a49005c978cc28e97da commit d6a3de7701325735daac7a49005c978cc28e97da Author: Matthew Malcomson Date: Thu Oct 13 12:57:14 2022 +0100 Testism adjustments for pure capability array25.C This testcase uses a global buffer as its place to allocate a structure. During initialisation on unoptimised code, the structure initialises its sub-structures with zeros. Since the sub-structure contains a pointer that includes storing a capability. Said global buffer is not aligned. Hence we get a BUS error. Here we ensure that the alignment is specified for pure capability targets. struct-layout-1.exp This testcase generates multiple different structures with different alignment behaviours. It purposefully generates misaligned pointers. These cause failures on purecap. This is a G++ variation of the same problem that we had in GCC, and we simply avoid the tests in the same way that we avoided them in GCC. g++.abi/vtable2.C This testcase uses ptrdiff_t for vtable entries. On purecap we have capability-sized and capability-aligned vtable entries. There seems to be at least one existing target architecture (see gcc/config/darwin.h) which uses different types for ptrdiff_t and intptr_t (although I haven't checked whether these types boil down to the same size data on hardware), so rather than change the testcase for existing architectures we only change the type for purecap. Diff: --- gcc/testsuite/g++.dg/compat/struct-layout-1.exp | 5 +++++ gcc/testsuite/g++.dg/init/array25.C | 3 +++ gcc/testsuite/g++.old-deja/g++.abi/vtable2.C | 16 +++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/g++.dg/compat/struct-layout-1.exp b/gcc/testsuite/g++.dg/compat/struct-layout-1.exp index f2a20aafafd..8fc799f794e 100644 --- a/gcc/testsuite/g++.dg/compat/struct-layout-1.exp +++ b/gcc/testsuite/g++.dg/compat/struct-layout-1.exp @@ -17,6 +17,11 @@ # This file was written by Jakub Jelinek, # Based on compat.exp writte by Janis Johnson, +# The random generator in this testsuite may deliberately underalign +# capabilities in a packed struct. This is currently not supported. +if { [check_effective_target_cheri_capability_pure] } then { + return +} # Test interoperability of two compilers that follow the same ABI. # diff --git a/gcc/testsuite/g++.dg/init/array25.C b/gcc/testsuite/g++.dg/init/array25.C index 1ab2725d7cf..f738d2e67c0 100644 --- a/gcc/testsuite/g++.dg/init/array25.C +++ b/gcc/testsuite/g++.dg/init/array25.C @@ -33,6 +33,9 @@ inline void *operator new (__SIZE_TYPE__ size, void *p) return p; } +#ifdef __CHERI_PURE_CAPABILITY__ +__attribute__((aligned(16))) +#endif char heap[sizeof(elt[500])]; int main () diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C index 96533e09218..62fbd76ce20 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C @@ -6,6 +6,12 @@ #include +#ifdef __CHERI_PURE_CAPABILITY__ +typedef __INTPTR_TYPE__ vtable_type; +#else +typedef ptrdiff_t vtable_type; +#endif + struct S0 { virtual void s0 (); @@ -149,14 +155,14 @@ extern "C" { #ifdef _LP64 #define CMP_VPTR(A, B) (*(unsigned long *)(*(A)+16) == *(unsigned long *)((unsigned long)(B)+16)) #else -#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B)) +#define CMP_VPTR(A, B) (*(A) == (vtable_type)(B)) #endif /* _LP64 */ #else extern "C" { unsigned int __canonicalize_funcptr_for_compare (void*); } #define CMP_VPTR(A, B) (__canonicalize_funcptr_for_compare(*(void **)A) == __canonicalize_funcptr_for_compare((void *)B)) #endif /* __hpux__ */ #else -#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B)) +#define CMP_VPTR(A, B) (*(A) == (vtable_type)(B)) #endif /* __hppa__ */ #define INC_VPTR(A) ((A) += 1) #define INC_VDATA(A,N) ((A) += (N)) @@ -165,11 +171,11 @@ extern "C" { unsigned int __canonicalize_funcptr_for_compare (void*); } int main () { S4 s4; - ptrdiff_t **vptr; - ptrdiff_t *vtbl; + vtable_type **vptr; + vtable_type *vtbl; // Set vtbl to point at the beginning of S4's primary vtable. - vptr = (ptrdiff_t **) &s4; + vptr = (vtable_type **) &s4; vtbl = *vptr; INC_VDATA (vtbl, -5);