Skip to content

Commit 73635b8

Browse files
Merge pull request #329 from rust-embedded/post-init
`riscv-rt`: Add uninit section
2 parents 9468182 + f72640d commit 73635b8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- New `post-init` feature to run a Rust `__post_init` function before jumping to `main`.
1313
- New `#[riscv_rt::post_init]` attribute to aid in the definition of the `__post_init` function.
14+
- Added `.uninit` section to the linker file. Due to its similarities with `.bss`, the
15+
linker will place this new section in `REGION_BSS`.
1416

1517
### Changed
1618

riscv-rt/link.x.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ SECTIONS
161161
. = ALIGN(${ARCH_WIDTH});
162162
__ebss = .;
163163

164+
/* Uninitialized data segment. In contrast with .bss, .uninit is not initialized to zero by
165+
* the runtime, and might contain residual data from previous executions or random values
166+
* if not explicitly initialized. While .bss and .uninit are different sections, they are
167+
* both allocated at REGION_BSS, as their purpose is similar. */
168+
.uninit (NOLOAD) : ALIGN(${ARCH_WIDTH})
169+
{
170+
. = ALIGN(${ARCH_WIDTH});
171+
__suninit = .;
172+
*(.uninit .uninit.*);
173+
. = ALIGN(${ARCH_WIDTH});
174+
__euninit = .;
175+
} > REGION_BSS
176+
164177
/* fictitious region that represents the memory available for the heap */
165178
.heap (NOLOAD) : ALIGN(4)
166179
{

0 commit comments

Comments
 (0)