diff options
author | 2022-07-27 18:36:56 +0000 | |
---|---|---|
committer | 2022-07-27 18:36:56 +0000 | |
commit | d4816e054b556e326c5e3d4c40f7120372aafc50 (patch) | |
tree | 96f89f1f5bd374ecb13fe249c6b4334e4d9e2d59 /macros/src/codegen | |
parent | 981fa1fb30a70ec2416778b3e8daa491108deb41 (diff) | |
parent | f15614e7cbba889462a22ae94b470e9a3c3dc817 (diff) | |
download | rtic-d4816e054b556e326c5e3d4c40f7120372aafc50.tar.gz rtic-d4816e054b556e326c5e3d4c40f7120372aafc50.tar.zst rtic-d4816e054b556e326c5e3d4c40f7120372aafc50.zip |
Merge #653
653: Allow custom `link_section` attributes for late resources r=AfoHT a=vccggorski
This commit makes RTIC aware of user-provided `link_section` attributes,
letting user override default section mapping.
Co-authored-by: Gabriel Górski <gabriel.gorski@volvocars.com>
Diffstat (limited to 'macros/src/codegen')
-rw-r--r-- | macros/src/codegen/local_resources.rs | 8 | ||||
-rw-r--r-- | macros/src/codegen/shared_resources.rs | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs index 50621c32..6e7c1daa 100644 --- a/macros/src/codegen/local_resources.rs +++ b/macros/src/codegen/local_resources.rs @@ -27,8 +27,14 @@ pub fn codegen( let mangled_name = util::static_local_resource_ident(name); let attrs = &res.attrs; + // late resources in `util::link_section_uninit` - let section = 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!()); diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs index 47f8faf0..08d77cc3 100644 --- a/macros/src/codegen/shared_resources.rs +++ b/macros/src/codegen/shared_resources.rs @@ -23,10 +23,16 @@ 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!( |