Skip to content

Commit 1e86064

Browse files
committed
add more tests for cmse-nonsecure-call stack spills
1 parent 50ba821 commit 1e86064

File tree

8 files changed

+280
-62
lines changed

8 files changed

+280
-62
lines changed

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ build-fail
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3+
//@ needs-llvm-components: arm
4+
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
5+
#![no_core]
6+
#[lang = "sized"]
7+
pub trait Sized {}
8+
#[lang = "copy"]
9+
pub 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 fn test(
18+
f1: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
19+
f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u16, u16) -> u32,
20+
f3: extern "C-cmse-nonsecure-call" fn(u32, u64, u32) -> u32,
21+
f4: extern "C-cmse-nonsecure-call" fn(AlignRelevant, u32) -> u32,
22+
f5: extern "C-cmse-nonsecure-call" fn([u32; 5]) -> u32,
23+
) {
24+
f1(1, 2, 3, 4, 5); //~ ERROR [E0798]
25+
f2(1, 2, 3, 4, 5); //~ ERROR [E0798]
26+
f3(1, 2, 3); //~ ERROR [E0798]
27+
f4(AlignRelevant(1), 2); //~ ERROR [E0798]
28+
f5([0xAA; 5]); //~ ERROR [E0798]
29+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
error[E0798]: arguments for `C-cmse-nonsecure-call` function too large to pass via registers
2+
--> $DIR/params-via-stack.rs:24:5
3+
|
4+
LL | f1: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
5+
| -- this function uses the `C-cmse-nonsecure-call` ABI
6+
...
7+
LL | f1(1, 2, 3, 4, 5);
8+
| ^^^^^^^^^^^^^^^^^ but its arguments don't fit in the available registers
9+
|
10+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass all their arguments via the 4 32-bit available argument registers
11+
12+
error[E0798]: arguments for `C-cmse-nonsecure-call` function too large to pass via registers
13+
--> $DIR/params-via-stack.rs:25:5
14+
|
15+
LL | f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u16, u16) -> u32,
16+
| -- this function uses the `C-cmse-nonsecure-call` ABI
17+
...
18+
LL | f2(1, 2, 3, 4, 5);
19+
| ^^^^^^^^^^^^^^^^^ but its arguments don't fit in the available registers
20+
|
21+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass all their arguments via the 4 32-bit available argument registers
22+
23+
error[E0798]: arguments for `C-cmse-nonsecure-call` function too large to pass via registers
24+
--> $DIR/params-via-stack.rs:26:5
25+
|
26+
LL | f3: extern "C-cmse-nonsecure-call" fn(u32, u64, u32) -> u32,
27+
| -- this function uses the `C-cmse-nonsecure-call` ABI
28+
...
29+
LL | f3(1, 2, 3);
30+
| ^^^^^^^^^^^ but its arguments don't fit in the available registers
31+
|
32+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass all their arguments via the 4 32-bit available argument registers
33+
34+
error[E0798]: arguments for `C-cmse-nonsecure-call` function too large to pass via registers
35+
--> $DIR/params-via-stack.rs:27:5
36+
|
37+
LL | f4: extern "C-cmse-nonsecure-call" fn(AlignRelevant, u32) -> u32,
38+
| -- this function uses the `C-cmse-nonsecure-call` ABI
39+
...
40+
LL | f4(AlignRelevant(1), 2);
41+
| ^^^^^^^^^^^^^^^^^^^^^^^ but its arguments don't fit in the available registers
42+
|
43+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass all their arguments via the 4 32-bit available argument registers
44+
45+
error[E0798]: arguments for `C-cmse-nonsecure-call` function too large to pass via registers
46+
--> $DIR/params-via-stack.rs:28:5
47+
|
48+
LL | f5: extern "C-cmse-nonsecure-call" fn([u32; 5]) -> u32,
49+
| -- this function uses the `C-cmse-nonsecure-call` ABI
50+
...
51+
LL | f5([0xAA; 5]);
52+
| ^^^^^^^^^^^^^ but its arguments don't fit in the available registers
53+
|
54+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass all their arguments via the 4 32-bit available argument registers
55+
56+
error: aborting due to 5 previous errors
57+
58+
For more information about this error, try `rustc --explain E0798`.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@ build-fail
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3+
//@ needs-llvm-components: arm
4+
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
5+
#![no_core]
6+
#[lang = "sized"]
7+
pub trait Sized {}
8+
#[lang = "copy"]
9+
pub trait Copy {}
10+
impl Copy for u32 {}
11+
12+
#[repr(C)]
13+
pub struct ReprCU64(u64);
14+
15+
#[repr(C)]
16+
pub struct ReprCBytes(u8, u8, u8, u8, u8);
17+
18+
#[repr(C)]
19+
pub struct U64Compound(u32, u32);
20+
21+
#[repr(C, align(16))]
22+
pub struct ReprCAlign16(u16);
23+
24+
#[no_mangle]
25+
pub fn test(
26+
f1: extern "C-cmse-nonsecure-call" fn() -> ReprCU64,
27+
f2: extern "C-cmse-nonsecure-call" fn() -> ReprCBytes,
28+
f3: extern "C-cmse-nonsecure-call" fn() -> U64Compound,
29+
f4: extern "C-cmse-nonsecure-call" fn() -> ReprCAlign16,
30+
f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 5],
31+
f6: extern "C-cmse-nonsecure-call" fn() -> u128, //~ WARNING [improper_ctypes_definitions]
32+
f7: extern "C-cmse-nonsecure-call" fn() -> i128, //~ WARNING [improper_ctypes_definitions]
33+
) {
34+
f1(); //~ ERROR [E0798]
35+
f2(); //~ ERROR [E0798]
36+
f3(); //~ ERROR [E0798]
37+
f4(); //~ ERROR [E0798]
38+
f5(); //~ ERROR [E0798]
39+
f6(); //~ ERROR [E0798]
40+
f7(); //~ ERROR [E0798]
41+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
warning: `extern` fn uses type `u128`, which is not FFI-safe
2+
--> $DIR/return-via-stack.rs:31:9
3+
|
4+
LL | f6: extern "C-cmse-nonsecure-call" fn() -> u128,
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
6+
|
7+
= note: 128-bit integers don't currently have a known stable ABI
8+
= note: `#[warn(improper_ctypes_definitions)]` on by default
9+
10+
warning: `extern` fn uses type `i128`, which is not FFI-safe
11+
--> $DIR/return-via-stack.rs:32:9
12+
|
13+
LL | f7: extern "C-cmse-nonsecure-call" fn() -> i128,
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
15+
|
16+
= note: 128-bit integers don't currently have a known stable ABI
17+
18+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
19+
--> $DIR/return-via-stack.rs:34:5
20+
|
21+
LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprCU64,
22+
| -- this function uses the `C-cmse-nonsecure-call` ABI
23+
...
24+
LL | f1();
25+
| ^^^^ but its return value doesn't fit in the available registers
26+
|
27+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
28+
29+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
30+
--> $DIR/return-via-stack.rs:35:5
31+
|
32+
LL | f2: extern "C-cmse-nonsecure-call" fn() -> ReprCBytes,
33+
| -- this function uses the `C-cmse-nonsecure-call` ABI
34+
...
35+
LL | f2();
36+
| ^^^^ but its return value doesn't fit in the available registers
37+
|
38+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
39+
40+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
41+
--> $DIR/return-via-stack.rs:36:5
42+
|
43+
LL | f3: extern "C-cmse-nonsecure-call" fn() -> U64Compound,
44+
| -- this function uses the `C-cmse-nonsecure-call` ABI
45+
...
46+
LL | f3();
47+
| ^^^^ but its return value doesn't fit in the available registers
48+
|
49+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
50+
51+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
52+
--> $DIR/return-via-stack.rs:37:5
53+
|
54+
LL | f4: extern "C-cmse-nonsecure-call" fn() -> ReprCAlign16,
55+
| -- this function uses the `C-cmse-nonsecure-call` ABI
56+
...
57+
LL | f4();
58+
| ^^^^ but its return value doesn't fit in the available registers
59+
|
60+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
61+
62+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
63+
--> $DIR/return-via-stack.rs:38:5
64+
|
65+
LL | f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 5],
66+
| -- this function uses the `C-cmse-nonsecure-call` ABI
67+
...
68+
LL | f5();
69+
| ^^^^ but its return value doesn't fit in the available registers
70+
|
71+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
72+
73+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
74+
--> $DIR/return-via-stack.rs:39:5
75+
|
76+
LL | f6: extern "C-cmse-nonsecure-call" fn() -> u128,
77+
| -- this function uses the `C-cmse-nonsecure-call` ABI
78+
...
79+
LL | f6();
80+
| ^^^^ but its return value doesn't fit in the available registers
81+
|
82+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
83+
84+
error[E0798]: return value of `C-cmse-nonsecure-call` function too large to pass via registers
85+
--> $DIR/return-via-stack.rs:40:5
86+
|
87+
LL | f7: extern "C-cmse-nonsecure-call" fn() -> i128,
88+
| -- this function uses the `C-cmse-nonsecure-call` ABI
89+
...
90+
LL | f7();
91+
| ^^^^ but its return value doesn't fit in the available registers
92+
|
93+
= note: functions with the `C-cmse-nonsecure-call` ABI must pass their result via the available return registers
94+
95+
error: aborting due to 7 previous errors; 2 warnings emitted
96+
97+
For more information about this error, try `rustc --explain E0798`.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//@ build-pass
2+
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
3+
//@ needs-llvm-components: arm
4+
#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
5+
#![no_core]
6+
#[lang = "sized"]
7+
pub trait Sized {}
8+
#[lang = "copy"]
9+
pub trait Copy {}
10+
impl Copy for u32 {}
11+
12+
#[repr(transparent)]
13+
pub struct ReprTransparentU64(u64);
14+
15+
#[repr(C)]
16+
pub struct U32Compound(u16, u16);
17+
18+
#[no_mangle]
19+
#[allow(improper_ctypes_definitions)]
20+
pub fn params(
21+
f1: extern "C-cmse-nonsecure-call" fn(),
22+
f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32),
23+
f3: extern "C-cmse-nonsecure-call" fn(u64, u64),
24+
f4: extern "C-cmse-nonsecure-call" fn(u128),
25+
f5: extern "C-cmse-nonsecure-call" fn(f64, f32, f32),
26+
f6: extern "C-cmse-nonsecure-call" fn(ReprTransparentU64, U32Compound),
27+
f7: extern "C-cmse-nonsecure-call" fn([u32; 4]),
28+
) {
29+
f1();
30+
f2(1, 2, 3, 4);
31+
f3(1, 2);
32+
f4(1);
33+
f5(1.0, 2.0, 3.0);
34+
f6(ReprTransparentU64(1), U32Compound(2, 3));
35+
f7([0xDEADBEEF; 4]);
36+
}
37+
38+
#[no_mangle]
39+
pub fn returns(
40+
f1: extern "C-cmse-nonsecure-call" fn() -> u32,
41+
f2: extern "C-cmse-nonsecure-call" fn() -> u64,
42+
f3: extern "C-cmse-nonsecure-call" fn() -> i64,
43+
f4: extern "C-cmse-nonsecure-call" fn() -> f64,
44+
f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 4],
45+
f6: extern "C-cmse-nonsecure-call" fn() -> ReprTransparentU64,
46+
f7: extern "C-cmse-nonsecure-call" fn() -> U32Compound,
47+
) {
48+
f1();
49+
f2();
50+
f3();
51+
f4();
52+
f5();
53+
f6();
54+
f7();
55+
}

0 commit comments

Comments
 (0)