forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack-protector-safe-stack.rs
More file actions
54 lines (41 loc) · 1.43 KB
/
stack-protector-safe-stack.rs
File metadata and controls
54 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//@ add-minicore
//@ revisions: all strong none safestack safestack_strong safestack_all
//@ assembly-output: emit-asm
//@ only-x86_64-unknown-linux-gnu
//@ [all] compile-flags: -Z stack-protector=all
//@ [strong] compile-flags: -Z stack-protector=strong
//@ [none] compile-flags: -Z stack-protector=none
//@ [safestack] compile-flags: -Z stack-protector=none -Z sanitizer=safestack
//@ [safestack_strong] compile-flags: -Z stack-protector=strong -Z sanitizer=safestack
//@ [safestack_all] compile-flags: -Z stack-protector=all -Z sanitizer=safestack
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled --target x86_64-unknown-linux-gnu
//@ needs-llvm-components: x86
#![feature(unsized_fn_params)]
#![crate_type = "lib"]
#![feature(no_core)]
#![no_core]
#![no_std]
extern crate minicore;
use minicore::*;
extern "C" {
fn test4spss(p: *mut u8);
}
// CHECK-LABEL: test1{{:|\[}}
#[no_mangle]
pub unsafe fn test1(x: *mut u8) -> u8 {
let mut buf: [u8; 64] = [0; 64];
let p = &mut buf as *mut [u8; 64] as *mut u8;
*p = 42;
test4spss(p);
*x = *p;
*p
// none-NOT: __stack_chk_fail
// strong: __stack_chk_fail
// all: __stack_chk_fail
// safestack: __safestack_unsafe_stack_ptr
// safestack-NOT: __stack_chk_fail
// safestack_strong: __safestack_unsafe_stack_ptr
// safestack_strong: __stack_chk_fail
// safestack_all: __safestack_unsafe_stack_ptr
// safestack_all: __stack_chk_fail
}