expression

Distinguish section load and run addresses

A linker may give initialized data one location in the load image and another location in RAM during execution. Startup uses the load image to initialize the run region before ordinary Rust code accesses statics. This arithmetic fixture uses imaginary addresses and demonstrates the span, not a real MCU startup routine. Expected host stdout (not executed): load: 0x1000..0x1004 run: 0x8000..0x8004 Common mistake: Assuming a section always has the same load and execution address.

Formal Syntax & Structure

rust syntaxrust
VMA / LMA; LOADADDR(.data)

Working Example

Example Snippetrust
fn main() {    let load = 0x1000u32;    let run = 0x8000u32;    let len = 4u32;    println!("load: {load:#06x}..{:#06x}", load + len);    println!("run: {run:#06x}..{:#06x}", run + len);}
Rust Reference