aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-09-17 20:48:03 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-09-17 20:48:03 +0200
commitb87c3dc0ec870d8563f7dd6fde3f85794eeb722f (patch)
treee4e11d97118e805029ced5a6a5d23c39eedb340f
parent27501f88b8c6ae9746efea01416f5276e43171eb (diff)
downloadcortex-m-b87c3dc0ec870d8563f7dd6fde3f85794eeb722f.tar.gz
cortex-m-b87c3dc0ec870d8563f7dd6fde3f85794eeb722f.tar.zst
cortex-m-b87c3dc0ec870d8563f7dd6fde3f85794eeb722f.zip
link.x: EXTERN(__INTERRUPTS) must come before PROVIDED
or the user defined interrupts will be discarded when using fat LTO as seen in #120 closes #120
-rw-r--r--cortex-m-rt/build.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/cortex-m-rt/build.rs b/cortex-m-rt/build.rs
index 8166b1b..a978146 100644
--- a/cortex-m-rt/build.rs
+++ b/cortex-m-rt/build.rs
@@ -24,6 +24,11 @@ fn main() {
let mut f = if env::var_os("CARGO_FEATURE_DEVICE").is_some() {
let mut f = File::create(out.join("link.x")).unwrap();
+ f.write_all(link_x).unwrap();
+
+ // *IMPORTANT*: The weak aliases (i.e. `PROVIDED`) must come *after* `EXTERN(__INTERRUPTS)`.
+ // Otherwise the linker will ignore user defined interrupts and always populate the table
+ // with the weak aliases.
writeln!(
f,
r#"
@@ -31,7 +36,6 @@ fn main() {
/* This will usually be provided by a device crate generated using svd2rust (see `device.x`) */
INCLUDE device.x"#
).unwrap();
- f.write_all(link_x).unwrap();
f
} else {
let mut f = File::create(out.join("link.x")).unwrap();