From 54319107b0d2a89d5b998bbe87d2470adf18c4c5 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Sun, 11 Oct 2020 22:39:00 +0000 Subject: [PATCH] ld: support ".noinit*" uninitialized ram section Add support for a section(s) ".noinit*" that will be allocated in ram, but not cleared or initialized. This can be used for passing variables between a bootloader and an app for instance, or even just between restarts of your application. Without any assigned usages of the section, there is zero change in ram usage. The align does nothing when the prior section was already aligned. --- ld/linker.ld.S | 6 ++++++ lib/cortex-m-generic.ld | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ld/linker.ld.S b/ld/linker.ld.S index 908ad9ea..84c1cd18 100644 --- a/ld/linker.ld.S +++ b/ld/linker.ld.S @@ -118,6 +118,12 @@ SECTIONS . = ALIGN(4); _etext = .; + /* ram, but not cleared on reset, eg boot/app comms */ + .noinit (NOLOAD) : { + *(.noinit*) + } >ram + . = ALIGN(4); + .data : { _data = .; *(.data*) /* Read-write initialized data */ diff --git a/lib/cortex-m-generic.ld b/lib/cortex-m-generic.ld index fc169764..8b995d35 100644 --- a/lib/cortex-m-generic.ld +++ b/lib/cortex-m-generic.ld @@ -89,6 +89,12 @@ SECTIONS . = ALIGN(4); _etext = .; + /* ram, but not cleared on reset, eg boot/app comms */ + .noinit (NOLOAD) : { + *(.noinit*) + } >ram + . = ALIGN(4); + .data : { _data = .; *(.data*) /* Read-write initialized data */