Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/arch/powerpc Switch to the PIC_GOTSETUP/PIC_TOCSETU...



details:   https://anonhg.NetBSD.org/src/rev/566752f51dc3
branches:  trunk
changeset: 760893:566752f51dc3
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jan 16 02:43:10 2011 +0000

description:
Switch to the PIC_GOTSETUP/PIC_TOCSETUP macros for PIC code.  Now libc
will be built to use secureplt by default.

diffstat:

 lib/libc/arch/powerpc/Makefile.inc      |   5 +-
 lib/libc/arch/powerpc/gen/swapcontext.S |  39 +++++++++++++++---------
 lib/libc/arch/powerpc/string/bzero.S    |  51 ++++++++++++++------------------
 lib/libc/arch/powerpc/sys/__clone.S     |   7 +++-
 lib/libc/arch/powerpc/sys/brk.S         |  10 ++---
 lib/libc/arch/powerpc/sys/cerror.S      |  16 +++++++---
 lib/libc/arch/powerpc/sys/ptrace.S      |  22 ++++++++-----
 lib/libc/arch/powerpc/sys/sbrk.S        |   7 +--
 8 files changed, 85 insertions(+), 72 deletions(-)

diffs (truncated from 384 to 300 lines):

diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/Makefile.inc
--- a/lib/libc/arch/powerpc/Makefile.inc        Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/Makefile.inc        Sun Jan 16 02:43:10 2011 +0000
@@ -1,7 +1,8 @@
-#      $NetBSD: Makefile.inc,v 1.11 2011/01/15 07:31:12 matt Exp $
+#      $NetBSD: Makefile.inc,v 1.12 2011/01/16 02:43:10 matt Exp $
 
 SRCS+=         __sigaction14_sigtramp.c __sigtramp2.S
-CPPFLAGS+=     -D_NOREGNAMES
+
+CPPFLAGS+=     -I. -D_NOREGNAMES
 
 .if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no")
 .include <softfloat/Makefile.inc>
diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/gen/swapcontext.S
--- a/lib/libc/arch/powerpc/gen/swapcontext.S   Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/gen/swapcontext.S   Sun Jan 16 02:43:10 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: swapcontext.S,v 1.5 2011/01/15 07:31:12 matt Exp $     */
+/*     $NetBSD: swapcontext.S,v 1.6 2011/01/16 02:43:10 matt Exp $     */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -32,30 +32,39 @@
 #include "SYS.h"
 #include "assym.h"
 
-__RCSID("$NetBSD: swapcontext.S,v 1.5 2011/01/15 07:31:12 matt Exp $")
+__RCSID("$NetBSD: swapcontext.S,v 1.6 2011/01/16 02:43:10 matt Exp $")
 
-#define        CALLFRAME_UCP   (CALLFRAMELEN - 1*SZREG)
-#define        CALLFRAME_OUCP  (CALLFRAMELEN - 2*SZREG)
+#define        XCALLFRAMELEN   (((2+3)*SZREG + CALLFRAMELEN - 1) & -CALLFRAMELEN)
+#define        XCALLFRAME_R30  (XCALLFRAMELEN-1*SZREG)
+#define        XCALLFRAME_UCP  (XCALLFRAMELEN-2*SZREG)
+#define        XCALLFRAME_OUCP (XCALLFRAMELEN-3*SZREG)
 
 ENTRY(swapcontext)
-       stwu    %r1,-CALLFRAMELEN(%r1)          # set up new stack frame
+       stwu    %r1,-XCALLFRAMELEN(%r1)         # set up new stack frame
        mflr    %r0
-       stw     %r0,CALLFRAMELEN+CALLFRAME_LR(%r1) # save link register
-       stw     %r3,CALLFRAME_OUCP(%r1)         # must save oucp
-       stw     %r4,CALLFRAME_UCP(%r1)          # must save ucp
+       stw     %r0,XCALLFRAMELEN+CALLFRAME_LR(%r1)     # save link register
+       stw     %r3,XCALLFRAME_OUCP(%r1)        # must save oucp
+       stw     %r4,XCALLFRAME_UCP(%r1)         # must save ucp
+#ifdef PIC
+       stw     %r30,XCALLFRAME_R30(%r1)        # must save r30
+       PIC_TOCSETUP(swapcontext,%r30)          # setup toc pointer
+#endif
        bl      PIC_PLT(_C_LABEL(_getcontext))  # getcontext(oucp)
        cmpwi   %r3,0
        bne     1f
-       lwz     %r11,CALLFRAME_OUCP(%r1)        # load oucp for adjustment
-       lwz     %r0,CALLFRAMELEN+CALLFRAME_LR(%r1)
+       lwz     %r11,XCALLFRAME_OUCP(%r1)       # load oucp for adjustment
+       lwz     %r0,XCALLFRAMELEN+CALLFRAME_LR(%r1)
        stw     %r0,UC_GREGS_PC(%r11)           # pc <- lr
