disallow cmse ABIs on unsupported platforms

This commit is contained in:
Folkert 2024-08-01 16:30:04 +02:00 committed by Folkert de Vries
parent a41c209ef3
commit 4d75a4f0f2
5 changed files with 41 additions and 6 deletions

View File

@ -2724,8 +2724,10 @@ pub fn is_abi_supported(&self, abi: Abi) -> Option<bool> {
}
X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]),
Aapcs { .. } => "arm" == self.arch,
CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
CCmseNonSecureEntry => ["arm", "aarch64"].contains(&&self.arch[..]),
CCmseNonSecureCall | CCmseNonSecureEntry => {
["thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", "thumbv8m.base-none-eabi"]
.contains(&&self.llvm_target[..])
}
Win64 { .. } | SysV64 { .. } => self.arch == "x86_64",
PtxKernel => self.arch == "nvptx64",
Msp430Interrupt => self.arch == "msp430",

View File

@ -1,5 +1,5 @@
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
--> $DIR/trustzone-only.rs:5:1
--> $DIR/trustzone-only.rs:20:1
|
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,10 +1,25 @@
//@ ignore-thumbv8m.main-none-eabi
#![feature(cmse_nonsecure_entry)]
//@ revisions: x86 aarch64 thumb7
//
//@[x86] compile-flags: --target x86_64-unknown-linux-gnu
//@[x86] needs-llvm-components: x86
//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
//@[aarch64] needs-llvm-components: aarch64
//@[thumb7] compile-flags: --target thumbv7em-none-eabi
//@[thumb7] needs-llvm-components: arm
#![feature(no_core, lang_items, rustc_attrs, cmse_nonsecure_entry)]
#![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
impl Copy for u32 {}
#[no_mangle]
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
//~^ ERROR [E0570]
input + 6
input
}
fn main() {}

View File

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

View File

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