aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-07-27 18:36:56 +0000
committerGitHub <noreply@github.com>2022-07-27 18:36:56 +0000
commitd4816e054b556e326c5e3d4c40f7120372aafc50 (patch)
tree96f89f1f5bd374ecb13fe249c6b4334e4d9e2d59
parent981fa1fb30a70ec2416778b3e8daa491108deb41 (diff)
parentf15614e7cbba889462a22ae94b470e9a3c3dc817 (diff)
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>
-rw-r--r--CHANGELOG.md2
-rw-r--r--macros/src/codegen/local_resources.rs8
-rw-r--r--macros/src/codegen/shared_resources.rs10
3 files changed, 17 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68af769..b131b30 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
### Added
+- Allow custom `link_section` attributes for late resources
+
### Fixed
### Changed
diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs
index 50621c3..6e7c1da 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 47f8faf..08d77cc 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!(