1 /* This test needs to use setrlimit to set the stack size, so it can
3 /* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */
4 /* { dg-require-effective-target cet } */
5 /* { dg-require-effective-target split_stack } */
6 /* { dg-options "-fsplit-stack -fcf-protection" } */
10 #include <sys/types.h>
11 #include <sys/resource.h>
13 /* Use a noinline function to ensure that the buffer is not removed
15 static void use_buffer (char *buf
, size_t) __attribute__ ((noinline
));
17 use_buffer (char *buf
, size_t c
)
21 for (i
= 0; i
< c
; ++i
)
25 /* Each recursive call uses 10 * i bytes. We call it 1000 times,
26 using a total of 5,000,000 bytes. If -fsplit-stack is not working,
27 that will overflow our stack limit. */
36 use_buffer (buf
, 10 * i
);
41 /* Same thing, using alloca. */
46 char *buf
= alloca (10 * i
);
50 use_buffer (buf
, 10 * i
);
60 /* We set a stack limit because we are usually invoked via make, and
61 make sets the stack limit to be as large as possible. */
62 r
.rlim_cur
= 8192 * 1024;
63 r
.rlim_max
= 8192 * 1024;
64 if (setrlimit (RLIMIT_STACK
, &r
) != 0)