Skip to content

Commit

Permalink
Merge pull request rtic-rs#1 from japaric/used
Browse files Browse the repository at this point in the history
make the reset handler private
  • Loading branch information
Jorge Aparicio authored Apr 9, 2017
2 parents 4ac91ae + 4457c0e commit 88ebaf1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Jorge Aparicio <japaricious@gmail.com>"]

[dependencies]
r0 = "0.2.0"
r0 = "0.2.1"

[dependencies.cortex-m]
optional = true
Expand Down
9 changes: 4 additions & 5 deletions link.x
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ SECTIONS
/* Vector table */
_VECTOR_TABLE = .;
LONG(ORIGIN(RAM) + LENGTH(RAM));
LONG(__reset + 1);

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

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

/* Entry point: the reset handler */
__reset = .;
KEEP(*(.text.start));

*(.text.*);
*(.rodata.*);
_init_array_start = ALIGN(4);
KEEP(*(.init_array));
_init_array_end = ALIGN(4);
} > FLASH

.bss : ALIGN(4)
Expand Down
15 changes: 11 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#![feature(compiler_builtins_lib)]
#![feature(lang_items)]
#![feature(linkage)]
#![feature(used)]
#![no_std]

#[cfg(feature = "panic-over-itm")]
Expand All @@ -44,13 +45,10 @@ extern crate r0;

mod lang_items;

// TODO make private and use `#[used]`
/// The reset handler
///
/// This is the entry point of all programs
#[doc(hidden)]
#[export_name = "start"]
pub unsafe extern "C" fn reset_handler() -> ! {
unsafe extern "C" fn reset_handler() -> ! {
extern "C" {
static mut _ebss: u32;
static mut _sbss: u32;
Expand All @@ -59,10 +57,14 @@ pub 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 @@ -79,3 +81,8 @@ pub unsafe extern "C" fn reset_handler() -> ! {
asm!("wfi" :::: "volatile");
}
}

#[allow(dead_code)]
#[used]
#[link_section = ".rodata.reset_handler"]
static RESET_HANDLER: unsafe extern "C" fn() -> ! = reset_handler;

0 comments on commit 88ebaf1

Please sign in to comment.