Skip to content

Commit a756451

Browse files
committed
disallow cmse ABIs on unsupported platforms
1 parent a6f0cc3 commit a756451

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

compiler/rustc_target/src/spec/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,10 @@ impl Target {
26732673
}
26742674
X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]),
26752675
Aapcs { .. } => "arm" == self.arch,
2676-
CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
2677-
CCmseNonSecureEntry => ["arm", "aarch64"].contains(&&self.arch[..]),
2676+
CCmseNonSecureCall | CCmseNonSecureEntry => {
2677+
["thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", "thumbv8m.base-none-eabi"]
2678+
.contains(&&self.llvm_target[..])
2679+
}
26782680
Win64 { .. } | SysV64 { .. } => self.arch == "x86_64",
26792681
PtxKernel => self.arch == "nvptx64",
26802682
Msp430Interrupt => self.arch == "msp430",

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr renamed to tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
2-
--> $DIR/trustzone-only.rs:5:1
2+
--> $DIR/trustzone-only.rs:20:1
33
|
44
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
//@ ignore-thumbv8m.main-none-eabi
2-
#![feature(cmse_nonsecure_entry)]
1+
//@ revisions: x86 aarch64 thumb7
2+
//
3+
//@[x86] compile-flags: --target x86_64-unknown-linux-gnu
4+
//@[x86] needs-llvm-components: x86
5+
//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
6+
//@[aarch64] needs-llvm-components: aarch64
7+
//@[thumb7] compile-flags: --target thumbv7em-none-eabi
8+
//@[thumb7] needs-llvm-components: arm
9+
#![feature(no_core, lang_items, rustc_attrs, cmse_nonsecure_entry)]
10+
#![no_core]
11+
12+
#[lang = "sized"]
13+
trait Sized {}
14+
#[lang = "copy"]
15+
trait Copy {}
16+
17+
impl Copy for u32 {}
318

419
#[no_mangle]
520
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
621
//~^ ERROR [E0570]
7-
input + 6
22+
input
823
}
924

1025
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
2+
--> $DIR/trustzone-only.rs:20:1
3+
|
4+
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0570`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
2+
--> $DIR/trustzone-only.rs:20:1
3+
|
4+
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0570`.

0 commit comments

Comments
 (0)