Skip to content

Commit

Permalink
Merge pull request #2 from japaric/ng
Browse files Browse the repository at this point in the history
stub exceptions by default, drop .init_array support
  • Loading branch information
Jorge Aparicio authored Apr 10, 2017
2 parents f072735 + f2ff000 commit 9c95cbd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion cortex-m-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ r0 = "0.2.1"

[dependencies.cortex-m]
optional = true
version = "0.2.0"
version = "0.2.2"

[dependencies.cortex-m-semihosting]
optional = true
Expand All @@ -19,6 +19,9 @@ features = ["mem"]
git = "https://github.com/rust-lang-nursery/compiler-builtins"

[features]
default = ["exceptions"]
# handle exceptions using the default handler
exceptions = ["cortex-m"]
linker-script = []
panic-over-itm = ["cortex-m"]
panic-over-semihosting = ["cortex-m-semihosting"]
4 changes: 2 additions & 2 deletions cortex-m-rt/link.x
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ SECTIONS
LONG(ORIGIN(RAM) + LENGTH(RAM));

KEEP(*(.rodata.reset_handler));
KEEP(*(.rodata._EXCEPTIONS));
KEEP(*(.rodata.exceptions));
__exceptions = .;

KEEP(*(.rodata._INTERRUPTS));
KEEP(*(.rodata.interrupts));
__interrupts = .;

*(.text.*);
Expand Down
19 changes: 13 additions & 6 deletions cortex-m-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#![feature(used)]
#![no_std]

#[cfg(feature = "panic-over-itm")]
#[macro_use]
#[cfg(any(feature = "panic-over-itm", feature = "exceptions"))]
#[cfg_attr(feature = "panic-over-itm", macro_use)]
extern crate cortex_m;
extern crate compiler_builtins;
#[cfg(feature = "panic-over-semihosting")]
Expand All @@ -45,6 +45,9 @@ extern crate r0;

mod lang_items;

#[cfg(feature = "exceptions")]
use cortex_m::exception;

/// The reset handler
///
/// This is the entry point of all programs
Expand All @@ -57,14 +60,10 @@ unsafe extern "C" fn reset_handler() -> ! {
static mut _sdata: u32;

static _sidata: u32;

static _init_array_start: extern "C" fn();
static _init_array_end: extern "C" fn();
}

::r0::zero_bss(&mut _sbss, &mut _ebss);
::r0::init_data(&mut _sdata, &mut _edata, &_sidata);
::r0::run_init_array(&_init_array_start, &_init_array_end);

// NOTE `rustc` forces this signature on us. See `src/lang_items.rs`
extern "C" {
Expand All @@ -86,3 +85,11 @@ unsafe extern "C" fn reset_handler() -> ! {
#[used]
#[link_section = ".rodata.reset_handler"]
static RESET_HANDLER: unsafe extern "C" fn() -> ! = reset_handler;

#[allow(dead_code)]
#[cfg(feature = "exceptions")]
#[link_section = ".rodata.exceptions"]
#[used]
static EXCEPTIONS: exception::Handlers = exception::Handlers {
..exception::DEFAULT_HANDLERS
};

0 comments on commit 9c95cbd

Please sign in to comment.