1 /* Check that GCC does .save and .cfi_offset directives with RA_AUTH_CODE pseudo hard-register. */
2 /* { dg-do compile } */
3 /* { dg-require-effective-target mbranch_protection_ok } */
4 /* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */
5 /* { dg-options "-march=armv8.1-m.main+mve+pacbti -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard -fasynchronous-unwind-tables -g -O0" } */
6
7 #include "stdio.h"
8
9 __attribute__((noinline)) int
10 fn1 (int a)
11 {
12 const char *fmt = "branch-protection";
13 int fun1(int x,const char *fmt,int c,int d)
14 {
15 printf("string = %s\n",fmt);
16 return x+c+d;
17 }
18 return fun1(a,fmt,10,10);
19 }
20
21 int main (void)
22 {
23 return fn1 (40);
24 }
25
26 /* { dg-final { scan-assembler-times "\.pacspval" 1 } } */
27 /* { dg-final { scan-assembler-times "pac ip, lr, sp" 3 } } */
28 /* { dg-final { scan-assembler-times "\.cfi_register 143, 12" 3 } } */
29 /* { dg-final { scan-assembler-times "\.save {r7, ra_auth_code, lr}" 2 } } */
30 /* { dg-final { scan-assembler-times "\.cfi_offset 143, -8" 2 } } */
31 /* { dg-final { scan-assembler-times "\.save {r3, r7, ra_auth_code, lr}" 1 } } */
32 /* { dg-final { scan-assembler-times "\.cfi_offset 143, -12" 1 } } */