]>
git.saurik.com Git - apple/libc.git/blob - tests/nxheap.c
6 #include <darwintest.h>
9 static volatile int pass
;
10 static sigjmp_buf jbuf
;
13 action(int signo
, struct __siginfo
*info
, void *uap
__attribute__((unused
)))
16 pass
= (signo
== SIGBUS
&& info
->si_addr
== heap
);
21 T_DECL(nxheap
, "Non-executable heap", T_META_CHECK_LEAKS(NO
))
23 struct sigaction sa
= {
24 .__sigaction_u
.__sa_sigaction
= action
,
25 .sa_flags
= SA_SIGINFO
,
28 T_ASSERT_POSIX_ZERO(sigaction(SIGBUS
, &sa
, NULL
), NULL
);
30 if (sigsetjmp(jbuf
, 0)) {
35 T_QUIET
; T_ASSERT_NOTNULL((heap
= malloc(1)), NULL
);
37 *heap
= (char)0xc3; // retq
38 ((void (*)(void))heap
)(); // call *%eax