On Sun, Apr 25, 2021 at 08:50:18PM -0500, Bill Schmidt wrote:
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/rop-1.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */

This should only run on ELFv2 currently, no?

> +/* { dg-final { scan-assembler {\mhashst\M} } } */
> +/* { dg-final { scan-assembler {\mhashchk\M} } } */

Maybe check these are emitted only once each?

> +/* { dg-final { scan-assembler {\mhashchkp\M} } } */
> diff --git a/gcc/testsuite/gcc.target/powerpc/rop-3.c 
> b/gcc/testsuite/gcc.target/powerpc/rop-3.c
> new file mode 100644
> index 00000000000..054f94fda99
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c
> @@ -0,0 +1,19 @@
> +/* { dg-do run { target { power10_hw } } } */
> +/* { dg-require-effective-target power10_ok } */
> +/* { dg-require-effective-target powerpc_elfv2 } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */

Why does this need power10_ok?  We always are 64-bit if ELFv2 (and even
if you don't want to depend on that, check for lp64 instead?)

> +/* Verify that ROP-protect instructions execute correctly when a
> +   call is present.  */
> +
> +void __attribute__((noinline)) foo ()
> +{
> +  asm ("");
> +}

Use noipa instead?  noinline should be fine in this super trivial case,
but it is less typing at least ;-)

> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/rop-5.c
> @@ -0,0 +1,17 @@
> +/* { dg-do run { target { power10_hw } } } */
> +/* { dg-require-effective-target power10_ok } */
> +/* { dg-require-effective-target powerpc_elfv2 } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
> +
> +/* Verify that __ROP_PROTECT__ is predefined for -mrop-protect.  */
> +
> +extern void abort (void);
> +
> +int main ()
> +{
> +#ifndef __ROP_PROTECT__
> +  abort ();
> +#endif
> +  return 0;
> +}

Please do this in a compile test instead?

#ifndef __ROP_PROTECT__
  har har har
#endif


Okay for trunk and 11 with such changes.  Thank you!


Segher

Reply via email to