diff --git a/aarch32-rt-macros/CHANGELOG.md b/aarch32-rt-macros/CHANGELOG.md index 344634a..0956330 100644 --- a/aarch32-rt-macros/CHANGELOG.md +++ b/aarch32-rt-macros/CHANGELOG.md @@ -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 diff --git a/aarch32-rt-macros/src/lib.rs b/aarch32-rt-macros/src/lib.rs index 4feb8ef..e3f3f73 100644 --- a/aarch32-rt-macros/src/lib.rs +++ b/aarch32-rt-macros/src/lib.rs @@ -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; diff --git a/examples/mps3-an536/src/bin/prefetch-exception-a32.rs b/examples/mps3-an536/src/bin/prefetch-exception-a32.rs index 2f3a59d..1425b96 100644 --- a/examples/mps3-an536/src/bin/prefetch-exception-a32.rs +++ b/examples/mps3-an536/src/bin/prefetch-exception-a32.rs @@ -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"); }