Skip to content

Commit 058166a

Browse files
committed
Test the coexistence of 'stack-protector' and 'safe-stack'
1 parent be28e7f commit 058166a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//@ revisions: all strong none safestack safestack_strong safestack_all
2+
//@ assembly-output: emit-asm
3+
//@ only-x86_64-unknown-linux-gnu
4+
//@ add-core-stubs
5+
//@ [all] compile-flags: -Z stack-protector=all
6+
//@ [strong] compile-flags: -Z stack-protector=strong
7+
//@ [none] compile-flags: -Z stack-protector=none
8+
//@ [safestack] compile-flags: -Z stack-protector=none -Z sanitizer=safestack
9+
//@ [safestack_strong] compile-flags: -Z stack-protector=strong -Z sanitizer=safestack
10+
//@ [safestack_all] compile-flags: -Z stack-protector=all -Z sanitizer=safestack
11+
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
12+
13+
#![feature(unsized_fn_params)]
14+
#![crate_type = "lib"]
15+
#![feature(no_core)]
16+
#![no_core]
17+
#![no_std]
18+
19+
extern crate minicore;
20+
21+
extern "C" {
22+
fn test4spss(p: *mut u8);
23+
}
24+
25+
// CHECK-LABEL: test1{{:|\[}}
26+
#[no_mangle]
27+
pub unsafe fn test1(x: *mut u8) -> u8 {
28+
let mut buf: [u8; 64] = [0; 64];
29+
30+
let p = &mut buf as *mut [u8; 64] as *mut u8;
31+
32+
*p = 42;
33+
34+
test4spss(p);
35+
36+
*x = *p;
37+
38+
*p
39+
40+
// none-NOT: __stack_chk_fail
41+
// strong: __stack_chk_fail
42+
// all: __stack_chk_fail
43+
44+
// safestack: __safestack_unsafe_stack_ptr
45+
// safestack-NOT: __stack_chk_fail
46+
47+
// safestack_strong: __safestack_unsafe_stack_ptr
48+
// safestack_strong: __stack_chk_fail
49+
50+
// safestack_all: __safestack_unsafe_stack_ptr
51+
// safestack_all: __stack_chk_fail
52+
}

0 commit comments

Comments
 (0)