Use a specific symbol for data source address in flash

That way, data source address does not depend on any other unrelated change in
linker script.

This also fixes cases when .data input section is aligned on 8 bytes.  The new
version does not provide any address for the output section so that it is
aligned to the strictest input section.  The _data_loadaddr symbol will
always take this alignment into account.
This commit is contained in:
Nicolas Schodet
2012-09-03 19:49:47 +02:00
parent 2a35377980
commit 74cd991e7e
14 changed files with 30 additions and 19 deletions

View File

@@ -52,12 +52,13 @@ SECTIONS
__exidx_end = .;
} >rom
.data : AT (__exidx_end) {
.data : {
_data = .;
*(.data*) /* Read-write initialized data */
. = ALIGN(4);
_edata = .;
} >ram
} >ram AT >rom
_data_loadaddr = LOADADDR(.data);
.bss : {
*(.bss*) /* Read-write zero initialized data */

View File

@@ -21,7 +21,7 @@
#define WEAK __attribute__ ((weak))
/* Symbols exported by the linker script(s): */
extern unsigned __exidx_end, _data, _edata, _ebss, _stack;
extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack;
void main(void);
void reset_handler(void);
@@ -224,7 +224,7 @@ void reset_handler(void)
__asm__("MSR msp, %0" : : "r"(&_stack));
for (src = &__exidx_end, dest = &_data; dest < &_edata; src++, dest++)
for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++)
*dest = *src;
while (dest < &_ebss)