]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Fix tests incompatible with GCS
authorMatthieu Longo <matthieu.longo@arm.com>
Thu, 14 Nov 2024 16:15:14 +0000 (16:15 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 14 Nov 2024 16:15:14 +0000 (16:15 +0000)
gcc/testsuite/ChangeLog:

* g++.target/aarch64/return_address_sign_ab_exception.C: Update.
* gcc.target/aarch64/eh_return.c: Update.

gcc/testsuite/g++.target/aarch64/return_address_sign_ab_exception.C
gcc/testsuite/gcc.target/aarch64/eh_return.c

index ead11de7b15dd82571345c9cc079e0be3c567b48..6c79ebf03eb1fe3b4db68992f38bf581bd917834 100644 (file)
@@ -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
index 32179488085ed4c84aa77007565c875d09c4197c..51b20f784b31058ad8d8c8e22e6cf2fa406144cd 100644 (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>