rs6000: testsuite: Add rop_ok effective-target function
Commit Message
This patch adds a new effective-target function that tests whether
it is safe to emit the ROP-protect instructions and updates the
ROP test cases to use it.
Segher, as we discussed offline, this uses the double [] which you said
isn't needed in general regex's, but for some reason is needed in the gcc
testsuite regex.
Tested on powerpc64le*-linux with no regressions. Ok for mainline?
Peter
gcc/testsuite/
* lib/target-supports.exp (check_effective_target_rop_ok): New function.
* gcc.target/powerpc/rop-1.c: Use it.
* gcc.target/powerpc/rop-2.c: Likewise.
* gcc.target/powerpc/rop-3.c: Likewise.
* gcc.target/powerpc/rop-4.c: Likewise.
* gcc.target/powerpc/rop-5.c: Likewise.
Comments
Hi!
On Thu, Nov 11, 2021 at 04:12:08PM -0600, Peter Bergner wrote:
> This patch adds a new effective-target function that tests whether
> it is safe to emit the ROP-protect instructions and updates the
> ROP test cases to use it.
>
> Segher, as we discussed offline, this uses the double [] which you said
> isn't needed in general regex's, but for some reason is needed in the gcc
> testsuite regex.
> +proc check_effective_target_rop_ok { } {
> + return [check_effective_target_power10_ok]
> + && [check_effective_target_powerpc_elfv2]
> +}
That's not a regular expression ;-)
It is easiest to put [] around each function call, it will take && as
argument if you write is as [checkA && checkB] . I'm not sure what I
meant, sorry :-) Writing it as you did is simpler and more idiomatic
than other ways of achieving this.
> Tested on powerpc64le*-linux with no regressions. Ok for mainline?
What can "*" be there other than the empty string? Which valuse of "*"
did you test? :-)
> gcc/testsuite/
> * lib/target-supports.exp (check_effective_target_rop_ok): New function.
> * gcc.target/powerpc/rop-1.c: Use it.
> * gcc.target/powerpc/rop-2.c: Likewise.
> * gcc.target/powerpc/rop-3.c: Likewise.
> * gcc.target/powerpc/rop-4.c: Likewise.
> * gcc.target/powerpc/rop-5.c: Likewise.
> --- a/gcc/testsuite/gcc.target/powerpc/rop-3.c
> +++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c
> @@ -1,5 +1,5 @@
> /* { dg-do run { target { power10_hw } } } */
> -/* { dg-require-effective-target powerpc_elfv2 } */
> +/* { dg-require-effective-target rop_ok } */
> /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
Okay for trunk. Thanks!
Segher
On 12/2/21 5:15 PM, Segher Boessenkool wrote:
>> Tested on powerpc64le*-linux with no regressions. Ok for mainline?
>
> What can "*" be there other than the empty string? Which valuse of "*"
> did you test? :-)
Heh, too used to typing powerpc64*-linux. Yeah, in this case * == "".
> Okay for trunk. Thanks!
Thanks, pushed.
Peter
@@ -6625,6 +6625,13 @@ proc check_effective_target_powerpc_elfv2 { } {
}
}
+# Return 1 if this is a PowerPC target supporting -mrop-protect
+
+proc check_effective_target_rop_ok { } {
+ return [check_effective_target_power10_ok]
+ && [check_effective_target_powerpc_elfv2]
+}
+
# The VxWorks SPARC simulator accepts only EM_SPARC executables and
# chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
# test environment appears to run executables on such a simulator.
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
/* Verify that ROP-protect instructions are inserted when a
call is present. */
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect -mprivileged" } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
/* Verify that privileged ROP-protect instructions are inserted when a
call is present. */
@@ -1,5 +1,5 @@
/* { dg-do run { target { power10_hw } } } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
/* Verify that ROP-protect instructions execute correctly when a
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
/* Verify that no ROP-protect instructions are inserted when no
call is present. */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-require-effective-target powerpc_elfv2 } */
+/* { dg-require-effective-target rop_ok } */
/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
/* Verify that __ROP_PROTECT__ is predefined for -mrop-protect. */