From 0de729572b70dca479cf4627b01e08c03e24d7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Sun, 17 May 2015 21:34:01 +0200 Subject: [PATCH] cc2538: Word-align .data LMA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to be fast, the reset_handler() function uses word accesses to initialize the .data output section. However, most toolchains do not automatically force the alignment of an output section LMA to use the maximum alignment of all its input sections. Because of that, assuming that .data contains some words, the LMA of the .data output section was not word-aligned in some cases, resulting in an initialization performed using slow unaligned word accesses. This commit forces the alignment of the LMA of the .data output section with a word boundary in order to always use fast aligned word accesses to read the .data load area. Note that this solution is better than using ALIGN_WITH_INPUT, both because the latter is a new feature incompatible with older toolchains, and because it could create a big gap between _etext and the LMA of .data if strongly-aligned data were added to .data, although only a word alignment is required here. The same considerations apply to the VMA of .data. However, it is already automatically word-aligned, both because .data contains words, and because the end VMA of the previous output section (.socdata) is word-aligned. Moreover, if the VMA of .data were forcibly word-aligned, then a filled gap could appear at the beginning of this section if strongly-aligned data were added to it, thus wasting flash memory. Consequently, it's better not to change anything for the VMA of .data, all the more it's very unlikely that it does not contain any word and that the end VMA of .socdata becomes non-word-aligned, and this would only result in a slower initialization. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/cc2538.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cc2538/cc2538.lds b/cpu/cc2538/cc2538.lds index 0ca3a2550..84908bd60 100644 --- a/cpu/cc2538/cc2538.lds +++ b/cpu/cc2538/cc2538.lds @@ -85,7 +85,7 @@ SECTIONS *(.udma_channel_control_table) } > SRAM - .data : + .data : ALIGN(4) { _data = .; *(.data*)