Memory alignment places data at addresses that satisfy the target architecture’s requirements. An address aligned to 8 bytes is a multiple of 8. In bare-metal Rust, alignment is part of the memory layout established before main() runs. section 4.1.1 section 4.1.3
On Arm Cortex-M, the initial stack pointer must be 8-byte aligned under the Arm ABI followed by Rust. This matters for 64-bit local variables and function arguments such as u64 and f64. Incorrect alignment can cause unaligned accesses, faults, or data corruption. section 4.1.3
The .bss section should also be aligned to an 8-byte boundary, as should other data sections where possible, so that 64-bit static variables are correctly aligned. A linker script can use ALIGN(8) to align its location counter before placing section contents. section 4.1.3
.data :
{
*(.data .data.*)
} > RAM AT > FLASH
.bss (NOLOAD) :
{
. = ALIGN(8);
*(.bss .bss.*)
} > RAM
}
The linker script aligns the location counter before placing .bss inputs. It also places .data in RAM with its initial contents loaded from FLASH. section 4.1.3
Alignment does not replace startup initialization. Before main(), startup code must copy .data from FLASH to RAM and zero .bss, unless a runtime crate handles those steps. Check the final memory layout with cargo objdump, and verify the stack address separately from the data sections. section 4.1.1 section 4.1.3




