1 /* $NetBSD: tramptest.c,v 1.1 2003/12/10 13:24:59 drochner Exp $ */
7 * This test checks that the stack has no execute permission.
8 * It depends on the fact that gcc puts trampoline code for
9 * nested functions on the stack, at least on some architectures.
10 * (On the other architectures, the test will fail, as on platforms
11 * where execution permissions cannot be controlled.)
12 * Actually, it would be better if gcc wouldn't use stack trampolines,
13 * at all, but for now it allows for an easy portable check whether the
14 * stack is executable.
18 __enable_execute_stack()
20 /* replace gcc's internal function by a noop */
24 buserr(int s
, siginfo_t
*si
, void *ctx
)
27 if (s
!= SIGSEGV
|| si
->si_code
!= SEGV_ACCERR
)
52 sa
.sa_sigaction
= buserr
;
53 sigemptyset(&sa
.sa_mask
);
54 sa
.sa_flags
= SA_SIGINFO
;
55 sigaction(SIGSEGV
, &sa
, 0);