Skip to content

Commit b3a6cd6

Browse files
committed
add more tests for C-cmse-nonsecure-entry functions
1 parent 0bc2b1e commit b3a6cd6

8 files changed

+200
-41
lines changed

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs

-16
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs

-21
This file was deleted.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ build-fail
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3+
//@ needs-llvm-components: arm
4+
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
5+
#![no_core]
6+
#[lang = "sized"]
7+
trait Sized {}
8+
#[lang = "copy"]
9+
trait Copy {}
10+
impl Copy for u32 {}
11+
12+
#[repr(C, align(16))]
13+
#[allow(unused)]
14+
pub struct AlignRelevant(u32);
15+
16+
#[no_mangle]
17+
pub extern "C-cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _: u32, _: u32) {}
18+
#[no_mangle]
19+
pub extern "C-cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _: u16) {}
20+
#[no_mangle]
21+
pub extern "C-cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {}
22+
#[no_mangle]
23+
pub extern "C-cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {}
24+
25+
#[no_mangle]
26+
#[allow(improper_ctypes_definitions)]
27+
pub extern "C-cmse-nonsecure-entry" fn f5(_: [u32; 5]) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: <unknown>:0:0: in function f1 void (i32, i32, i32, i32, i32, i32): secure entry function requires arguments on stack
2+
3+
error: aborting due to 1 previous error
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//@ build-fail
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3+
//@ needs-llvm-components: arm
4+
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
5+
#![no_core]
6+
#[lang = "sized"]
7+
pub trait Sized {}
8+
#[lang = "copy"]
9+
pub trait Copy {}
10+
impl Copy for u32 {}
11+
impl Copy for u8 {}
12+
13+
#[repr(C)]
14+
pub struct ReprCU64(u64);
15+
16+
#[repr(C)]
17+
pub struct ReprCBytes(u8, u8, u8, u8, u8);
18+
19+
#[repr(C)]
20+
pub struct U64Compound(u32, u32);
21+
22+
#[repr(C, align(16))]
23+
pub struct ReprCAlign16(u16);
24+
25+
#[no_mangle]
26+
pub extern "C-cmse-nonsecure-entry" fn f1() -> ReprCU64 {
27+
ReprCU64(0)
28+
}
29+
#[no_mangle]
30+
pub extern "C-cmse-nonsecure-entry" fn f2() -> ReprCBytes {
31+
ReprCBytes(0, 1, 2, 3, 4)
32+
}
33+
#[no_mangle]
34+
pub extern "C-cmse-nonsecure-entry" fn f3() -> U64Compound {
35+
U64Compound(2, 3)
36+
}
37+
#[no_mangle]
38+
pub extern "C-cmse-nonsecure-entry" fn f4() -> ReprCAlign16 {
39+
ReprCAlign16(4)
40+
}
41+
42+
#[no_mangle]
43+
#[allow(improper_ctypes_definitions)]
44+
pub extern "C-cmse-nonsecure-entry" fn f5() -> [u8; 5] {
45+
[0xAA; 5]
46+
}
47+
#[no_mangle]
48+
#[allow(improper_ctypes_definitions)]
49+
pub extern "C-cmse-nonsecure-entry" fn u128() -> u128 {
50+
123
51+
}
52+
#[no_mangle]
53+
#[allow(improper_ctypes_definitions)]
54+
pub extern "C-cmse-nonsecure-entry" fn i128() -> i128 {
55+
456
56+
}
57+
58+
#[repr(Rust)]
59+
pub union ReprRustUnionU64 {
60+
_unused: u64,
61+
}
62+
63+
#[repr(C)]
64+
pub union ReprCUnionU64 {
65+
_unused: u64,
66+
}
67+
68+
#[no_mangle]
69+
#[allow(improper_ctypes_definitions)]
70+
pub extern "C-cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 {
71+
ReprRustUnionU64 { _unused: 1 }
72+
}
73+
#[no_mangle]
74+
pub extern "C-cmse-nonsecure-entry" fn union_c() -> ReprCUnionU64 {
75+
ReprCUnionU64 { _unused: 2 }
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: <unknown>:0:0: in function f1 void (ptr): secure entry function would return value through pointer
2+
3+
error: aborting due to 1 previous error
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//@ build-pass
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3+
//@ needs-llvm-components: arm
4+
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
5+
#![no_core]
6+
#![crate_type = "lib"]
7+
#[lang = "sized"]
8+
pub trait Sized {}
9+
#[lang = "copy"]
10+
trait Copy {}
11+
impl Copy for u32 {}
12+
impl Copy for u8 {}
13+
14+
#[repr(transparent)]
15+
pub struct ReprTransparentStruct<T> {
16+
_marker1: (),
17+
_marker2: (),
18+
field: T,
19+
_marker3: (),
20+
}
21+
22+
#[repr(transparent)]
23+
pub enum ReprTransparentEnumU64 {
24+
A(u64),
25+
}
26+
27+
#[repr(C)]
28+
pub struct U32Compound(u16, u16);
29+
30+
#[no_mangle]
31+
pub extern "C-cmse-nonsecure-entry" fn inputs1() {}
32+
#[no_mangle]
33+
pub extern "C-cmse-nonsecure-entry" fn inputs2(_: u32, _: u32, _: u32, _: u32) {}
34+
#[no_mangle]
35+
pub extern "C-cmse-nonsecure-entry" fn inputs3(_: u64, _: u64) {}
36+
#[no_mangle]
37+
#[allow(improper_ctypes_definitions)]
38+
pub extern "C-cmse-nonsecure-entry" fn inputs4(_: u128) {}
39+
#[no_mangle]
40+
pub extern "C-cmse-nonsecure-entry" fn inputs5(_: f64, _: f32, _: f32) {}
41+
#[no_mangle]
42+
pub extern "C-cmse-nonsecure-entry" fn inputs6(_: ReprTransparentStruct<u64>, _: U32Compound) {}
43+
#[no_mangle]
44+
#[allow(improper_ctypes_definitions)]
45+
pub extern "C-cmse-nonsecure-entry" fn inputs7(_: [u32; 4]) {}
46+
47+
#[no_mangle]
48+
pub extern "C-cmse-nonsecure-entry" fn outputs1() -> u32 {
49+
0
50+
}
51+
#[no_mangle]
52+
pub extern "C-cmse-nonsecure-entry" fn outputs2() -> u64 {
53+
0
54+
}
55+
#[no_mangle]
56+
pub extern "C-cmse-nonsecure-entry" fn outputs3() -> i64 {
57+
0
58+
}
59+
#[no_mangle]
60+
pub extern "C-cmse-nonsecure-entry" fn outputs4() -> f64 {
61+
0.0
62+
}
63+
#[no_mangle]
64+
#[allow(improper_ctypes_definitions)]
65+
pub extern "C-cmse-nonsecure-entry" fn outputs5() -> [u8; 4] {
66+
[0xAA; 4]
67+
}
68+
#[no_mangle]
69+
pub extern "C-cmse-nonsecure-entry" fn outputs6() -> ReprTransparentStruct<u64> {
70+
ReprTransparentStruct { _marker1: (), _marker2: (), field: 0xAA, _marker3: () }
71+
}
72+
#[no_mangle]
73+
pub extern "C-cmse-nonsecure-entry" fn outputs7(
74+
) -> ReprTransparentStruct<ReprTransparentStruct<u64>> {
75+
ReprTransparentStruct {
76+
_marker1: (),
77+
_marker2: (),
78+
field: ReprTransparentStruct { _marker1: (), _marker2: (), field: 0xAA, _marker3: () },
79+
_marker3: (),
80+
}
81+
}
82+
#[no_mangle]
83+
pub extern "C-cmse-nonsecure-entry" fn outputs8() -> ReprTransparentEnumU64 {
84+
ReprTransparentEnumU64::A(0)
85+
}
86+
#[no_mangle]
87+
pub extern "C-cmse-nonsecure-entry" fn outputs9() -> U32Compound {
88+
U32Compound(1, 2)
89+
}

0 commit comments

Comments
 (0)