Source-Changes-HG archive

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

[src/trunk]: src/lib/libc Change cerror to take errno in r4, instead of r0.



details:   https://anonhg.NetBSD.org/src/rev/c84018759731
branches:  trunk
changeset: 586955:c84018759731
user:      uwe <uwe%NetBSD.org@localhost>
date:      Fri Jan 06 03:58:31 2006 +0000

description:
Change cerror to take errno in r4, instead of r0.
In PIC code fetch cerror address from GOT to avoid
unresolved text relocations in shared libraries.
Hide the code to jump to cerror inside JUMP_CERROR macro.
Change syscall code to use JUMP_CERROR.
Die text relocations! DIE!

diffstat:

 lib/libc/arch/sh3/SYS.h                           |  45 +++++++++++++---------
 lib/libc/arch/sh3/sys/__clone.S                   |   7 +--
 lib/libc/arch/sh3/sys/brk.S                       |  17 ++------
 lib/libc/arch/sh3/sys/cerror.S                    |  14 +++----
 lib/libc/arch/sh3/sys/fork.S                      |  24 ++---------
 lib/libc/arch/sh3/sys/ptrace.S                    |  18 ++-------
 lib/libc/arch/sh3/sys/sbrk.S                      |  18 ++-------
 lib/libc/compat/arch/sh3/sys/compat_sigprocmask.S |  21 ++--------
 lib/libc/compat/arch/sh3/sys/compat_sigsuspend.S  |  21 ++--------
 9 files changed, 62 insertions(+), 123 deletions(-)

diffs (truncated from 413 to 300 lines):

diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/SYS.h
--- a/lib/libc/arch/sh3/SYS.h   Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/SYS.h   Fri Jan 06 03:58:31 2006 +0000
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
- *     $NetBSD: SYS.h,v 1.7 2005/12/25 11:08:35 uwe Exp $
+ *     $NetBSD: SYS.h,v 1.8 2006/01/06 03:58:31 uwe Exp $
  */
 
 #include <machine/asm.h>
@@ -63,28 +63,37 @@
                SYSTRAP(y)
 
 #ifdef PIC
+
+#define JUMP_CERROR                                    \
+               mov     r0, r4;                         \
+               mov.l   912f, r1;                       \
+               mova    912f, r0;                       \
+               mov.l   913f, r2;                       \
+               add     r1, r0;                         \
+               mov.l   @(r0, r2), r3;                  \
+               jmp     @r3;                            \
+                nop;                                   \
+               .align  2;                              \
+       912:    .long   _GLOBAL_OFFSET_TABLE_;          \
+       913:    .long   PIC_GOT(cerror)
+
+#else  /* !PIC */
+
+#define JUMP_CERROR                                    \
+               mov.l   912f, r3;                       \
+               jmp     @r3;                            \
+                mov    r0, r4;                         \
+               .align  2;                              \
+       912:    .long   cerror
+
+#endif /* !PIC */
+
 #define _SYSCALL(x,y)                                  \
                .text;                                  \
-       911:    mov.l   912f, r3;                       \
-               braf    r3;                             \
-                nop;                                   \
-               .align  2;                              \
-       912:    .long   cerror-(911b+6);                \
+       911:    JUMP_CERROR;                            \
                _SYSCALL_NOERROR(x,y);                  \
                bf      911b;                           \
                nop
-#else
-#define _SYSCALL(x,y)                                  \
-               .text;                                  \
-       911:    mov.l   912f, r3;                       \
-               jmp     @r3;                            \
-                nop;                                   \
-               .align  2;                              \
-       912:    .long   cerror;                         \
-               _SYSCALL_NOERROR(x,y);                  \
-               bf      911b;                           \
-               nop
-#endif
 
 #define SYSCALL_NOERROR(x)                             \
                _SYSCALL_NOERROR(x,x)
diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/sys/__clone.S
--- a/lib/libc/arch/sh3/sys/__clone.S   Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/sys/__clone.S   Fri Jan 06 03:58:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __clone.S,v 1.5 2006/01/05 19:28:50 uwe Exp $  */
+/*     $NetBSD: __clone.S,v 1.6 2006/01/06 03:58:31 uwe Exp $  */
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.  All rights reserved.
@@ -74,9 +74,7 @@
 inval:
        mov     #EINVAL, r0
 err:
