[21/22] aarch64: Fix tests incompatible with GCS
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
Commit Message
From: Matthieu Longo <matthieu.longo@arm.com>
gcc/testsuite/ChangeLog:
* g++.target/aarch64/return_address_sign_ab_exception.C: Update.
* gcc.target/aarch64/eh_return.c: Update.
---
.../return_address_sign_ab_exception.C | 19 +++++++++++++------
gcc/testsuite/gcc.target/aarch64/eh_return.c | 13 +++++++++++++
2 files changed, 26 insertions(+), 6 deletions(-)
Comments
Yury Khrustalev <yury.khrustalev@arm.com> writes:
> From: Matthieu Longo <matthieu.longo@arm.com>
>
> gcc/testsuite/ChangeLog:
>
> * g++.target/aarch64/return_address_sign_ab_exception.C: Update.
> * gcc.target/aarch64/eh_return.c: Update.
OK, thanks.
Richard
> ---
> .../return_address_sign_ab_exception.C | 19 +++++++++++++------
> gcc/testsuite/gcc.target/aarch64/eh_return.c | 13 +++++++++++++
> 2 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/testsuite/g++.target/aarch64/return_address_sign_ab_exception.C b/gcc/testsuite/g++.target/aarch64/return_address_sign_ab_exception.C
> index ead11de7b15..6c79ebf03eb 100644
> --- a/gcc/testsuite/g++.target/aarch64/return_address_sign_ab_exception.C
> +++ b/gcc/testsuite/g++.target/aarch64/return_address_sign_ab_exception.C
> @@ -1,16 +1,28 @@
> /* { dg-do run } */
> /* { dg-options "--save-temps" } */
> /* { dg-require-effective-target arm_v8_3a_bkey_directive } */
> +/* { dg-final { check-function-bodies "**" "" } } */
>
> +/*
> +** _Z5foo_av:
> +** hint 25 // paciasp
> +** ...
> +*/
> __attribute__((target("branch-protection=pac-ret+leaf")))
> int foo_a () {
> throw 22;
> }
>
> +/*
> +** _Z5foo_bv:
> +** hint 27 // pacibsp
> +** ...
> +*/
> __attribute__((target("branch-protection=pac-ret+leaf+b-key")))
> int foo_b () {
> throw 22;
> }
> +/* { dg-final { scan-assembler-times ".cfi_b_key_frame" 1 } } */
>
> int main (int argc, char** argv) {
> try {
> @@ -23,9 +35,4 @@ int main (int argc, char** argv) {
> }
> }
> return 1;
> -}
> -
> -/* { dg-final { scan-assembler-times "paciasp" 1 } } */
> -/* { dg-final { scan-assembler-times "pacibsp" 1 } } */
> -/* { dg-final { scan-assembler-times ".cfi_b_key_frame" 1 } } */
> -
> +}
> \ No newline at end of file
> diff --git a/gcc/testsuite/gcc.target/aarch64/eh_return.c b/gcc/testsuite/gcc.target/aarch64/eh_return.c
> index 32179488085..51b20f784b3 100644
> --- a/gcc/testsuite/gcc.target/aarch64/eh_return.c
> +++ b/gcc/testsuite/gcc.target/aarch64/eh_return.c
> @@ -1,6 +1,19 @@
> /* { dg-do run } */
> /* { dg-options "-O2 -fno-inline" } */
>
> +/* With BTI enabled, this test would crash with SIGILL, Illegal instruction.
> + The 2nd argument of __builtin_eh_return is expected to be an EH handler
> + within a function, rather than a separate function.
> + The current implementation of __builtin_eh_return in AArch64 backend emits a
> + jump instead of branching with LR.
> + The prologue of the handler (i.e. continuation) starts with "bti c" (vs.
> + "bti jc") which is a landing pad type prohibiting jumps, hence the exception
> + at runtime.
> + The current behavior of __builtin_eh_return is considered correct.
> + Consequently, the default option -mbranch-protection=standard needs to be
> + overridden to remove BTI. */
> +/* { dg-additional-options "-mbranch-protection=pac-ret+leaf+gcs" { target { default_branch_protection } } } */
> +
> #include <stdlib.h>
> #include <stdio.h>
@@ -1,16 +1,28 @@
/* { dg-do run } */
/* { dg-options "--save-temps" } */
/* { dg-require-effective-target arm_v8_3a_bkey_directive } */
+/* { dg-final { check-function-bodies "**" "" } } */
+/*
+** _Z5foo_av:
+** hint 25 // paciasp
+** ...
+*/
__attribute__((target("branch-protection=pac-ret+leaf")))
int foo_a () {
throw 22;
}
+/*
+** _Z5foo_bv:
+** hint 27 // pacibsp
+** ...
+*/
__attribute__((target("branch-protection=pac-ret+leaf+b-key")))
int foo_b () {
throw 22;
}
+/* { dg-final { scan-assembler-times ".cfi_b_key_frame" 1 } } */
int main (int argc, char** argv) {
try {
@@ -23,9 +35,4 @@ int main (int argc, char** argv) {
}
}
return 1;
-}
-
-/* { dg-final { scan-assembler-times "paciasp" 1 } } */
-/* { dg-final { scan-assembler-times "pacibsp" 1 } } */
-/* { dg-final { scan-assembler-times ".cfi_b_key_frame" 1 } } */
-
+}
\ No newline at end of file
@@ -1,6 +1,19 @@
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline" } */
+/* With BTI enabled, this test would crash with SIGILL, Illegal instruction.
+ The 2nd argument of __builtin_eh_return is expected to be an EH handler
+ within a function, rather than a separate function.
+ The current implementation of __builtin_eh_return in AArch64 backend emits a
+ jump instead of branching with LR.
+ The prologue of the handler (i.e. continuation) starts with "bti c" (vs.
+ "bti jc") which is a landing pad type prohibiting jumps, hence the exception
+ at runtime.
+ The current behavior of __builtin_eh_return is considered correct.
+ Consequently, the default option -mbranch-protection=standard needs to be
+ overridden to remove BTI. */
+/* { dg-additional-options "-mbranch-protection=pac-ret+leaf+gcs" { target { default_branch_protection } } } */
+
#include <stdlib.h>
#include <stdio.h>