diff options
Diffstat (limited to '')
9 files changed, 116 insertions, 0 deletions
diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs new file mode 100644 index 000000000..e05dbf3bb --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs @@ -0,0 +1,11 @@ +// gate-test-abi_c_cmse_nonsecure_call +fn main() { + let non_secure_function = unsafe { + core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( + //~^ ERROR [E0658] + 0x10000004, + ) + }; + let mut toto = 5; + toto += non_secure_function(toto, 2, 3, 5); +} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr new file mode 100644 index 000000000..ed8e16899 --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr @@ -0,0 +1,12 @@ +error[E0658]: C-cmse-nonsecure-call ABI is experimental and subject to change + --> $DIR/gate_test.rs:4:46 + | +LL | core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #81391 <https://github.com/rust-lang/rust/issues/81391> for more information + = help: add `#![feature(abi_c_cmse_nonsecure_call)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs new file mode 100644 index 000000000..bbc039bdf --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs @@ -0,0 +1,24 @@ +// build-pass +// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib +// needs-llvm-components: arm +#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] +#![no_core] +#[lang="sized"] +pub trait Sized { } +#[lang="copy"] +pub trait Copy { } +impl Copy for u32 {} + +extern "rust-intrinsic" { + pub fn transmute<T, U>(e: T) -> U; +} + +#[no_mangle] +pub fn test(a: u32, b: u32, c: u32, d: u32) -> u32 { + let non_secure_function = unsafe { + transmute::<usize, extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32>( + 0x10000004, + ) + }; + non_secure_function(a, b, c, d) +} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs new file mode 100644 index 000000000..b8112b20a --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs @@ -0,0 +1,27 @@ +// build-fail +// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib +// needs-llvm-components: arm +#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] +#![no_core] +#[lang="sized"] +pub trait Sized { } +#[lang="copy"] +pub trait Copy { } +impl Copy for u32 {} + +extern "rust-intrinsic" { + pub fn transmute<T, U>(e: T) -> U; +} + +#[no_mangle] +pub fn test(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 { + let non_secure_function = unsafe { + transmute::< + usize, + extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32> + ( + 0x10000004, + ) + }; + non_secure_function(a, b, c, d, e) +} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr new file mode 100644 index 000000000..372300787 --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr @@ -0,0 +1,4 @@ +error: <unknown>:0:0: in function test i32 (i32, i32, i32, i32, i32): call to non-secure function would require passing arguments on stack + +error: aborting due to previous error + diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs new file mode 100644 index 000000000..f32b37090 --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs @@ -0,0 +1,8 @@ +// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib +// needs-llvm-components: arm +#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)] +#![no_core] +#[lang="sized"] +trait Sized { } + +pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781] diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr new file mode 100644 index 000000000..08b763b26 --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr @@ -0,0 +1,9 @@ +error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers + --> $DIR/wrong-abi-location-1.rs:8:1 + | +LL | pub extern "C-cmse-nonsecure-call" fn test() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0781`. diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs new file mode 100644 index 000000000..6f8bb24aa --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs @@ -0,0 +1,10 @@ +// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib +// needs-llvm-components: arm +#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)] +#![no_core] +#[lang="sized"] +trait Sized { } + +extern "C-cmse-nonsecure-call" { //~ ERROR [E0781] + fn test(); +} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr new file mode 100644 index 000000000..3ade9891e --- /dev/null +++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr @@ -0,0 +1,11 @@ +error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers + --> $DIR/wrong-abi-location-2.rs:8:1 + | +LL | / extern "C-cmse-nonsecure-call" { +LL | | fn test(); +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0781`. |