From 28dbe9a04b16f79db255baecbf0cd486c510ef58 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 12 Dec 2017 15:31:27 -0800 Subject: altos/stm: Align 'data' to 8 bytes, just like textram The textram section must be aligned to 8 bytes to keep the linker happy. However, if that section contains no data, the declaration will set the __data_start__ value to that alignment, but the data section itself would start on a 4-byte alignment, potentially 4 bytes lower than the value indicated by __data_start__. This completely scrambles initialized memory as the startup code will copy the data segment to __data_start__, 4 bytes off of the actual data segment start. Fix this by forcing the data segment to also be aligned to 8 bytes. Signed-off-by: Keith Packard --- src/stm/altos-loader.ld | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/stm') diff --git a/src/stm/altos-loader.ld b/src/stm/altos-loader.ld index a4a7dc43..806b4842 100644 --- a/src/stm/altos-loader.ld +++ b/src/stm/altos-loader.ld @@ -72,8 +72,9 @@ SECTIONS { } >ram AT>rom /* Data -- relocated to RAM, but written to ROM + * Also aligned to 8 bytes to agree with textram */ - .data : { + .data BLOCK(8): { *(.data) /* initialized data */ __data_end__ = .; } >ram AT>rom -- cgit v1.2.3