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

Commit

Permalink
s/swap-ld/cortex-m-rt-ld/g
Browse files Browse the repository at this point in the history
also fix a bug when .bss was empty but .data was not
  • Loading branch information
japaric committed Feb 17, 2018
1 parent 114a708 commit a535074
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion link.x
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SECTIONS
_ebss = .;
} > RAM

.data : ALIGN(4)
.data _ebss : ALIGN(4)
{
_sidata = LOADADDR(.data);
_sdata = .;
Expand Down
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//!
//! - A `_sheap` symbol at whose address you can locate a heap.
//!
//! - Zero cost stack overflow protection when using the `swap-ld` linker.
//! - Zero cost stack overflow protection when using the `cortex-m-rt-ld` linker.
//!
//! # Example
//!
Expand Down Expand Up @@ -117,7 +117,7 @@
//! .data 0x0 0x20000000
//! ```
//!
//! ## Zero stack overflow protection
//! ## Zero cost stack overflow protection
//!
//! Consider the following variation of the previous program:
//!
Expand Down Expand Up @@ -207,13 +207,13 @@
//! sections so that the `.bss` section is near the end of the RAM region and the `.stack` comes
//! *before* `.bss`, at a lower address.
//!
//! To swap the sections you can use the [`swap-ld`] linker to link the program.
//! To swap the sections you can use the [`cortex-m-rt-ld`] linker to link the program.
//!
//! ``` console
//! $ cargo install swap-ld
//! $ cargo install cortex-m-rt-ld
//!
//! $ xargo rustc --target thumbv7m-none-eabi -- \
//! -C link-arg=-Tlink.x -C linker=swap-ld -Z linker-flavor=ld
//! -C link-arg=-Tlink.x -C linker=cortex-m-rt-ld -Z linker-flavor=ld
//! ```
//!
//! Now you get non overlapping linker sections:
Expand Down Expand Up @@ -269,17 +269,17 @@
//!
//! The `.stack` can crash into the `.heap`, or vice versa, and you'll also get memory corruption.
//!
//! `swap-ld` can also be used in this case but the size of the `.heap` section must be specified
//! in the `_heap_size` symbol in `memory.x`, or in any other linker script.
//! `cortex-m-rt-ld` can also be used in this case but the size of the `.heap` section must be
//! specified via the `_heap_size` symbol in `memory.x`, or in any other linker script.
//!
//! ``` console
//! $ $EDITOR memory.x && tail $_
//! $ $EDITOR memory.x && tail -n1 $_
//! _heap_size = 0x400;
//! ```
//!
//! ``` console
//! $ xargo rustc --target thumbv7m-none-eabi -- \
//! -C link-arg=-Tlink.x -C linker=swap-ld -Z linker-flavor=ld
//! -C link-arg=-Tlink.x -C linker=cortex-m-rt-ld -Z linker-flavor=ld
//!
//! $ arm-none-eabi-size -Ax $(find target -name app) | head
//! section size addr
Expand All @@ -298,7 +298,7 @@
//! <img alt="Swapped sections when `.heap` exists" src="https://i.imgur.com/6Y5DaBp.png">
//! </p>
//!
//! Now both stack overflows and dynamic memory over-allocations will generate hard fault
//! Now both stack overflows and dynamic memory over-allocations (OOM) will generate hard fault
//! exceptions, instead of running into each other.
//!
//! # Symbol interfaces
Expand Down Expand Up @@ -425,7 +425,7 @@
//!
//! ### `_heap_size`
//!
//! The size of the `.heap` section. Only meaningful when using `swap-ld`.
//! The size of the `.heap` section. Only meaningful when using `cortex-m-rt-ld`.
//!
//! ### `_stext`
//!
Expand Down Expand Up @@ -472,13 +472,13 @@
//! }
//! ```
//!
//! *NOTE* if you are using `swap-ld` and/or have defined the `_heap_size` symbol then you should
//! *NOTE* if you are using `cortex-m-rt-ld` and/or have defined the `_heap_size` symbol then you should
//! use the address of the `_eheap` to compute the size of the `.heap` section, instead of
//! duplicating the value that you wrote in `memory.x`.
//!
//! [1]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html
//! [qs]: https://docs.rs/cortex-m-quickstart/0.2.0/cortex_m_quickstart/
//! [`swap-ld`]: https://crates.io/crates/swap-ld
//! [`cortex-m-rt-ld`]: https://crates.io/crates/cortex-m-rt-ld
//! [2]: https://sourceware.org/binutils/docs/ld/MEMORY.html

#![cfg_attr(any(target_arch = "arm", feature = "abort-on-panic"), feature(core_intrinsics))]
Expand Down

0 comments on commit a535074

Please sign in to comment.