Skip to content

Commit 3a077e6

Browse files
committed
tweak the linker script to keep the EXCEPTIONS symbol (vector table)
fixes rust-embedded/cortex-m-quickstart#19 fixes rust-embedded/cortex-m-rt#35 closes rust-embedded/cortex-m-quickstart#18
1 parent ee15706 commit 3a077e6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cortex-m-rt/link.x

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
INCLUDE memory.x
22

3+
/* With multiple codegen units the rlib produced for this crate has several object files in it. */
4+
/* Because the linker is Smart it may not look into all the object files and not pick up the */
5+
/* .vector_table.exceptions section. But we want it to! To workaround the problem we create an */
6+
/* undefined reference to the EXCEPTIONS symbol (located in .vector_table.exceptions); this way the */
7+
/* linker will look at all the object of the rlib and pick up our EXCEPTIONS symbol */
8+
EXTERN(EXCEPTIONS);
9+
310
/* Create an undefined reference to the INTERRUPTS symbol. This is required to
411
force the linker to *not* drop the INTERRUPTS symbol if it comes from an
512
object file that's passed to the linker *before* this crate */

cortex-m-rt/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,13 @@ extern "C" {
410410
fn SYS_TICK();
411411
}
412412

413+
#[allow(private_no_mangle_statics)]
413414
#[cfg(target_arch = "arm")]
414-
#[used]
415+
#[doc(hidden)]
415416
#[link_section = ".vector_table.exceptions"]
416-
static EXCEPTIONS: [Option<unsafe extern "C" fn()>; 14] = [
417+
#[no_mangle]
418+
#[used]
419+
pub static EXCEPTIONS: [Option<unsafe extern "C" fn()>; 14] = [
417420
Some(NMI),
418421
Some(HARD_FAULT),
419422
Some(MEM_MANAGE),

0 commit comments

Comments
 (0)