target/arm: Update CNTP for PREDDESC
[qemu/ar7.git] / tests / tcg / aarch64 / bti-crt.inc.c
blob47805f4e35bb507111439b5ee26574a242053cce
1 /*
2 * Minimal user-environment for testing BTI.
4 * Normal libc is not (yet) built with BTI support enabled,
5 * and so could generate a BTI TRAP before ever reaching main.
6 */
8 #include <stdlib.h>
9 #include <signal.h>
10 #include <ucontext.h>
11 #include <asm/unistd.h>
13 int main(void);
15 void _start(void)
17 exit(main());
20 void exit(int ret)
22 register int x0 __asm__("x0") = ret;
23 register int x8 __asm__("x8") = __NR_exit;
25 asm volatile("svc #0" : : "r"(x0), "r"(x8));
26 __builtin_unreachable();
30 * Irritatingly, the user API struct sigaction does not match the
31 * kernel API struct sigaction. So for simplicity, isolate the
32 * kernel ABI here, and make this act like signal.
34 void signal_info(int sig, void (*fn)(int, siginfo_t *, ucontext_t *))
36 struct kernel_sigaction {
37 void (*handler)(int, siginfo_t *, ucontext_t *);
38 unsigned long flags;
39 unsigned long restorer;
40 unsigned long mask;
41 } sa = { fn, SA_SIGINFO, 0, 0 };
43 register int x0 __asm__("x0") = sig;
44 register void *x1 __asm__("x1") = &sa;
45 register void *x2 __asm__("x2") = 0;
46 register int x3 __asm__("x3") = sizeof(unsigned long);
47 register int x8 __asm__("x8") = __NR_rt_sigaction;
49 asm volatile("svc #0"
50 : : "r"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x8) : "memory");