From c6fd3cdd0a4e29c1e2d77c6e9107450a1bceed92 Mon Sep 17 00:00:00 2001 From: Gabriel Górski Date: Wed, 6 Jul 2022 17:43:38 +0200 Subject: Allow custom `link_section` attributes for late resources This commit makes RTIC aware of user-provided `link_section` attributes, letting user override default section mapping. --- macros/src/codegen/shared_resources.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'macros/src/codegen/shared_resources.rs') diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs index 47f8faf0..010b27ae 100644 --- a/macros/src/codegen/shared_resources.rs +++ b/macros/src/codegen/shared_resources.rs @@ -23,10 +23,17 @@ pub fn codegen( let ty = &res.ty; let mangled_name = &util::static_shared_resource_ident(name); - // late resources in `util::link_section_uninit` - let section = util::link_section_uninit(); let attrs = &res.attrs; + // late resources in `util::link_section_uninit` + // unless user specifies custom link section + let section = if attrs.iter().any(|attr| attr.path.is_ident("link_section")) { + None + } + else { + Some(util::link_section_uninit()) + }; + // For future use // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); mod_app.push(quote!( -- cgit v1.2.3