Instead of using the function number (which is always zero), fetch the
application-provided exit code argument and pass that to the two exit
functions.

Signed-off-by: Keith Packard <kei...@keithp.com>
---
 target/nios2/nios2-semi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
index 3738774976..ffd1f095f6 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -133,8 +133,9 @@ void do_nios2_semihosting(CPUNios2State *env)
     args = env->regs[R_ARG1];
     switch (nr) {
     case HOSTED_EXIT:
-        gdb_exit(env->regs[R_ARG0]);
-        exit(env->regs[R_ARG0]);
+        GET_ARG(0);
+        gdb_exit(arg0);
+        exit(arg0);
 
     case HOSTED_OPEN:
         GET_ARG(0);
-- 
2.40.1


Reply via email to