-       mov.l   .L_cerror, r1
-2:     JUMP    r1
-        nop
+       JUMP_CERROR
        /* NOTREACHED */
 
 3:     rts
@@ -87,5 +85,4 @@
 
 .L_got:                PIC_GOT_DATUM
 .L__exit:      CALL_DATUM(_C_LABEL(_exit), 1b)
-.L_cerror:     CALL_DATUM_LOCAL(cerror, 2b)
        SET_ENTRY_SIZE(__clone)
diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/sys/brk.S
--- a/lib/libc/arch/sh3/sys/brk.S       Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/sys/brk.S       Fri Jan 06 03:58:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: brk.S,v 1.9 2003/08/07 16:42:20 agc Exp $      */
+/*     $NetBSD: brk.S,v 1.10 2006/01/06 03:58:31 uwe Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
 
 #include <machine/asm.h>
 #if defined(SYSLIBC_SCCS) && !defined(lint)
-       RCSID("$NetBSD: brk.S,v 1.9 2003/08/07 16:42:20 agc Exp $")
+       RCSID("$NetBSD: brk.S,v 1.10 2006/01/06 03:58:31 uwe Exp $")
 #endif /* SYSLIBC_SCCS and not lint */
 
 #include "SYS.h"
@@ -83,15 +83,7 @@
        rts
        mov.l   r4, @r1
 err:
-       mov.l   Lcerror, r1
-#ifdef PIC
-       braf    r1
-#else
-       jmp     @r1
-#endif
-       nop
-2:
-
+       JUMP_CERROR
 
        .align  2
 LSYS_break:    .long   SYS_break
@@ -99,9 +91,8 @@
 L_GOT:         .long   _GLOBAL_OFFSET_TABLE_
 Lminbrk:       .long   _C_LABEL(__minbrk)@GOT
 Lcurbrk:       .long   curbrk@GOT
-Lcerror:       .long   cerror-2b
 #else
 Lminbrk:       .long   _C_LABEL(__minbrk)
 Lcurbrk:       .long   curbrk
-Lcerror:       .long   cerror
 #endif
+       SET_ENTRY_SIZE(_brk)
diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/sys/cerror.S
--- a/lib/libc/arch/sh3/sys/cerror.S    Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/sys/cerror.S    Fri Jan 06 03:58:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cerror.S,v 1.8 2006/01/05 23:10:35 uwe Exp $   */
+/*     $NetBSD: cerror.S,v 1.9 2006/01/06 03:58:31 uwe Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
 
 #include <machine/asm.h>
 #if defined(SYSLIBC_SCCS) && !defined(lint)
-       RCSID("$NetBSD: cerror.S,v 1.8 2006/01/05 23:10:35 uwe Exp $")
+       RCSID("$NetBSD: cerror.S,v 1.9 2006/01/06 03:58:31 uwe Exp $")
 #endif /* SYSLIBC_SCCS and not lint */
 
 #include "SYS.h"
@@ -49,15 +49,14 @@
        .align  2
 cerror:
        mov.l   .L___errno, r1
-       mov.l   r0, @-sp        ! save error code
        PIC_PROLOGUE(.L_got)
        sts.l   pr, @-sp
 1:     CALL    r1
-        nop
+        mov.l  r4, @-sp        ! save error code
+       mov.l   @sp+, r4
        lds.l   @sp+, pr
        PIC_EPILOGUE
-       mov.l   @sp+, r2        ! restore error code
-       mov.l   r2, @r0
+       mov.l   r4, @r0
        mov     #-1, r1
        rts
         mov    #-1, r0
@@ -75,13 +74,12 @@
        .align  2
 cerror:
 #ifdef PIC
-       mov     r0, r2
        mova    L_GOT, r0
        mov.l   L_GOT, r1
        add     r0, r1
        mov.l   L_errno, r0
        mov.l   @(r0, r1), r1
