1 // RUN: %clang_safestack -fno-stack-protector -D_FORTIFY_SOURCE=0 -g %s -o %t.nossp
2 // RUN: %run %t.nossp 2>&1 | FileCheck --check-prefix=NOSSP %s
4 // RUN: %clang_safestack -fstack-protector-all -D_FORTIFY_SOURCE=0 -g %s -o %t.ssp
5 // RUN: env LIBC_FATAL_STDERR_=1 not --crash %run %t.ssp 2>&1 | \
6 // RUN: FileCheck -check-prefix=SSP %s
8 // Test stack canaries on the unsafe stack.
10 // REQUIRES: stable-runtime
16 __attribute__((noinline
)) void f(unsigned *y
) {
18 char *volatile p
= &x
;
19 char *volatile q
= (char *)y
;
21 assert(q
- p
< 1024); // sanity
22 // This has technically undefined behavior, but we know the actual layout of
23 // the unsafe stack and this should not touch anything important.
24 memset(&x
, 0xab, q
- p
+ sizeof(*y
));
27 int main(int argc
, char **argv
)
32 fprintf(stderr
, "main 1\n");
36 fprintf(stderr
, "main 2\n");