1 #include "../multiarch/noexec.c.inc"
3 static void *arch_mcontext_pc(const mcontext_t
*ctx
)
5 return (void *)ctx
->gregs
[REG_RIP
];
8 int arch_mcontext_arg(const mcontext_t
*ctx
)
10 return ctx
->gregs
[REG_RDI
];
13 static void arch_flush(void *p
, int len
)
17 extern char noexec_1
[];
18 extern char noexec_2
[];
19 extern char noexec_end
[];
22 " movq $1,%rdi\n" /* %rdi is 0 on entry, set 1. */
24 " movq $2,%rdi\n" /* %rdi is 0/1; set 2. */
30 struct noexec_test noexec_tests
[] = {
32 .name
= "fallthrough",
33 .test_code
= noexec_1
,
34 .test_len
= noexec_end
- noexec_1
,
35 .page_ofs
= noexec_1
- noexec_2
,
36 .entry_ofs
= noexec_1
- noexec_2
,
43 .test_code
= noexec_1
,
44 .test_len
= noexec_end
- noexec_1
,
45 .page_ofs
= noexec_1
- noexec_2
,
52 .name
= "fallthrough [cross]",
53 .test_code
= noexec_1
,
54 .test_len
= noexec_end
- noexec_1
,
55 .page_ofs
= noexec_1
- noexec_2
- 2,
56 .entry_ofs
= noexec_1
- noexec_2
- 2,
58 .expected_pc_ofs
= -2,
62 .name
= "jump [cross]",
63 .test_code
= noexec_1
,
64 .test_len
= noexec_end
- noexec_1
,
65 .page_ofs
= noexec_1
- noexec_2
- 2,
68 .expected_pc_ofs
= -2,
73 return test_noexec(noexec_tests
,
74 sizeof(noexec_tests
) / sizeof(noexec_tests
[0]));