Add proper C runtime init, add reset handler.

The C runtime wasn't initialized correctly (there was garbage in the data
and bss sections). Add a reset_handler which initializes these sections
before calling the application's main() function.

The initial stack pointer is also defined in the linker script, allowing the
application to override with a linker command line option
"-Wl,--defsym,_stack=0x20005000".

Thanks to Gareth McMullin <gareth@blacksphere.co.nz>.
This commit is contained in:
Uwe Hermann
2010-10-19 02:00:28 +02:00
parent 68b7e255ad
commit 1621fde1f4
2 changed files with 31 additions and 2 deletions

View File

@@ -33,15 +33,25 @@ SECTIONS
*(.vectors) /* Vector table */
*(.text) /* Program code */
*(.rodata) /* Read-only data */
_etext = .;
} >rom
. = ORIGIN(ram);
.data : {
_data = .;
*(.data) /* Read-write initialized data */
_edata = .;
} >ram AT >rom
.bss : {
*(.bss) /* Read-write zero initialized data */
*(COMMON)
_ebss = .;
} >ram AT >rom
end = .;
}
PROVIDE(_stack = 0x20000800);