-       addi    %r0,%r1,CALLFRAMELEN
-       stw     %r0,UC_GREGS_R1(%r11)           # save adjusted sp
-       lwz     %r3,CALLFRAME_UCP(%r1)          # load ucp
+       addi    %r0,%r1,XCALLFRAMELEN
+       stw     %r0,UC_GREGS_R1(%r11)           # adjust sp
+       lwz     %r3,XCALLFRAME_UCP(%r1)         # load ucp
        bl      PIC_PLT(_C_LABEL(setcontext))   # setcontext(ucp)
 1:
-       lwz     %r0,CALLFRAMELEN+CALLFRAME_LR(%r1)
+       lwz     %r0,XCALLFRAMELEN+CALLFRAME_LR(%r1)
+#ifdef PIC
+       lwz     %r30,XCALLFRAME_R30(%r1)
+#endif
        mtlr    %r0
-       addi    %r1,%r1,CALLFRAMELEN
+       addi    %r1,%r1,XCALLFRAMELEN
        blr
 END(swapcontext)
diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/string/bzero.S
--- a/lib/libc/arch/powerpc/string/bzero.S      Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/string/bzero.S      Sun Jan 16 02:43:10 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bzero.S,v 1.8 2011/01/15 07:31:12 matt Exp $ */
+/*     $NetBSD: bzero.S,v 1.9 2011/01/16 02:43:10 matt Exp $ */
 
 /*-
  * Copyright (C) 2001  Martin J. Laubach <mjl%NetBSD.org@localhost>
@@ -32,7 +32,7 @@
 
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: bzero.S,v 1.8 2011/01/15 07:31:12 matt Exp $")
+__RCSID("$NetBSD: bzero.S,v 1.9 2011/01/16 02:43:10 matt Exp $")
 #endif /* LIBC_SCCS && !lint */
 
 #ifdef _KERNEL
@@ -76,8 +76,7 @@
                /* First find out cache line size */
 #ifdef PIC
                mflr    %r9
-               bl      _GLOBAL_OFFSET_TABLE_@local-4
-               mflr    %r10
+               PIC_GOTSETUP(%r10)
                mtlr    %r9
                lwz     %r5,cache_info@got(%r10)
 #else
@@ -93,25 +92,34 @@
 #define CPU_CACHELINE  1
 #define        CPU_CACHEINFO   5
 
-#define STKFRAME_SZ    48
+#define STKFRAME_SZ    64
 #define MIB            8
 #define OLDPLEN                16
 #define R3_SAVE                20
 #define R4_SAVE                24
 #define R0_SAVE                28
 #define R8_SAVE                32
+#define R31_SAVE       36
+#ifdef PIC
+#define R30_SAVE       40
+#endif
 
-               mflr    %r6
-               stw     %r6, 4(%r1)
+               stw     %r9, 4(%r1)
                stwu    %r1, -STKFRAME_SZ(%r1)
 
+               stw     %r31, R31_SAVE(%r1)
+               mr      %r31, %r5               /* cache info */
+
+#ifdef PIC
+               stw     %r30, R30_SAVE(%r1)
+               PIC_TOCSETUP(cb_memset,%r30)
+#endif
+
                stw     %r8, R8_SAVE(%r1)
                stw     %r3, R3_SAVE(%r1)
                stw     %r4, R4_SAVE(%r1)
                stw     %r0, R0_SAVE(%r1)
 
-       
-
                li      %r0, CTL_MACHDEP                /* Construct MIB */
                stw     %r0, MIB(%r1)
                li      %r0, CPU_CACHEINFO
@@ -133,7 +141,7 @@
 
                /* Failure, try older sysctl */
        
-               li      %r0, CTL_MACHDEP                /* Construct MIB */
+               li      %r0, CTL_MACHDEP        /* Construct MIB */
                stw     %r0, MIB(%r1)
                li      %r0, CPU_CACHELINE
                stw     %r0, MIB+4(%r1)
@@ -143,17 +151,7 @@
 
                addi    %r3, %r1, MIB
                li      %r4, 2                  /* namelen */
-#ifdef PIC
-               mflr    %r9
-               bl      _GLOBAL_OFFSET_TABLE_@local-4
-               mflr    %r10
-               mtlr    %r9
-               lwz     %r5,cache_info@got(%r10)
-               addi    %r5, %r5, 4
-#else
-               lis     %r5,cache_info+4@h
-               ori     %r5,%r5,cache_info+4@l
-#endif
+               addi    %r5, %r31, 4
                addi    %r6, %r1, OLDPLEN
                li      %r7, 0
                li      %r8, 0
@@ -163,15 +161,10 @@
                lwz     %r3, R3_SAVE(%r1)
                lwz     %r4, R4_SAVE(%r1)
                lwz     %r0, R0_SAVE(%r1)
-
+               lwz     %r9, 4(%r31)
+               lwz     %r31, R31_SAVE(%r1)
 #ifdef PIC
-               bl      _GLOBAL_OFFSET_TABLE_@local-4
-               mflr    %r10
-               lwz     %r9, cache_info@got(%r10)
-               lwz     %r9, 4(%r9)
-#else
-               lis     %r5, cache_info+4@ha
-               lwz     %r9, cache_info+4@l(%r5)
+               lwz     %r30, R30_SAVE(%r1)
 #endif
                la      %r1, STKFRAME_SZ(%r1)
                lwz     %r5, 4(%r1)
diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/sys/__clone.S
--- a/lib/libc/arch/powerpc/sys/__clone.S       Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/sys/__clone.S       Sun Jan 16 02:43:10 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __clone.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */
+/*     $NetBSD: __clone.S,v 1.4 2011/01/16 02:43:10 matt Exp $ */
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.  All rights reserved.
@@ -30,7 +30,7 @@
 #include "SYS.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __clone.S,v 1.3 2011/01/15 07:31:12 matt Exp $")
+__RCSID("$NetBSD: __clone.S,v 1.4 2011/01/16 02:43:10 matt Exp $")
 #endif /* LIBC_SCCS && !lint */
 
 #ifdef WEAK_ALIAS
@@ -61,6 +61,9 @@
        mr      %r3,%r6         /* arg */
        blrl                    /* Call the clone's entry point. */
 
+#ifdef PIC
+       PIC_TOCSETUP(__clone, %r30)     /* exit won't return so blow away r30 */
+#endif
        bl      PIC_PLT(_C_LABEL(_exit))
 
 1:
diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/sys/brk.S
--- a/lib/libc/arch/powerpc/sys/brk.S   Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/sys/brk.S   Sun Jan 16 02:43:10 2011 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: brk.S,v 1.11 2011/01/15 07:31:12 matt Exp $    */
+/*     $NetBSD: brk.S,v 1.12 2011/01/16 02:43:10 matt Exp $    */
 
 #include "SYS.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: brk.S,v 1.11 2011/01/15 07:31:12 matt Exp $")
+__RCSID("$NetBSD: brk.S,v 1.12 2011/01/16 02:43:10 matt Exp $")
 #endif /* LIBC_SCCS && !lint */
 
        .globl  _C_LABEL(__curbrk)
@@ -19,12 +19,10 @@
        .long   _C_LABEL(_end)          # XXX not used yet
 
        .text
-
 ENTRY(_brk)
-#ifdef PIC
+#if defined(PIC)
        mflr    %r10
-       bl      _GLOBAL_OFFSET_TABLE_@local-4
-       mflr    %r9
+       PIC_GOTSETUP(%r9)
        mtlr    %r10
        lwz     %r5,_C_LABEL(_end)@got(%r9)
 #else
diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/sys/cerror.S
--- a/lib/libc/arch/powerpc/sys/cerror.S        Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/sys/cerror.S        Sun Jan 16 02:43:10 2011 +0000
@@ -1,10 +1,10 @@
-/*     $NetBSD: cerror.S,v 1.7 2011/01/15 07:31:13 matt Exp $  */
+/*     $NetBSD: cerror.S,v 1.8 2011/01/16 02:43:10 matt Exp $  */
 
 #include "SYS.h"
 #include "assym.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: cerror.S,v 1.7 2011/01/15 07:31:13 matt Exp $")
+__RCSID("$NetBSD: cerror.S,v 1.8 2011/01/16 02:43:10 matt Exp $")
 #endif /* LIBC_SCCS && !lint */
 
 #ifndef _REENTRANT
@@ -19,19 +19,25 @@
        mflr    %r0
        stwu    %r1,-CALLFRAMELEN(%r1)          # allocate new stack frame
        stw     %r0,CALLFRAMELEN+CALLFRAME_LR(%r1)
+#ifdef PIC
+       stw     %r30,CALLFRAME_R30(%r1)
+       PIC_TOCSETUP(__cerror, %r30)
+#endif
        stw     %r31,CALLFRAME_R31(%r1)
-       mr      %r31,%r3                        # stash away in callee-saved register
+       mr      %r31,%r3                # stash away in callee-saved register
        bl      PIC_PLT(_C_LABEL(__errno))
        stw     %r31,0(%r3)
        lwz     %r0,CALLFRAMELEN+CALLFRAME_LR(%r1)
        lwz     %r31,CALLFRAME_R31(%r1)
+#ifdef PIC
+       lwz     %r30,CALLFRAME_R30(%r1)
+#endif
        mtlr    %r0
        addi    %r1,%r1,CALLFRAMELEN
 #else
 #ifdef PIC
        mflr    %r10
-       bl      _GLOBAL_OFFSET_TABLE_@local-4
-       mflr    %r4
+       PIC_GOTSETUP(%r4)
        lwz     %r4,_C_LABEL(errno)@got(%r4)
        stw     %r3,0(%r4)
        mtlr    %r10
diff -r 928ab3f058cf -r 566752f51dc3 lib/libc/arch/powerpc/sys/ptrace.S
--- a/lib/libc/arch/powerpc/sys/ptrace.S        Sun Jan 16 02:41:55 2011 +0000
+++ b/lib/libc/arch/powerpc/sys/ptrace.S        Sun Jan 16 02:43:10 2011 +0000
@@ -1,17 +1,18 @@
-/*     $NetBSD: ptrace.S,v 1.5 2011/01/15 07:31:13 matt Exp $  */



Home | Main Index | Thread Index | Old Index