Skip to content

Commit 7c24c9a

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

File tree

1 file changed

+54
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)