2 * Branch target identification, basic notskip cases.
5 #include "bti-crt.inc.c"
7 static void skip2_sigill(int sig
, siginfo_t
*info
, ucontext_t
*uc
)
9 uc
->uc_mcontext
.pc
+= 8;
10 uc
->uc_mcontext
.pstate
= 1;
14 #define BTI_N "hint #32"
15 #define BTI_C "hint #34"
16 #define BTI_J "hint #36"
17 #define BTI_JC "hint #38"
19 #define BTYPE_1(DEST) \
20 asm("mov %0,#1; adr x16, 1f; br x16; 1: " DEST "; mov %0,#0" \
21 : "=r"(skipped) : : "x16")
23 #define BTYPE_2(DEST) \
24 asm("mov %0,#1; adr x16, 1f; blr x16; 1: " DEST "; mov %0,#0" \
25 : "=r"(skipped) : : "x16", "x30")
27 #define BTYPE_3(DEST) \
28 asm("mov %0,#1; adr x15, 1f; br x15; 1: " DEST "; mov %0,#0" \
29 : "=r"(skipped) : : "x15")
31 #define TEST(WHICH, DEST, EXPECT) \
32 do { WHICH(DEST); fail += skipped ^ EXPECT; } while (0)
40 /* Signal-like with SA_SIGINFO. */
41 signal_info(SIGILL
, skip2_sigill
);
43 TEST(BTYPE_1
, NOP
, 1);
44 TEST(BTYPE_1
, BTI_N
, 1);
45 TEST(BTYPE_1
, BTI_C
, 0);
46 TEST(BTYPE_1
, BTI_J
, 0);
47 TEST(BTYPE_1
, BTI_JC
, 0);
49 TEST(BTYPE_2
, NOP
, 1);
50 TEST(BTYPE_2
, BTI_N
, 1);
51 TEST(BTYPE_2
, BTI_C
, 0);
52 TEST(BTYPE_2
, BTI_J
, 1);
53 TEST(BTYPE_2
, BTI_JC
, 0);
55 TEST(BTYPE_3
, NOP
, 1);
56 TEST(BTYPE_3
, BTI_N
, 1);
57 TEST(BTYPE_3
, BTI_C
, 1);
58 TEST(BTYPE_3
, BTI_J
, 0);
59 TEST(BTYPE_3
, BTI_JC
, 0);