NOLOAD is a linker-script directive for a section that occupies memory at runtime but does not need its contents stored in the firmware image. It is useful for zero-initialized data, provided startup code or another guarantee establishes the required initial values. section 4.1.3 section 5.4.4
For ordinary writable data, .bss is placed in RAM and marked NOLOAD; startup code zeroes it before the program runs. By contrast, .data has initial values stored in FLASH and must be copied to RAM during startup. section 4.1.3
.data :
{
*(.data .data.*)
} > RAM AT > FLASH
.bss (NOLOAD) :
{
. = ALIGN(8);
*(.bss .bss.*)
} > RAM
}
This linker script places .data in RAM with its initial contents in FLASH. It places .bss in RAM with NOLOAD and aligns it to an 8-byte boundary. section 4.1.3
Custom sections need special care. A Rust static can use #[unsafe(link_section)] to select a dedicated section, and the linker script can map that section to DTCM with NOLOAD. cortex-m-rt automatically initializes the standard .bss and .data sections, not custom sections. Arrange explicit initialization where needed, or ensure the custom data is genuinely zero-initialized. For nonzero initial values, arrange storage in FLASH and copying to DTCM during startup. section 5.4.4
MEMORY {
ITCM : ORIGIN = 0x00000000, LENGTH = 64K
DTCM : ORIGIN = 0x20000000, LENGTH = 64K
FLASH : ORIGIN = 0x08000000, LENGTH = 1M
}
SECTIONS {
.tcm_data (NOLOAD) : ALIGN(4) {
KEEP(*(.tcm_data*))
} > DTCM
}
The .tcm_data section occupies DTCM without storing its contents in the firmware image. This example targets devices with DTCM, such as the Cortex-M7-based STM32F746 or STM32H743. section 5.4.4
