]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/safestack/canary.c
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: not --crash %run %t.ssp 2>&1 | FileCheck -check-prefix=SSP %s
7 // Test stack canaries on the unsafe stack.
9 // REQUIRES: stable-runtime
15 __attribute__((noinline
)) void f(unsigned *y
) {
17 char *volatile p
= &x
;
18 char *volatile q
= (char *)y
;
20 assert(q
- p
< 1024); // sanity
21 // This has technically undefined behavior, but we know the actual layout of
22 // the unsafe stack and this should not touch anything important.
23 memset(&x
, 0xab, q
- p
+ sizeof(*y
));
26 int main(int argc
, char **argv
)
31 fprintf(stderr
, "main 1\n");
35 fprintf(stderr
, "main 2\n");