Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bindgen/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl Parse {
items.join("::")
};

let is_extern_c = sig.abi.is_omitted() || sig.abi.is_c();
let is_extern_c = sig.abi.is_omitted() || sig.abi.is_c() || sig.abi.is_cmse();
let exported_name = named_symbol.exported_name();

match (is_extern_c, exported_name) {
Expand Down
27 changes: 16 additions & 11 deletions src/bindgen/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,24 +371,19 @@ impl_syn_item_helper!(syn::ItemTraitAlias);
/// Helper function for accessing Abi information
pub trait SynAbiHelpers {
fn is_c(&self) -> bool;
fn is_cmse(&self) -> bool;
fn is_omitted(&self) -> bool;
}

impl SynAbiHelpers for Option<syn::Abi> {
fn is_c(&self) -> bool {
if let Some(ref abi) = *self {
if let Some(ref lit_string) = abi.name {
return matches!(lit_string.value().as_str(), "C" | "C-unwind");
}
}
false
self.as_ref().is_some_and(|abi| abi.is_c())
}
fn is_cmse(&self) -> bool {
self.as_ref().is_some_and(|abi| abi.is_cmse())
}
fn is_omitted(&self) -> bool {
if let Some(ref abi) = *self {
abi.name.is_none()
} else {
false
}
self.as_ref().is_some_and(|abi| abi.is_omitted())
}
}

Expand All @@ -400,6 +395,16 @@ impl SynAbiHelpers for syn::Abi {
false
}
}
fn is_cmse(&self) -> bool {
if let Some(ref lit_string) = self.name {
matches!(
lit_string.value().as_str(),
"cmse-nonsecure-entry" | "cmse-nonsecure-call"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure why these function shouldn't be tagged with __attribute__((cmse_nonsecure_call)) and __attribute__((cmse_nonsecure_entry)), respectively. Mind elaborating on that?

Copy link
Author

@defermelowie defermelowie Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off the top of my head, that's because these annotations instruct the compiler to create veneers for these functions which is only important at their definition (in rust), call sites shouldn't care about this.

)
} else {
false
}
}
fn is_omitted(&self) -> bool {
self.name.is_none()
}
Expand Down