Skip to content

Commit 8d0b5a9

Browse files
committed
Check the coexistence of stack-protector and safe-stack.
1 parent 383b9c4 commit 8d0b5a9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@ revisions: all strong none safestack safestack_strong safestack_all
2+
//@ assembly-output: emit-asm
3+
//@ ignore-msvc safestack sanitizer not supported
4+
//@ ignore-nvptx64 stack protector is not supported
5+
//@ ignore-wasm32-bare
6+
//@ ignore-aarch64
7+
//@ [all] compile-flags: -Z stack-protector=all
8+
//@ [strong] compile-flags: -Z stack-protector=strong
9+
//@ [none] compile-flags: -Z stack-protector=none
10+
//@ [safestack] compile-flags: -Z stack-protector=none -Z sanitizer=safestack
11+
//@ [safestack_strong] compile-flags: -Z stack-protector=strong -Z sanitizer=safestack
12+
//@ [safestack_all] compile-flags: -Z stack-protector=all -Z sanitizer=safestack
13+
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
14+
15+
#![crate_type = "lib"]
16+
#![allow(internal_features)]
17+
#![feature(unsized_fn_params)]
18+
19+
// Check the coexistence of stack-protector and safe-stack.
20+
// CHECK-LABEL: test1{{:|\[}}
21+
#[no_mangle]
22+
pub unsafe fn test1(src: *const u8, len: usize) -> u8 {
23+
let mut buf = [0u8; 64];
24+
std::ptr::copy_nonoverlapping(src, buf.as_mut_ptr(), len.min(buf.len()));
25+
buf[0]
26+
27+
// none-NOT: __stack_chk_fail
28+
// strong: __stack_chk_fail
29+
// all: __stack_chk_fail
30+
31+
// safestack: __safestack_unsafe_stack_ptr
32+
// safestack-NOT: __stack_chk_fail
33+
34+
// safestack_strong: __safestack_unsafe_stack_ptr
35+
// safestack_strong: __stack_chk_fail
36+
37+
// safestack_all: __safestack_unsafe_stack_ptr
38+
// safestack_all: __stack_chk_fail
39+
}

0 commit comments

Comments
 (0)