public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthew Malcomson <matmal01@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Testism adjustments for pure capability Date: Thu, 13 Oct 2022 11:58:50 +0000 (GMT) [thread overview] Message-ID: <20221013115850.942453858C56@sourceware.org> (raw) https://gcc.gnu.org/g:d6a3de7701325735daac7a49005c978cc28e97da commit d6a3de7701325735daac7a49005c978cc28e97da Author: Matthew Malcomson <matthew.malcomson@arm.com> 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, <jakub@redhat.com> # Based on compat.exp writte by Janis Johnson, <janis187@us.ibm.com> +# 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 <stddef.h> +#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);
reply other threads:[~2022-10-13 11:58 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221013115850.942453858C56@sourceware.org \ --to=matmal01@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).