Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 5961128

Browse files
authored
Merge pull request #36 from japaric/keep-exceptions
tweak the linker script to keep the EXCEPTIONS symbol (vector table)
2 parents 5caebe7 + b9b63f0 commit 5961128

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

link.x

Lines changed: 7 additions & 0 deletions
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 */

src/lib.rs

Lines changed: 5 additions & 2 deletions
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)