From f72640d7233ed3c5ffb279d0ad9f4648fe6ac5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas=20Rodr=C3=ADguez?= Date: Sat, 12 Jul 2025 08:00:00 +0200 Subject: [PATCH] Add uninit section --- riscv-rt/CHANGELOG.md | 2 ++ riscv-rt/link.x.in | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/riscv-rt/CHANGELOG.md b/riscv-rt/CHANGELOG.md index fd8c0e80..6cd21c5a 100644 --- a/riscv-rt/CHANGELOG.md +++ b/riscv-rt/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - New `post-init` feature to run a Rust `__post_init` function before jumping to `main`. - New `#[riscv_rt::post_init]` attribute to aid in the definition of the `__post_init` function. +- Added `.uninit` section to the linker file. Due to its similarities with `.bss`, the + linker will place this new section in `REGION_BSS`. ### Changed diff --git a/riscv-rt/link.x.in b/riscv-rt/link.x.in index 636d6c05..16314860 100644 --- a/riscv-rt/link.x.in +++ b/riscv-rt/link.x.in @@ -161,6 +161,19 @@ SECTIONS . = ALIGN(${ARCH_WIDTH}); __ebss = .; + /* Uninitialized data segment. In contrast with .bss, .uninit is not initialized to zero by + * the runtime, and might contain residual data from previous executions or random values + * if not explicitly initialized. While .bss and .uninit are different sections, they are + * both allocated at REGION_BSS, as their purpose is similar. */ + .uninit (NOLOAD) : ALIGN(${ARCH_WIDTH}) + { + . = ALIGN(${ARCH_WIDTH}); + __suninit = .; + *(.uninit .uninit.*); + . = ALIGN(${ARCH_WIDTH}); + __euninit = .; + } > REGION_BSS + /* fictitious region that represents the memory available for the heap */ .heap (NOLOAD) : ALIGN(4) {