Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2018-07-11 15:26:16 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-07-11 18:18:04 +0300
commit430b52911102a2ee48f1857954f2aeacc5b56dc6 (patch)
treec1ca8faf7ee91b68a222c2f1558c89575f55a5a3 /libgloss/arm
parent81dc535bb9e0196203e706caa533713306b4fc2c (diff)
Fix AArch32 semihosting SYS_EXIT call on semihosting v1.
The current SYS_EXIT has a bug that when making the call it always uses the v2 calling convention. This is undefined behavior according to the semihosting specification: https://developer.arm.com/docs/100863/latest/semihosting-operations/sys_exit-0x18 This patch fixes it by making sure v1 passes the argument directly in the register instead of in a block. And for v2 it does the same if the v2 extension isn't supported. The sequence generated now is 12424: ebfffecd bl 11f60 <_has_ext_exit_extended> 12428: e3500000 cmp r0, #0 1242c: 11a0500d movne r5, sp 12430: 059d5000 ldreq r5, [sp] 12434: e1a00004 mov r0, r4 12438: e1a01005 mov r1, r5 1243c: ef00f000 svc 0x0000f000 Signed-off-by: Tamar Christina <tamar.christina@arm.com>
Diffstat (limited to 'libgloss/arm')
-rw-r--r--libgloss/arm/_kill.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libgloss/arm/_kill.c b/libgloss/arm/_kill.c
index fc77e8097..278ded73a 100644
--- a/libgloss/arm/_kill.c
+++ b/libgloss/arm/_kill.c
@@ -39,7 +39,13 @@ _kill (int pid, int sig)
}
}
+#if SEMIHOST_V2
+if (_has_ext_exit_extended ())
return do_AngelSWI (insn, block);
+else
+#endif
+ return do_AngelSWI (insn, (void*)block[0]);
+
#else
asm ("swi %a0" :: "i" (SWI_Exit));
#endif