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

tweak the linker script to keep the EXCEPTIONS symbol (vector table) #36

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions link.x
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down