On 4 February 2015 at 15:56, Karl Zimmerman <karl.erik.zimmer...@gmail.com> wrote: > Had a similar problem with my emulation environment. However, I did > some inspection of the assembly code generated by newlib for ARM semi- > hosting. While it initially appears that exit() and _exit() discard the > status code, upon careful inspection one finds that it is pushed on the > stack, with the SP pointing right to it at the point at which the SWI is > executed. > > Thus, if the code passed to 0x18 is 0x20026, you can fetch the status > code passed to exit() from the stack.
Yes, but this is an internal implementation detail of newlib, not a part of the semihosting ABI. It might well change in different versions of newlib and we can't rely on it. -- PMM