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
) __attribute__ ((noinline
));
17 use_buffer (char *buf
)
22 /* Each recursive call uses 10,000 bytes. We call it 1000 times,
23 using a total of 10,000,000 bytes. If -fsplit-stack is not
24 working, that will overflow our stack limit. */
33 if (va_arg (ap
, int) != 1
34 || va_arg (ap
, int) != 2
35 || va_arg (ap
, int) != 3
36 || va_arg (ap
, int) != 4
37 || va_arg (ap
, int) != 5
38 || va_arg (ap
, int) != 6
39 || va_arg (ap
, int) != 7
40 || va_arg (ap
, int) != 8
41 || va_arg (ap
, int) != 9
42 || va_arg (ap
, int) != 10)
48 down (i
- 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
57 /* We set a stack limit because we are usually invoked via make, and
58 make sets the stack limit to be as large as possible. */
59 r
.rlim_cur
= 8192 * 1024;
60 r
.rlim_max
= 8192 * 1024;
61 if (setrlimit (RLIMIT_STACK
, &r
) != 0)
63 down (1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);