public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Fix AArch32 semihosting SYS_EXIT call on semihosting v1.
Date: Wed, 11 Jul 2018 15:18:00 -0000	[thread overview]
Message-ID: <20180711151818.95554.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=430b52911102a2ee48f1857954f2aeacc5b56dc6

commit 430b52911102a2ee48f1857954f2aeacc5b56dc6
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Wed Jul 11 13:26:16 2018 +0100

    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>

Diff:
---
 libgloss/arm/_kill.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgloss/arm/_kill.c b/libgloss/arm/_kill.c
index fc77e80..278ded7 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


                 reply	other threads:[~2018-07-11 15:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180711151818.95554.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).