Skip to content

Commit f778905

Browse files
authored
Merge pull request #83 from adamrk/probestack-test
Test for probestack linking errors
2 parents 3d1a87e + d5fadec commit f778905

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

drivers/char/rust_example.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![no_std]
44
#![feature(allocator_api, global_asm)]
5+
#![feature(test)]
56

67
use alloc::boxed::Box;
78
use core::pin::Pin;
@@ -52,6 +53,13 @@ impl KernelModule for RustExample {
5253
println!(" my_bool: {}", my_bool.read());
5354
println!(" my_i32: {}", my_i32.read());
5455

56+
// Including this large variable on the stack will trigger
57+
// stack probing on the supported archs.
58+
// This will verify that stack probing does not lead to
59+
// any errors if we need to link `__rust_probestack`.
60+
let x: [u64; 1028] = core::hint::black_box([5; 1028]);
61+
println!("Large array has length: {}", x.len());
62+
5563
Ok(RustExample {
5664
message: "on the heap!".to_owned(),
5765
_dev: miscdev::Registration::new_pinned::<RustFile>(cstr!("rust_miscdev"), None)?,

drivers/char/rust_example_2.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![no_std]
44
#![feature(allocator_api, global_asm)]
5+
#![feature(test)]
56

67
use kernel::prelude::*;
78

@@ -36,6 +37,14 @@ impl KernelModule for RustExample2 {
3637
println!("[2] Parameters:");
3738
println!("[2] my_bool: {}", my_bool.read());
3839
println!("[2] my_i32: {}", my_i32.read());
40+
41+
// Including this large variable on the stack will trigger
42+
// stack probing on the supported archs.
43+
// This will verify that stack probing does not lead to
44+
// any errors if we need to link `__rust_probestack`.
45+
let x: [u64; 1028] = core::hint::black_box([5; 1028]);
46+
println!("Large array has length: {}", x.len());
47+
3948
Ok(RustExample2 {
4049
message: "on the heap!".to_owned(),
4150
})

drivers/char/rust_example_3.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![no_std]
44
#![feature(allocator_api, global_asm)]
5+
#![feature(test)]
56

67
use kernel::prelude::*;
78

@@ -36,6 +37,14 @@ impl KernelModule for RustExample3 {
3637
println!("[3] Parameters:");
3738
println!("[3] my_bool: {}", my_bool.read());
3839
println!("[3] my_i32: {}", my_i32.read());
40+
41+
// Including this large variable on the stack will trigger
42+
// stack probing on the supported archs.
43+
// This will verify that stack probing does not lead to
44+
// any errors if we need to link `__rust_probestack`.
45+
let x: [u64; 1028] = core::hint::black_box([5; 1028]);
46+
println!("Large array has length: {}", x.len());
47+
3948
Ok(RustExample3 {
4049
message: "on the heap!".to_owned(),
4150
})

drivers/char/rust_example_4.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![no_std]
44
#![feature(allocator_api, global_asm)]
5+
#![feature(test)]
56

67
use kernel::prelude::*;
78

@@ -36,6 +37,14 @@ impl KernelModule for RustExample4 {
3637
println!("[4] Parameters:");
3738
println!("[4] my_bool: {}", my_bool.read());
3839
println!("[4] my_i32: {}", my_i32.read());
40+
41+
// Including this large variable on the stack will trigger
42+
// stack probing on the supported archs.
43+
// This will verify that stack probing does not lead to
44+
// any errors if we need to link `__rust_probestack`.
45+
let x: [u64; 1028] = core::hint::black_box([5; 1028]);
46+
println!("Large array has length: {}", x.len());
47+
3948
Ok(RustExample4 {
4049
message: "on the heap!".to_owned(),
4150
})

0 commit comments

Comments
 (0)