Skip to content

Commit

Permalink
add .init_array support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Apr 9, 2017
1 parent eeaf566 commit 201d4e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cortex-m-rt/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 <[email protected]>"]

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

[dependencies.cortex-m]
optional = true
Expand Down
3 changes: 3 additions & 0 deletions cortex-m-rt/link.x
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ SECTIONS

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

.bss : ALIGN(4)
Expand Down
4 changes: 4 additions & 0 deletions cortex-m-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ 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 Down

0 comments on commit 201d4e2

Please sign in to comment.