Switch to the PIC_GOTSETUP/PIC_TOCSETUP macros for PIC code. Now libc
will be built to use secureplt by default.
This commit is contained in:
parent
810e7ea289
commit
b79441d450
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
@ -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 @@ cb_memset:
|
|||
/* 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 @@ cb_memset:
|
|||
#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 @@ cb_memset:
|
|||
|
||||
/* 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 @@ cb_memset:
|
|||
|
||||
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 @@ cb_memset:
|
|||
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)
|
||||
|
|
|
@ -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 @@ ENTRY(__clone)
|
|||
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:
|
||||
|
|
|
@ -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 @@ _C_LABEL(__minbrk):
|
|||
.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
|
||||
|
|
|
@ -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 @@ ENTRY(__cerror)
|
|||
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
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/* $NetBSD: ptrace.S,v 1.5 2011/01/15 07:31:13 matt Exp $ */
|
||||
/* $NetBSD: ptrace.S,v 1.6 2011/01/16 02:43:10 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
#include "assym.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: ptrace.S,v 1.5 2011/01/15 07:31:13 matt Exp $")
|
||||
__RCSID("$NetBSD: ptrace.S,v 1.6 2011/01/16 02:43:10 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
#define XCALLFRAMELEN ((((2+4)*SZREG) + CALLFRAMELEN - 1) & -CALLFRAMELEN)
|
||||
#define XCALLFRAMELEN ((((2+5)*SZREG) + CALLFRAMELEN - 1) & -CALLFRAMELEN)
|
||||
#define XCALLFRAME_DATA (XCALLFRAMELEN - 1*SZREG)
|
||||
#define XCALLFRAME_ADDR (XCALLFRAMELEN - 2*SZREG)
|
||||
#define XCALLFRAME_PID (XCALLFRAMELEN - 3*SZREG)
|
||||
#define XCALLFRAME_REQUEST (XCALLFRAMELEN - 4*SZREG)
|
||||
#define XCALLFRAME_R30 (XCALLFRAMELEN - 5*SZREG)
|
||||
|
||||
ENTRY(ptrace)
|
||||
#ifdef _REENTRANT
|
||||
|
@ -22,11 +23,18 @@ ENTRY(ptrace)
|
|||
stw %r4,XCALLFRAME_PID(%r1)
|
||||
stw %r5,XCALLFRAME_ADDR(%r1)
|
||||
stw %r6,XCALLFRAME_DATA(%r1)
|
||||
#ifdef PIC
|
||||
stw %r30,XCALLFRAME_R30(%r1)
|
||||
PIC_TOCSETUP(ptrace, %r30)
|
||||
#endif
|
||||
|
||||
bl PIC_PLT(_C_LABEL(__errno))
|
||||
li %r7,0
|
||||
stw %r7,0(%r3)
|
||||
|
||||
#ifdef PIC
|
||||
lwz %r30,XCALLFRAME_R30(%r1)
|
||||
#endif
|
||||
lwz %r6,XCALLFRAME_DATA(%r1)
|
||||
lwz %r4,XCALLFRAME_PID(%r1)
|
||||
lwz %r5,XCALLFRAME_ADDR(%r1)
|
||||
|
@ -37,8 +45,7 @@ ENTRY(ptrace)
|
|||
#else
|
||||
#ifdef PIC
|
||||
mflr %r0
|
||||
bl _GLOBAL_OFFSET_TABLE_@local-4
|
||||
mflr %r7
|
||||
PIC_GOTSETUP(%r7)
|
||||
lwz %r7,_C_LABEL(errno)@got(%r7)
|
||||
li %r8,0
|
||||
stw %r8,0(%r7)
|
||||
|
@ -50,8 +57,5 @@ ENTRY(ptrace)
|
|||
#endif /* PIC */
|
||||
#endif /* _REENTRANT */
|
||||
_DOSYSCALL(ptrace)
|
||||
bso 1f
|
||||
blr
|
||||
1:
|
||||
bnslr
|
||||
b _C_LABEL(__cerror)
|
||||
END(ptrace)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* $NetBSD: sbrk.S,v 1.10 2011/01/15 07:31:13 matt Exp $ */
|
||||
/* $NetBSD: sbrk.S,v 1.11 2011/01/16 02:43:10 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: sbrk.S,v 1.10 2011/01/15 07:31:13 matt Exp $")
|
||||
__RCSID("$NetBSD: sbrk.S,v 1.11 2011/01/16 02:43:10 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
.globl _C_LABEL(__curbrk)
|
||||
|
@ -21,8 +21,7 @@ _C_LABEL(__curbrk):
|
|||
ENTRY(_sbrk)
|
||||
#ifdef PIC
|
||||
mflr %r10
|
||||
bl _GLOBAL_OFFSET_TABLE_@local-4
|
||||
mflr %r5
|
||||
PIC_GOTSETUP(%r5)
|
||||
mtlr %r10
|
||||
lwz %r5,_C_LABEL(__curbrk)@got(%r5)
|
||||
lwz %r6,0(%r5)
|
||||
|
|
Loading…
Reference in New Issue