cc2538: Fix .data LMA/VMA mismatch with some toolchains

Some toolchains, like Sourcery CodeBench Lite 2013.05-23 arm-none-eabi
(http://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/)
automatically force the alignment of an output section LMA to use the
maximum alignment of all its input sections. This toolchain uses GNU
binutils 2.23, and this automatic behavior is the same as the manual
behavior of the ALIGN_WITH_INPUT feature of GNU binutils 2.24+.

This behavior is not an issue per se, but it creates a gap between
_etext and the LMA of the .data output section if _etext does not have
the same alignment, while reset_handler() initialized this section by
copying the data from _etext to its VMA, hence an offset in the
addresses of loaded data, and missing data.

This commit fixes this issue by making reset_handler() directly use the
LMA of the .data section using LOADADDR(.data), rather than assuming
that _etext is this LMA.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
This commit is contained in:
Benoît Thébaudeau 2015-05-17 21:07:10 +02:00
parent 630b7f8963
commit 0d260f61a0
2 changed files with 3 additions and 2 deletions

View file

@ -91,6 +91,7 @@ SECTIONS
*(.data*)
_edata = .;
} > SRAM AT > FLASH
_ldata = LOADADDR(.data);
.ARM.exidx :
{

View file

@ -275,7 +275,7 @@ void(*const vectors[])(void) =
};
/*---------------------------------------------------------------------------*/
/* Linker constructs indicating .data and .bss segment locations */
extern unsigned long _etext;
extern unsigned long _ldata;
extern unsigned long _data;
extern unsigned long _edata;
extern unsigned long _bss;
@ -303,7 +303,7 @@ reset_handler(void)
REG(SYS_CTRL_EMUOVR) = 0xFF;
/* Copy the data segment initializers from flash to SRAM. */
pul_src = &_etext;
pul_src = &_ldata;
for(pul_dst = &_data; pul_dst < &_edata;) {
*pul_dst++ = *pul_src++;