public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Anthony Green <green@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Fix setjmp/longjmp for the moxie port. Date: Fri, 13 Dec 2019 18:09:00 -0000 [thread overview] Message-ID: <20191213180910.96947.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=31227ba53d39ec1dac19a488c967ebbe9a04c19a commit 31227ba53d39ec1dac19a488c967ebbe9a04c19a Author: Anthony Green <green@moxielogic.com> Date: Fri Dec 13 13:08:06 2019 -0500 Fix setjmp/longjmp for the moxie port. These functions needs to save and restore the stack frame, because that's where the return address is stored. Diff: --- newlib/libc/include/machine/setjmp.h | 2 +- newlib/libc/machine/moxie/setjmp.S | 71 ++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h index 25fdea2..78a81b5 100644 --- a/newlib/libc/include/machine/setjmp.h +++ b/newlib/libc/include/machine/setjmp.h @@ -238,7 +238,7 @@ _BEGIN_STD_C #endif #ifdef __moxie__ -#define _JBLEN 16 +#define _JBLEN 19 #endif #ifdef __CRX__ diff --git a/newlib/libc/machine/moxie/setjmp.S b/newlib/libc/machine/moxie/setjmp.S index 6c2c015..ed261d5 100644 --- a/newlib/libc/machine/moxie/setjmp.S +++ b/newlib/libc/machine/moxie/setjmp.S @@ -1,5 +1,5 @@ /* A setjmp.c for Moxie - Copyright (C) 2009 Anthony Green + Copyright (C) 2009, 2019 Anthony Green The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided @@ -12,28 +12,31 @@ they apply. */ # setjmp/longjmp for moxie. The jmpbuf looks like this: -# -# Register jmpbuf offset -# $r0 0x00 -# $r1 0x04 -# $r2 0x08 -# $r3 0x0c -# $r4 0x10 -# $r5 0x14 -# $r6 0x18 -# $r7 0x1c -# $r8 0x20 -# $r9 0x24 -# $r10 0x28 -# $r11 0x2c -# $r12 0x30 -# $r13 0x34 -# $fp 0x38 -# $sp 0x3c - - .text - .global setjmp - .type setjmp,@function +# +# Register jmpbuf offset +# $r0 0x00 +# $r1 0x04 +# $r2 0x08 +# $r3 0x0c +# $r4 0x10 +# $r5 0x14 +# $r6 0x18 +# $r7 0x1c +# $r8 0x20 +# $r9 0x24 +# $r10 0x28 +# $r11 0x2c +# $r12 0x30 +# $r13 0x34 +# $fp 0x38 +# $sp 0x3c +# stack frame fp 0x40 +# stack frame ra 0x44 +# stack frame sc 0x48 + + .text + .global setjmp + .type setjmp,@function setjmp: st.l ($r0), $r0 sto.l 0x04($r0), $r1 @@ -51,6 +54,13 @@ setjmp: sto.l 0x34($r0), $r13 sto.l 0x38($r0), $sp sto.l 0x3c($r0), $fp + ldo.l $r1, 0x0($fp) + sto.l 0x40($r0), $r1 + ldo.l $r1, 0x04($fp) + sto.l 0x44($r0), $r1 + ldo.l $r1, 0x08($fp) + sto.l 0x48($r0), $r1 + ldo.l $r1, 0x04($r0) xor $r0, $r0 ret .Lend1: @@ -62,7 +72,6 @@ longjmp: ldi.l $r2, 0x00 cmp $r1, $r2 beq .Lreturn1 - ldo.l $r1, 0x04($r0) ldo.l $r2, 0x08($r0) ldo.l $r3, 0x0c($r0) ldo.l $r4, 0x10($r0) @@ -77,6 +86,13 @@ longjmp: ldo.l $r13, 0x34($r0) ldo.l $sp, 0x38($r0) ldo.l $fp, 0x3c($r0) + ldo.l $r1, 0x40($r0) + sto.l 0x0($fp), $r1 + ldo.l $r1, 0x44($r0) + sto.l 0x4($fp), $r1 + ldo.l $r1, 0x48($r0) + sto.l 0x8($fp), $r1 + ldo.l $r1, 0x04($r0) mov $r0, $r1 ret .Lreturn1: @@ -95,6 +111,13 @@ longjmp: ldo.l $r13, 0x34($r0) ldo.l $sp, 0x38($r0) ldo.l $fp, 0x3c($r0) + ldo.l $r1, 0x40($r0) + sto.l 0x0($fp), $r1 + ldo.l $r1, 0x44($r0) + sto.l 0x4($fp), $r1 + ldo.l $r1, 0x48($r0) + sto.l 0x8($fp), $r1 + ldo.l $r1, 0x04($r0) ldi.l $r0, 0x01 ret .Lend2:
reply other threads:[~2019-12-13 18:09 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=20191213180910.96947.qmail@sourceware.org \ --to=green@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: linkBe 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).