Skip to content

Conversation

@defermelowie
Copy link

@defermelowie defermelowie commented Jul 16, 2025

Rust has nightly support for Cortex-M Security Extension through the cmse-nonsecure-entry and cmse-nonsecure-call ABIs. These are compatible with C but cause the compiler to emit extra instructions for things such as clearing sensitive registers before jumps.

Therefore it would be convenient if cbindgen was able to generate declarations for functions annotated with these CMSE ABIs as well. This PR adds basic support for these ABIs by slightly relaxing the filter.

Copy link
Collaborator

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Looks reasonable but would it be possible to add a test?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants