riscv-newlib icon indicating copy to clipboard operation
riscv-newlib copied to clipboard

crt0.S does not get argv[] using SYS_GETCMDLINE

Open ilg-ul opened this issue 2 years ago • 0 comments

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.

ilg-ul avatar Jul 21 '22 19:07 ilg-ul