Source-Changes-HG archive

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

[src/netbsd-9]: src/lib/libc/arch/mips/sys Pull up following revision(s) (req...



details:   https://anonhg.NetBSD.org/src/rev/de2616ebd85f
branches:  netbsd-9
changeset: 964281:de2616ebd85f
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Feb 06 15:30:14 2021 +0000

description:
Pull up following revision(s) (requested by simonb in ticket #1199):

        lib/libc/arch/mips/sys/cerror.S: revision 1.20

For mips n32/n64 explicitly save the GP reg on the stack, and
restore it _after_ the call to __errno().  Fixes sending the
__errno() call off to nowhereland when this code is included
in another library (eg __posix_cerror() in libposix).  Failure
picked up by the ATF lib/libposix/posix1/t_rename test.

diffstat:

 lib/libc/arch/mips/sys/cerror.S |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 391789a538b4 -r de2616ebd85f lib/libc/arch/mips/sys/cerror.S
--- a/lib/libc/arch/mips/sys/cerror.S   Thu Feb 04 19:31:25 2021 +0000
+++ b/lib/libc/arch/mips/sys/cerror.S   Sat Feb 06 15:30:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cerror.S,v 1.19 2013/09/12 15:36:15 joerg Exp $        */
+/*     $NetBSD: cerror.S,v 1.19.28.1 2021/02/06 15:30:14 martin Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
        RCSID("from: @(#)cerror.s       8.1 (Berkeley) 6/16/93")
 #else
-       RCSID("$NetBSD: cerror.S,v 1.19 2013/09/12 15:36:15 joerg Exp $")
+       RCSID("$NetBSD: cerror.S,v 1.19.28.1 2021/02/06 15:30:14 martin Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -50,24 +50,33 @@
        .globl  _C_LABEL(__errno)
 NESTED_NOPROFILE(__cerror, CALLFRAME_SIZ, ra)
        .mask   0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
-       PIC_PROLOGUE(__cerror)
+       PIC_PROLOGUE(__cerror)          # saves caller gp in t3 (n32/n64)
        PTR_SUBU        sp, CALLFRAME_SIZ
        PTR_S           ra, CALLFRAME_RA(sp)
        INT_S           v0, CALLFRAME_S0(sp)    # save errno value
+#if defined(__mips_n32) || defined(__mips_n64)
+       PTR_S           t3, CALLFRAME_GP(sp)    # save caller gp (in t3)
+#endif
 
        SAVE_GP(CALLFRAME_GP)
 
        PTR_LA          t9, _C_LABEL(__errno)   # locate address of errno
-       RESTORE_GP64                            # restore GP (from t3)
+
        jalr            t9                      # __errno()
 
+#if defined(__mips_n32) || defined(__mips_n64)
+       PTR_L           gp, CALLFRAME_GP(sp)    # restore caller gp
+#endif
        INT_L           t0, CALLFRAME_S0(sp)
        PTR_L           ra, CALLFRAME_RA(sp)
        INT_S           t0, 0(v0)               # update errno value
        PTR_ADDU        sp, CALLFRAME_SIZ
        li              v0, -1
        li              v1, -1
-       j               ra                      # GP has been restored.
+
+       # Note we don't use PIC_RETURN() here as the GP is stored
+       # on the stack and not in the t3 reg (for the n32/n64 case).
+       j               ra
 END(__cerror)
 #else          
        .globl  _C_LABEL(errno)



Home | Main Index | Thread Index | Old Index