NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-sh3/49597: swapcontext(3) stack pointer problem on NetBSD/sh3



The following reply was made to PR port-sh3/49597; it has been noted by GNATS.

From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: port-sh3/49597: swapcontext(3) stack pointer problem on NetBSD/sh3
Date: Thu, 22 Jan 2015 17:52:15 +0300

 On Thu, Jan 22, 2015 at 14:05:00 +0000, oshima-ya%yagoto-urayama.jp@localhost wrote:
 
 > --- lib/libc/arch/sh3/gen/swapcontext.S 12 Sep 2013 15:36:15 -0000      1.10
 > +++ lib/libc/arch/sh3/gen/swapcontext.S 21 Jan 2015 15:30:08 -0000
 > @@ -53,6 +53,11 @@
 >         /* Note: getcontext does _UC_MACHINE_INTRV(oucp) = 0 for us */
 >         mov.l   @sp, r0
 >         mov.l   r0, @(36 + 1 * 4, r1)   /* _UC_MACHINE_SET_PC(oucp, pr) */
 > +       /* Adjust stack pointer */
 > +       mov     sp, r2
 > +#ifdef __PIC__
 > +       add     #12, r2                 /* for 2 -sp + PIC_PROLOGUE */
 > +#else
 > +       add     #8, r2                  /* for 2 -sp */
 > +#endif
 > +       mov     #(36 + 21 * 4), r0      /* offset _UC_MACHINE_SP(oucp) */
 > +       mov.l   r2, @(r0, r1)           /* store SP */
 >         mov.l   .L_setcontext, r2
 >  2:     CALL    r2                      /* setcontext(ucp) */
 >          mov.l  @(4, sp), r4
 
 Have you tested this?
 
 From a quick look, getcontext() captures the state that has not two,
 but three registers in the stack - including mov.l r4, @-sp in the
 delay slot of the CALL, doesn't it?
 
 -uwe
 


Home | Main Index | Thread Index | Old Index