RISC-V: Stack pointer initialization in crt0
Christian Herber <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <GV1PR04MB95138ED8C375CA6CA4A074C986142@GV1PR04MB9513.eurprd04.prod.outlook.com> |
Newlib works great when building a linux user space executable. However, if you want to run something baremetal in M-mode, the standard startup is a roadblock because of the lack of stack pointer initialization. I see there had been discussion on this topic here: https://github.com/riscvarchive/riscv-newlib/issues/39 I dislike the current situation as it puts an unnecessary obstacle for users e.g. switching from Arm to RISC-V. As a user, especially if I build with -spec=nosys.spec, it is strange if the startup assumes an operating system has initialized the stack pointer. This recent reddit thread shows the situation quite well: https://www.reddit.com/r/RISCV/comments/1hjbxyd/running_an_mmode_rv32_cprogram_on_qemu/