|
31 | 31 | //!
|
32 | 32 | //! - A `_sheap` symbol at whose address you can locate a heap.
|
33 | 33 | //!
|
34 |
| -//! - Zero cost stack overflow protection when using the `swap-ld` linker. |
| 34 | +//! - Zero cost stack overflow protection when using the `cortex-m-rt-ld` linker. |
35 | 35 | //!
|
36 | 36 | //! # Example
|
37 | 37 | //!
|
|
117 | 117 | //! .data 0x0 0x20000000
|
118 | 118 | //! ```
|
119 | 119 | //!
|
120 |
| -//! ## Zero stack overflow protection |
| 120 | +//! ## Zero cost stack overflow protection |
121 | 121 | //!
|
122 | 122 | //! Consider the following variation of the previous program:
|
123 | 123 | //!
|
|
207 | 207 | //! sections so that the `.bss` section is near the end of the RAM region and the `.stack` comes
|
208 | 208 | //! *before* `.bss`, at a lower address.
|
209 | 209 | //!
|
210 |
| -//! To swap the sections you can use the [`swap-ld`] linker to link the program. |
| 210 | +//! To swap the sections you can use the [`cortex-m-rt-ld`] linker to link the program. |
211 | 211 | //!
|
212 | 212 | //! ``` console
|
213 |
| -//! $ cargo install swap-ld |
| 213 | +//! $ cargo install cortex-m-rt-ld |
214 | 214 | //!
|
215 | 215 | //! $ xargo rustc --target thumbv7m-none-eabi -- \
|
216 |
| -//! -C link-arg=-Tlink.x -C linker=swap-ld -Z linker-flavor=ld |
| 216 | +//! -C link-arg=-Tlink.x -C linker=cortex-m-rt-ld -Z linker-flavor=ld |
217 | 217 | //! ```
|
218 | 218 | //!
|
219 | 219 | //! Now you get non overlapping linker sections:
|
|
269 | 269 | //!
|
270 | 270 | //! The `.stack` can crash into the `.heap`, or vice versa, and you'll also get memory corruption.
|
271 | 271 | //!
|
272 |
| -//! `swap-ld` can also be used in this case but the size of the `.heap` section must be specified |
273 |
| -//! in the `_heap_size` symbol in `memory.x`, or in any other linker script. |
| 272 | +//! `cortex-m-rt-ld` can also be used in this case but the size of the `.heap` section must be |
| 273 | +//! specified via the `_heap_size` symbol in `memory.x`, or in any other linker script. |
274 | 274 | //!
|
275 | 275 | //! ``` console
|
276 |
| -//! $ $EDITOR memory.x && tail $_ |
| 276 | +//! $ $EDITOR memory.x && tail -n1 $_ |
277 | 277 | //! _heap_size = 0x400;
|
278 | 278 | //! ```
|
279 | 279 | //!
|
280 | 280 | //! ``` console
|
281 | 281 | //! $ xargo rustc --target thumbv7m-none-eabi -- \
|
282 |
| -//! -C link-arg=-Tlink.x -C linker=swap-ld -Z linker-flavor=ld |
| 282 | +//! -C link-arg=-Tlink.x -C linker=cortex-m-rt-ld -Z linker-flavor=ld |
283 | 283 | //!
|
284 | 284 | //! $ arm-none-eabi-size -Ax $(find target -name app) | head
|
285 | 285 | //! section size addr
|
|
298 | 298 | //! <img alt="Swapped sections when `.heap` exists" src="https://i.imgur.com/6Y5DaBp.png">
|
299 | 299 | //! </p>
|
300 | 300 | //!
|
301 |
| -//! Now both stack overflows and dynamic memory over-allocations will generate hard fault |
| 301 | +//! Now both stack overflows and dynamic memory over-allocations (OOM) will generate hard fault |
302 | 302 | //! exceptions, instead of running into each other.
|
303 | 303 | //!
|
304 | 304 | //! # Symbol interfaces
|
|
425 | 425 | //!
|
426 | 426 | //! ### `_heap_size`
|
427 | 427 | //!
|
428 |
| -//! The size of the `.heap` section. Only meaningful when using `swap-ld`. |
| 428 | +//! The size of the `.heap` section. Only meaningful when using `cortex-m-rt-ld`. |
429 | 429 | //!
|
430 | 430 | //! ### `_stext`
|
431 | 431 | //!
|
|
472 | 472 | //! }
|
473 | 473 | //! ```
|
474 | 474 | //!
|
475 |
| -//! *NOTE* if you are using `swap-ld` and/or have defined the `_heap_size` symbol then you should |
| 475 | +//! *NOTE* if you are using `cortex-m-rt-ld` and/or have defined the `_heap_size` symbol then you should |
476 | 476 | //! use the address of the `_eheap` to compute the size of the `.heap` section, instead of
|
477 | 477 | //! duplicating the value that you wrote in `memory.x`.
|
478 | 478 | //!
|
479 | 479 | //! [1]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html
|
480 | 480 | //! [qs]: https://docs.rs/cortex-m-quickstart/0.2.0/cortex_m_quickstart/
|
481 |
| -//! [`swap-ld`]: https://crates.io/crates/swap-ld |
| 481 | +//! [`cortex-m-rt-ld`]: https://crates.io/crates/cortex-m-rt-ld |
482 | 482 | //! [2]: https://sourceware.org/binutils/docs/ld/MEMORY.html
|
483 | 483 |
|
484 | 484 | #![cfg_attr(any(target_arch = "arm", feature = "abort-on-panic"), feature(core_intrinsics))]
|
|
0 commit comments