Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions aarch32-rt-macros/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ As of *aarch32-rt-macros v0.1.0*, this project is released in lock-step with

## [Unreleased]

- Handle outer `unsafe` for whitelisted proc macro attributes. For example, this allows
`#[unsafe(link_section="...")]` which previously did not work.

## [aarch32-rt-macros v0.2.0]

- Changed `#[entry]`, `#[exception]` and `#[irq]` to hide the handler function
Expand Down
15 changes: 15 additions & 0 deletions aarch32-rt-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ fn check_attr_whitelist(attrs: &[Attribute], caller: VectorKind) -> Result<(), T
];

'o: for attr in attrs {
// Also check whatever is wrapped inside `unsafe(...)`
if attr.path().is_ident("unsafe") {
let mut whitelisted = false;
let _ = attr.parse_nested_meta(|meta| {
for val in whitelist {
if meta.path.is_ident(val) {
whitelisted = true;
}
}
Ok(())
});
if whitelisted {
continue 'o;
}
}
for val in whitelist {
if eq(attr, val) {
continue 'o;
Expand Down
2 changes: 2 additions & 0 deletions examples/mps3-an536/src/bin/prefetch-exception-a32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ core::arch::global_asm!(
"#
);

// Custom link sections are allowed as well.
#[exception(Undefined)]
#[unsafe(link_section = ".text._rust_undefined_handler")]
fn undefined_handler(_addr: usize) -> ! {
panic!("unexpected undefined exception");
}
Expand Down