riscv-newlib
riscv-newlib copied to clipboard
crt0.S does not get argv[] using SYS_GETCMDLINE
The startup code expects the main()
arguments to be processed by someone else and does not call SYS_GETCMDLINE
to get them, as specified by Arm semihosting:
This might work on some specific platforms, but generally it fails, since that area is right after the stack, usually an invalid memory region.
The workaround for semihosted applications it to rewrite the startup code.
The solution for newlib is to replicate the logic used by the Arm startup code, which processes the arguments properly.
It might also be a good idea to call SYS_HEAPINFO
and properly process the heap/stack.