Skip to content

Commit b87c3dc

Browse files
committed
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
1 parent 27501f8 commit b87c3dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cortex-m-rt/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ fn main() {
2424
let mut f = if env::var_os("CARGO_FEATURE_DEVICE").is_some() {
2525
let mut f = File::create(out.join("link.x")).unwrap();
2626

27+
f.write_all(link_x).unwrap();
28+
29+
// *IMPORTANT*: The weak aliases (i.e. `PROVIDED`) must come *after* `EXTERN(__INTERRUPTS)`.
30+
// Otherwise the linker will ignore user defined interrupts and always populate the table
31+
// with the weak aliases.
2732
writeln!(
2833
f,
2934
r#"
3035
/* Provides weak aliases (cf. PROVIDED) for device specific interrupt handlers */
3136
/* This will usually be provided by a device crate generated using svd2rust (see `device.x`) */
3237
INCLUDE device.x"#
3338
).unwrap();
34-
f.write_all(link_x).unwrap();
3539
f
3640
} else {
3741
let mut f = File::create(out.join("link.x")).unwrap();

0 commit comments

Comments
 (0)