-       mov.l   r2, @r1
+       mov.l   r4, @r1
 #else
        mov.l   L_errno, r1
        mov.l   r0, @r1
diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/sys/fork.S
--- a/lib/libc/arch/sh3/sys/fork.S      Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/sys/fork.S      Fri Jan 06 03:58:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fork.S,v 1.8 2003/08/07 16:42:21 agc Exp $     */
+/*     $NetBSD: fork.S,v 1.9 2006/01/06 03:58:31 uwe Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,32 +36,18 @@
 
 #include <machine/asm.h>
 #if defined(SYSLIBC_SCCS) && !defined(lint)
-       RCSID("$NetBSD: fork.S,v 1.8 2003/08/07 16:42:21 agc Exp $")
+       RCSID("$NetBSD: fork.S,v 1.9 2006/01/06 03:58:31 uwe Exp $")
 #endif /* SYSLIBC_SCCS and not lint */
 
 #include "SYS.h"
 
        .text
        .align  2
-2:     mov.l   1f, r3
-#ifdef PIC
-       braf    r3
-#else
-       jmp     @r3
-#endif
-       nop
-4:
+2:     JUMP_CERROR
+
        _SYSCALL_NOERROR(__fork,fork)
        bf      2b
-       bra     3f
-       nop
-       .align  2
-#ifdef PIC
-1:     .long   cerror-4b
-#else
-1:     .long   cerror
-#endif
-3:
+
        add     #0xff, r1       /* from 1 to 0 in child, 0 to -1 in parent */
        rts                     /* pid = fork(); */
        and     r1, r0
diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/sys/ptrace.S
--- a/lib/libc/arch/sh3/sys/ptrace.S    Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/sys/ptrace.S    Fri Jan 06 03:58:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptrace.S,v 1.6 2003/10/24 04:41:28 uwe Exp $   */
+/*     $NetBSD: ptrace.S,v 1.7 2006/01/06 03:58:31 uwe Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
 
 #include <machine/asm.h>
 #if defined(SYSLIBC_SCCS) && !defined(lint)
-       RCSID("$NetBSD: ptrace.S,v 1.6 2003/10/24 04:41:28 uwe Exp $")
+       RCSID("$NetBSD: ptrace.S,v 1.7 2006/01/06 03:58:31 uwe Exp $")
 #endif /* SYSLIBC_SCCS and not lint */
 
 #include "SYS.h"
@@ -59,24 +59,14 @@
        rts
        nop
 err:
-       mov.l   Lcerror, r1
-#ifdef PIC
-       braf    r1
-#else
-       jmp     @r1
-#endif
-       nop
-1:
+       JUMP_CERROR
 
        .align  2
 LSYS_ptrace:   .long   SYS_ptrace
 #ifdef PIC
 L_GOT:         .long   _GLOBAL_OFFSET_TABLE_
 L_errno:       .long   _C_LABEL(errno)@GOT
-Lcerror:       .long   cerror-1b
 #else
 L_errno:       .long   _C_LABEL(errno)
-Lcerror:       .long   cerror
 #endif
-
-
+       SET_ENTRY_SIZE(ptrace)
diff -r 10aa5a667f77 -r c84018759731 lib/libc/arch/sh3/sys/sbrk.S
--- a/lib/libc/arch/sh3/sys/sbrk.S      Fri Jan 06 02:30:08 2006 +0000
+++ b/lib/libc/arch/sh3/sys/sbrk.S      Fri Jan 06 03:58:31 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbrk.S,v 1.8 2003/08/07 16:42:21 agc Exp $     */
+/*     $NetBSD: sbrk.S,v 1.9 2006/01/06 03:58:31 uwe Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
 
 #include <machine/asm.h>
 #if defined(SYSLIBC_SCCS) && !defined(lint)
-       RCSID("$NetBSD: sbrk.S,v 1.8 2003/08/07 16:42:21 agc Exp $")
+       RCSID("$NetBSD: sbrk.S,v 1.9 2006/01/06 03:58:31 uwe Exp $")
 #endif /* SYSLIBC_SCCS and not lint */
 
 #include "SYS.h"



Home | Main Index | Thread Index | Old Index