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

Commit a535074

Browse files
committed
s/swap-ld/cortex-m-rt-ld/g
also fix a bug when .bss was empty but .data was not
1 parent 114a708 commit a535074

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

link.x

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SECTIONS
7070
_ebss = .;
7171
} > RAM
7272

73-
.data : ALIGN(4)
73+
.data _ebss : ALIGN(4)
7474
{
7575
_sidata = LOADADDR(.data);
7676
_sdata = .;

src/lib.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! - A `_sheap` symbol at whose address you can locate a heap.
3333
//!
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.
3535
//!
3636
//! # Example
3737
//!
@@ -117,7 +117,7 @@
117117
//! .data 0x0 0x20000000
118118
//! ```
119119
//!
120-
//! ## Zero stack overflow protection
120+
//! ## Zero cost stack overflow protection
121121
//!
122122
//! Consider the following variation of the previous program:
123123
//!
@@ -207,13 +207,13 @@
207207
//! sections so that the `.bss` section is near the end of the RAM region and the `.stack` comes
208208
//! *before* `.bss`, at a lower address.
209209
//!
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.
211211
//!
212212
//! ``` console
213-
//! $ cargo install swap-ld
213+
//! $ cargo install cortex-m-rt-ld
214214
//!
215215
//! $ 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
217217
//! ```
218218
//!
219219
//! Now you get non overlapping linker sections:
@@ -269,17 +269,17 @@
269269
//!
270270
//! The `.stack` can crash into the `.heap`, or vice versa, and you'll also get memory corruption.
271271
//!
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.
274274
//!
275275
//! ``` console
276-
//! $ $EDITOR memory.x && tail $_
276+
//! $ $EDITOR memory.x && tail -n1 $_
277277
//! _heap_size = 0x400;
278278
//! ```
279279
//!
280280
//! ``` console
281281
//! $ 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
283283
//!
284284
//! $ arm-none-eabi-size -Ax $(find target -name app) | head
285285
//! section size addr
@@ -298,7 +298,7 @@
298298
//! <img alt="Swapped sections when `.heap` exists" src="https://i.imgur.com/6Y5DaBp.png">
299299
//! </p>
300300
//!
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
302302
//! exceptions, instead of running into each other.
303303
//!
304304
//! # Symbol interfaces
@@ -425,7 +425,7 @@
425425
//!
426426
//! ### `_heap_size`
427427
//!
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`.
429429
//!
430430
//! ### `_stext`
431431
//!
@@ -472,13 +472,13 @@
472472
//! }
473473
//! ```
474474
//!
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
476476
//! use the address of the `_eheap` to compute the size of the `.heap` section, instead of
477477
//! duplicating the value that you wrote in `memory.x`.
478478
//!
479479
//! [1]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html
480480
//! [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
482482
//! [2]: https://sourceware.org/binutils/docs/ld/MEMORY.html
483483
484484
#![cfg_attr(any(target_arch = "arm", feature = "abort-on-panic"), feature(core_intrinsics))]

0 commit comments

Comments
 (0)