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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user