aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-10-03 11:17:19 +0200
committerGravatar GitHub <noreply@github.com> 2017-10-03 11:17:19 +0200
commitdb8d8c5f7d33b7aab2487a0533c5bc9f5b380621 (patch)
tree801d22aad9ad2eb416ed82a8aeb3bb45e34c988f
parentee15706c387497e20ad1eb3d95bcc3e22a92341c (diff)
parent3a077e641fdbab7e53907740878425426caead5d (diff)
downloadcortex-m-db8d8c5f7d33b7aab2487a0533c5bc9f5b380621.tar.gz
cortex-m-db8d8c5f7d33b7aab2487a0533c5bc9f5b380621.tar.zst
cortex-m-db8d8c5f7d33b7aab2487a0533c5bc9f5b380621.zip
Merge pull request #36 from japaric/keep-exceptions
tweak the linker script to keep the EXCEPTIONS symbol (vector table)
-rw-r--r--cortex-m-rt/link.x7
-rw-r--r--cortex-m-rt/src/lib.rs7
2 files changed, 12 insertions, 2 deletions
diff --git a/cortex-m-rt/link.x b/cortex-m-rt/link.x
index e9605c3..0d043cb 100644
--- a/cortex-m-rt/link.x
+++ b/cortex-m-rt/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/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index bc9572f..b83d53c 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/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<unsafe extern "C" fn()>; 14] = [
+#[no_mangle]
+#[used]
+pub static EXCEPTIONS: [Option<unsafe extern "C" fn()>; 14] = [
Some(NMI),
Some(HARD_FAULT),
Some(MEM_MANAGE),