diff --git a/link.x b/link.x index e9605c3e..0d043cbc 100644 --- a/link.x +++ b/link.x @@ -1,5 +1,12 @@ INCLUDE memory.x +/* With multiple codegen units the rlib produced for this crate has several object files in it. */ +/* Because the linker is Smart it may not look into all the object files and not pick up the */ +/* .vector_table.exceptions section. But we want it to! To workaround the problem we create an */ +/* undefined reference to the EXCEPTIONS symbol (located in .vector_table.exceptions); this way the */ +/* linker will look at all the object of the rlib and pick up our EXCEPTIONS symbol */ +EXTERN(EXCEPTIONS); + /* Create an undefined reference to the INTERRUPTS symbol. This is required to force the linker to *not* drop the INTERRUPTS symbol if it comes from an object file that's passed to the linker *before* this crate */ diff --git a/src/lib.rs b/src/lib.rs index bc9572f7..b83d53c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -410,10 +410,13 @@ extern "C" { fn SYS_TICK(); } +#[allow(private_no_mangle_statics)] #[cfg(target_arch = "arm")] -#[used] +#[doc(hidden)] #[link_section = ".vector_table.exceptions"] -static EXCEPTIONS: [Option; 14] = [ +#[no_mangle] +#[used] +pub static EXCEPTIONS: [Option; 14] = [ Some(NMI), Some(HARD_FAULT), Some(MEM_MANAGE),