Comment 3 for bug 1216845

Revision history for this message
Peter Maydell (pmaydell) wrote : Re: [Qemu-devel] [Bug 1216845] Re: qemu-system-arm semihosting always calls exit(0)

On 4 February 2015 at 15:56, Karl Zimmerman
<email address hidden> 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