Minimize differences between powerpc and powerpc64
Fix powerpc64 assembly to use right instructions for 64bit CPUs. Use hidden for __curbrk and __minbrk to avoid GOT/TOC relocations.
This commit is contained in:
parent
794ed9d503
commit
38dcdc34d9
|
@ -1,24 +1,21 @@
|
|||
/* $NetBSD: SYS.h,v 1.12 2011/01/15 07:31:12 matt Exp $ */
|
||||
/* $NetBSD: SYS.h,v 1.13 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
#define BRANCH_TO_CERROR() b _C_LABEL(__cerror)
|
||||
|
||||
#define _DOSYSCALL(x) li %r0,(SYS_ ## x) ;\
|
||||
sc
|
||||
#else
|
||||
#define _DOSYSCALL(x) li %r0,(SYS_/**/x) ;\
|
||||
sc
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#define _SYSCALL_NOERROR(x,y) .text ;\
|
||||
.align 2 ;\
|
||||
.p2align 2 ;\
|
||||
ENTRY(x) ;\
|
||||
_DOSYSCALL(y)
|
||||
|
||||
#define _SYSCALL(x,y) .text ;\
|
||||
.align 2 ;\
|
||||
2: b _C_LABEL(__cerror) ;\
|
||||
.p2align 2 ;\
|
||||
2: BRANCH_TO_CERROR() ;\
|
||||
_SYSCALL_NOERROR(x,y) ;\
|
||||
bso 2b
|
||||
|
||||
|
@ -32,7 +29,7 @@
|
|||
|
||||
#define PSEUDO(x,y) _SYSCALL_NOERROR(x,y) ;\
|
||||
bnslr ;\
|
||||
b _C_LABEL(__cerror) ;\
|
||||
BRANCH_TO_CERROR() ;\
|
||||
END(x)
|
||||
|
||||
#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __clone.S,v 1.5 2013/09/12 15:36:15 joerg Exp $ */
|
||||
/* $NetBSD: __clone.S,v 1.6 2014/08/23 02:24:22 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.5 2013/09/12 15:36:15 joerg Exp $")
|
||||
__RCSID("$NetBSD: __clone.S,v 1.6 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
|
@ -44,9 +44,9 @@ ENTRY(__clone)
|
|||
/*
|
||||
* Sanity checks: func and stack may not be NULL.
|
||||
*/
|
||||
cmpwi %r3,0
|
||||
cmpptri %r3,0
|
||||
beq 1f
|
||||
cmpwi %r4,0
|
||||
cmpptri %r4,0
|
||||
beq 1f
|
||||
|
||||
mr %r7,%r3 /* Save fn in r7. */
|
||||
|
@ -54,7 +54,7 @@ ENTRY(__clone)
|
|||
_DOSYSCALL(__clone) /* (flags, stack) */
|
||||
bso 2f /* error... */
|
||||
|
||||
cmpwi %r3,0
|
||||
cmpptri %r3,0
|
||||
bnelr /* We're the parent, just return. */
|
||||
|
||||
mtlr %r7 /* fn */
|
||||
|
@ -69,5 +69,5 @@ ENTRY(__clone)
|
|||
1:
|
||||
li %r3,EINVAL
|
||||
2:
|
||||
b _C_LABEL(__cerror)
|
||||
BRANCH_TO_CERROR()
|
||||
END(__clone)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* $NetBSD: __syscall.S,v 1.2 2014/02/01 20:26:21 matt Exp $ */
|
||||
/* $NetBSD: __syscall.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include <powerpc/asm.h>
|
||||
#include "SYS.h"
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.p2align 2
|
||||
ENTRY(__syscall)
|
||||
mr %r0,%r3 /* syscall number */
|
||||
mr %r3,%r4
|
||||
|
@ -13,10 +13,10 @@ ENTRY(__syscall)
|
|||
mr %r7,%r8
|
||||
mr %r8,%r9
|
||||
mr %r9,%r10
|
||||
lwz %r10,8(%r1) /* final argument is on the stack */
|
||||
ldreg %r10,(2*__SIZEOF_POINTER__)(%r1) /* final argument is on the stack */
|
||||
sc
|
||||
bnslr
|
||||
b _C_LABEL(__cerror)
|
||||
BRANCH_TO_CERROR()
|
||||
END(__syscall)
|
||||
|
||||
STRONG_ALIAS(syscall, __syscall)
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/* $NetBSD: brk.S,v 1.13 2013/09/12 15:36:15 joerg Exp $ */
|
||||
/* $NetBSD: brk.S,v 1.14 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: brk.S,v 1.13 2013/09/12 15:36:15 joerg Exp $")
|
||||
__RCSID("$NetBSD: brk.S,v 1.14 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
.hidden _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(__curbrk)
|
||||
.hidden _C_LABEL(__minbrk)
|
||||
.globl _C_LABEL(__minbrk)
|
||||
.globl _C_LABEL(_end)
|
||||
|
||||
|
@ -15,36 +17,38 @@ WEAK_ALIAS(brk, _brk)
|
|||
#endif
|
||||
|
||||
.data
|
||||
.p2align 2
|
||||
_C_LABEL(__minbrk):
|
||||
.long _C_LABEL(_end) # XXX not used yet
|
||||
.long _C_LABEL(_end)
|
||||
_C_LABEL(__curbrk):
|
||||
.long _C_LABEL(_end)
|
||||
|
||||
.text
|
||||
ENTRY(_brk)
|
||||
#ifdef __PIC__
|
||||
mflr %r10
|
||||
PIC_GOTSETUP(%r9)
|
||||
mtlr %r10
|
||||
lwz %r5,_C_LABEL(_end)@got(%r9)
|
||||
mflr %r0
|
||||
bcl 20,31,.LPIC0
|
||||
.LPIC0: mflr %r9
|
||||
mtlr %r0
|
||||
addis %r9,%r9,(_C_LABEL(__minbrk)-.LPIC0)@ha
|
||||
ldptru %r5,(_C_LABEL(__minbrk)-.LPIC0)@l(%r9) # r5 = &_end
|
||||
#else
|
||||
lis %r5,_C_LABEL(_end)@ha # r5 = &_end
|
||||
addi %r5,%r5,_C_LABEL(_end)@l
|
||||
lis %r9,_C_LABEL(__minbrk)@ha
|
||||
ldptru %r5,_C_LABEL(__minbrk)@l(%r9) # r5 = &_end
|
||||
#endif
|
||||
cmplw %r5,%r3 # if (&_end <= r3)
|
||||
cmpptrl %r5,%r3 # if (__minbrk <= r3)
|
||||
#ifdef __PPC_ISEL__
|
||||
iselgt %r3,%r5,%r3
|
||||
#else
|
||||
bgt 0f
|
||||
mr %r5,%r3 # r5 = r3
|
||||
0:
|
||||
mr %r3,%r5 # new break value
|
||||
_DOSYSCALL(break) # assume, that r5 is kept
|
||||
bso 1f
|
||||
#ifdef __PIC__
|
||||
lwz %r6,_C_LABEL(__curbrk)@got(%r9)
|
||||
stw %r5,0(%r6)
|
||||
#else
|
||||
lis %r6,_C_LABEL(__curbrk)@ha # record new break
|
||||
stw %r5,_C_LABEL(__curbrk)@l(%r6)
|
||||
#endif
|
||||
_DOSYSCALL(break) # assume that r5 is preserved
|
||||
bso 1f
|
||||
stptr %r5,__SIZEOF_POINTER__(%r9)
|
||||
blr # return 0
|
||||
|
||||
1:
|
||||
b _C_LABEL(__cerror)
|
||||
BRANCH_TO_CERROR()
|
||||
END(_brk)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getcontext.S,v 1.5 2011/01/15 07:31:13 matt Exp $ */
|
||||
/* $NetBSD: getcontext.S,v 1.6 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -33,7 +33,7 @@
|
|||
#include "assym.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: getcontext.S,v 1.5 2011/01/15 07:31:13 matt Exp $")
|
||||
__RCSID("$NetBSD: getcontext.S,v 1.6 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
|
@ -45,9 +45,9 @@ ENTRY(_getcontext)
|
|||
_DOSYSCALL(getcontext)
|
||||
bso 1f
|
||||
mflr %r4
|
||||
stw %r4,UC_GREGS_PC(%r5) # saved pc <- lr
|
||||
stw %r3,UC_GREGS_R3(%r5) # arrange for return value 0
|
||||
stptr %r4,UC_GREGS_PC(%r5) # saved pc <- lr
|
||||
stint %r3,UC_GREGS_R3(%r5) # arrange for return value 0
|
||||
blr
|
||||
1:
|
||||
b _C_LABEL(__cerror)
|
||||
BRANCH_TO_CERROR()
|
||||
END(_getcontext)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* $NetBSD: pipe.S,v 1.8 2011/01/15 07:31:13 matt Exp $ */
|
||||
/* $NetBSD: pipe.S,v 1.9 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: pipe.S,v 1.8 2011/01/15 07:31:13 matt Exp $")
|
||||
__RCSID("$NetBSD: pipe.S,v 1.9 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
|
@ -14,10 +14,10 @@ ENTRY(_pipe)
|
|||
mr %r5,%r3 # save pointer
|
||||
_DOSYSCALL(pipe) # assume, that r5 is kept
|
||||
bso 1f
|
||||
stw %r3,0(%r5) # success, store fds
|
||||
stw %r4,4(%r5)
|
||||
stint %r3,0(%r5) # success, store fds
|
||||
stint %r4,4(%r5)
|
||||
li %r3,0
|
||||
blr # and return 0
|
||||
1:
|
||||
b _C_LABEL(__cerror)
|
||||
BRANCH_TO_CERROR()
|
||||
END(_pipe)
|
||||
|
|
|
@ -1,41 +1,37 @@
|
|||
/* $NetBSD: sbrk.S,v 1.12 2013/09/12 15:36:15 joerg Exp $ */
|
||||
/* $NetBSD: sbrk.S,v 1.13 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: sbrk.S,v 1.12 2013/09/12 15:36:15 joerg Exp $")
|
||||
__RCSID("$NetBSD: sbrk.S,v 1.13 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
.hidden _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(_end)
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(sbrk, _sbrk)
|
||||
#endif
|
||||
|
||||
.data
|
||||
_C_LABEL(__curbrk):
|
||||
.long _C_LABEL(_end)
|
||||
.text
|
||||
|
||||
ENTRY(_sbrk)
|
||||
#ifdef __PIC__
|
||||
mflr %r10
|
||||
PIC_GOTSETUP(%r5)
|
||||
mtlr %r10
|
||||
lwz %r5,_C_LABEL(__curbrk)@got(%r5)
|
||||
lwz %r6,0(%r5)
|
||||
mflr %r0
|
||||
bcl 20,31,.LPIC0
|
||||
.LPIC0: mflr %r5
|
||||
mtlr %r0
|
||||
addis %r8,%r5,(_C_LABEL(__curbrk)-.LPIC0)@ha
|
||||
ldptru %r6,(_C_LABEL(__curbrk)-.LPIC0)@l(%r8)
|
||||
#else
|
||||
lis %r5,_C_LABEL(__curbrk)@ha
|
||||
lwzu %r6,_C_LABEL(__curbrk)@l(%r5) # r6 = old break, r5 = &curbrk
|
||||
lis %r8,_C_LABEL(__curbrk)@ha
|
||||
ldptru %r6,_C_LABEL(__curbrk)@l(%r8) # r6 = old break, r5 = &curbrk
|
||||
#endif
|
||||
add %r3,%r3,%r6
|
||||
mr %r7,%r3 # r7 = new break
|
||||
_DOSYSCALL(break) # break(new_break)
|
||||
bso 1f
|
||||
mr %r3,%r6 # set return value
|
||||
stw %r7,0(%r5) # record new break
|
||||
stptr %r7,0(%r8) # record new break
|
||||
blr
|
||||
1:
|
||||
b _C_LABEL(__cerror)
|
||||
BRANCH_TO_CERROR()
|
||||
END(_sbrk)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# $NetBSD: Makefile.inc,v 1.2 2006/07/07 06:56:34 ross Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.3 2014/08/23 02:24:22 matt Exp $
|
||||
|
||||
KMINCLUDES=
|
||||
KMSRCS=
|
||||
|
||||
SRCS+= __sigaction14_sigtramp.c __sigtramp2.S
|
||||
CPPFLAGS+= -I.
|
||||
|
||||
SRCS+= __sigaction14_sigtramp.c __sigtramp2.S
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
/* $NetBSD: SYS.h,v 1.2 2010/03/22 02:17:23 mrg Exp $ */
|
||||
/* $NetBSD: SYS.h,v 1.3 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
#ifdef _CALL_AIX
|
||||
#define BRANCH_TO_CERROR() b ._C_LABEL(__cerror); nop
|
||||
#else
|
||||
#define BRANCH_TO_CERROR() b _C_LABEL(__cerror)
|
||||
#endif
|
||||
|
||||
#define _DOSYSCALL(x) li %r0,(SYS_ ## x) ;\
|
||||
sc
|
||||
#else
|
||||
#define _DOSYSCALL(x) li %r0,(SYS_/**/x) ;\
|
||||
sc
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#define _SYSCALL_NOERROR(x,y) .text ;\
|
||||
.align 2 ;\
|
||||
.p2align 2 ;\
|
||||
ENTRY(x) ;\
|
||||
_DOSYSCALL(y)
|
||||
|
||||
#define _SYSCALL(x,y) .text ;\
|
||||
.align 2 ;\
|
||||
2: b PIC_PLT(_C_LABEL(__cerror));\
|
||||
nop ;\
|
||||
.p2align 2 ;\
|
||||
2: BRANCH_TO_CERROR() ;\
|
||||
_SYSCALL_NOERROR(x,y) ;\
|
||||
bso 2b
|
||||
|
||||
|
@ -28,12 +28,13 @@
|
|||
#define SYSCALL(x) _SYSCALL(x,x)
|
||||
|
||||
#define PSEUDO_NOERROR(x,y) _SYSCALL_NOERROR(x,y) ;\
|
||||
blr
|
||||
blr ;\
|
||||
END(x)
|
||||
|
||||
#define PSEUDO(x,y) _SYSCALL_NOERROR(x,y) ;\
|
||||
bnslr ;\
|
||||
b PIC_PLT(_C_LABEL(__cerror));\
|
||||
nop
|
||||
BRANCH_TO_CERROR() ;\
|
||||
END(x)
|
||||
|
||||
#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x)
|
||||
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
/* $NetBSD: __setjmp14.S,v 1.2 2009/03/08 18:57:12 he Exp $ */
|
||||
/* $NetBSD: __setjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$NetBSD: __setjmp14.S,v 1.2 2009/03/08 18:57:12 he Exp $"
|
||||
__RCSID("$NetBSD: __setjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -24,8 +21,7 @@ ENTRY(__setjmp14)
|
|||
li %r3,1 # SIG_BLOCK
|
||||
li %r4,0
|
||||
addi %r5,%r6,100 # &sigmask
|
||||
li %r0,SYS___sigprocmask14
|
||||
sc # assume no error XXX
|
||||
_DOSYSCALL(__sigprocmask14) # assume no error XXX
|
||||
mflr %r11
|
||||
mfcr %r12
|
||||
mr %r10,%r1
|
||||
|
@ -58,6 +54,7 @@ ENTRY(__setjmp14)
|
|||
|
||||
li %r3,0
|
||||
blr
|
||||
END(__setjmp14)
|
||||
|
||||
ENTRY(__longjmp14)
|
||||
ld %r8,8(%r6) # load r8-r31
|
||||
|
@ -93,9 +90,9 @@ ENTRY(__longjmp14)
|
|||
addi %r4,%r3,100 # &sigmask
|
||||
li %r3,3 # SIG_SETMASK
|
||||
li %r5,0
|
||||
li %r0,SYS___sigprocmask14
|
||||
sc # assume no error XXX
|
||||
_DOSYSCALL(__sigprocmask14) # assume no error XXX
|
||||
or. %r3,%r6,%r6
|
||||
bnelr
|
||||
li %r3,1
|
||||
blr
|
||||
END(__longjmp14)
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/* $NetBSD: __sigsetjmp14.S,v 1.2 2010/03/22 01:39:11 mrg Exp $ */
|
||||
/* $NetBSD: __sigsetjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <machine/asm.h>
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$NetBSD: __sigsetjmp14.S,v 1.2 2010/03/22 01:39:11 mrg Exp $"
|
||||
.asciz "$NetBSD: __sigsetjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $"
|
||||
#endif
|
||||
|
||||
ENTRY(__sigsetjmp14)
|
||||
|
@ -15,8 +14,7 @@ ENTRY(__sigsetjmp14)
|
|||
li %r3,1 # SIG_BLOCK
|
||||
li %r4,0
|
||||
addi %r5,%r6,100 # &sigmask
|
||||
li %r0,SYS___sigprocmask14
|
||||
sc # assume no error XXX
|
||||
_DOSYSCALL(__sigprocmask14) # assume no error XXX
|
||||
1:
|
||||
mflr %r11
|
||||
mfcr %r12
|
||||
|
@ -29,6 +27,7 @@ ENTRY(__sigsetjmp14)
|
|||
.endr
|
||||
li %r3,0
|
||||
blr
|
||||
END(__sigsetjmp14)
|
||||
|
||||
ENTRY(__siglongjmp14)
|
||||
i = 0
|
||||
|
@ -46,10 +45,10 @@ ENTRY(__siglongjmp14)
|
|||
addi %r4,%r3,100 # &sigmask
|
||||
li %r3,3 # SIG_SETMASK
|
||||
li %r5,0
|
||||
li %r0,SYS___sigprocmask14
|
||||
sc # assume no error XXX
|
||||
_DOSYSCALL(__sigprocmask14) # assume no error XXX
|
||||
1:
|
||||
or. %r3,%r6,%r6
|
||||
bnelr
|
||||
li %r3,1
|
||||
blr
|
||||
END(__siglongjmp14)
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
# $NetBSD: genassym.cf,v 1.1 2014/08/23 02:24:22 matt Exp $
|
||||
|
||||
#
|
||||
# Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Matt Thomas <matt@3am-sfotware.com>.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
include <sys/types.h>
|
||||
include <sys/queue.h>
|
||||
include <sys/cpu.h>
|
||||
include <sys/signal.h>
|
||||
include <sys/ucontext.h>
|
||||
|
||||
include <machine/frame.h>
|
||||
|
||||
define UC_GREGS_R1 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R1])
|
||||
define UC_GREGS_R3 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R3])
|
||||
define UC_GREGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC])
|
||||
|
||||
define SIG_BLOCK SIG_BLOCK
|
||||
define SIG_SETMASK SIG_SETMASK
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __clone.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */
|
||||
/* $NetBSD: __clone.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Tsubai Masanari. All rights reserved.
|
||||
|
@ -40,18 +40,17 @@ ENTRY(__clone)
|
|||
/*
|
||||
* Sanity checks: func and stack may not be NULL.
|
||||
*/
|
||||
cmpdi %r3,0
|
||||
cmpptri %r3,0
|
||||
beq 1f
|
||||
cmpdi %r4,0
|
||||
cmpptri %r4,0
|
||||
beq 1f
|
||||
|
||||
mr %r7,%r3 /* Save fn in r7. */
|
||||
mr %r3,%r5
|
||||
li %r0,SYS___clone /* (flags, stack) */
|
||||
sc
|
||||
_DOSYSCALL(__clone) /* (flags, stack) */
|
||||
bso 2f /* error... */
|
||||
|
||||
cmpdi %r3,0
|
||||
cmpptri %r3,0
|
||||
bnelr /* We're the parent, just return. */
|
||||
|
||||
mtlr %r7 /* fn */
|
||||
|
@ -59,8 +58,10 @@ ENTRY(__clone)
|
|||
blrl /* Call the clone's entry point. */
|
||||
|
||||
bl PIC_PLT(_C_LABEL(_exit))
|
||||
nop
|
||||
|
||||
1:
|
||||
li %r3,EINVAL
|
||||
2:
|
||||
b PIC_PLT(_C_LABEL(__cerror))
|
||||
BRANCH_TO_CERROR()
|
||||
END(__clone)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __sigtramp2.S,v 1.3 2011/01/17 08:23:54 matt Exp $ */
|
||||
/* $NetBSD: __sigtramp2.S,v 1.4 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -46,3 +46,4 @@ ENTRY_NOPROFILE(__sigtramp_siginfo_2)
|
|||
mr %r3,%r30 /* restore ucontext pointer */
|
||||
_DOSYSCALL(setcontext) /* restore machine state */
|
||||
_DOSYSCALL(exit) /* or exit with errno if failed */
|
||||
END(__sigtramp_siginfo_2)
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
/* $NetBSD: __syscall.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */
|
||||
/* $NetBSD: __syscall.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
RSYSCALL(__syscall)
|
||||
.text
|
||||
.p2align 2
|
||||
ENTRY(__syscall)
|
||||
mr %r0,%r3 /* syscall number */
|
||||
mr %r3,%r4
|
||||
mr %r4,%r5
|
||||
mr %r5,%r6
|
||||
mr %r6,%r7
|
||||
mr %r7,%r8
|
||||
mr %r8,%r9
|
||||
mr %r9,%r10
|
||||
ldreg %r10,(2*__SIZEOF_POINTER__)(%r1) /* final argument is on the stack */
|
||||
sc
|
||||
bnslr
|
||||
BRANCH_TO_CERROR()
|
||||
END(__syscall)
|
||||
|
||||
STRONG_ALIAS(syscall, __syscall)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: __vfork14.S,v 1.1 2006/07/06 17:04:22 ross Exp $ */
|
||||
/* $NetBSD: __vfork14.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
/*
|
||||
* pid = vfork();
|
||||
|
@ -13,3 +13,4 @@ SYSCALL(__vfork14)
|
|||
addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent
|
||||
and %r3,%r3,%r4 # return 0 in child, pid in parent
|
||||
blr
|
||||
END(__vfork14)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
/* $NetBSD: brk.S,v 1.4 2011/10/29 16:03:33 christos Exp $ */
|
||||
/* $NetBSD: brk.S,v 1.5 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
|
||||
.hidden _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(__curbrk)
|
||||
.hidden _C_LABEL(__minbrk)
|
||||
.globl _C_LABEL(__minbrk)
|
||||
.globl _C_LABEL(_end)
|
||||
|
||||
|
@ -10,32 +13,30 @@
|
|||
WEAK_ALIAS(brk, _brk)
|
||||
#endif
|
||||
|
||||
.macro LdAddr r,sym
|
||||
.pushsection ".toc","aw"
|
||||
100: .tc \sym[TC],\sym
|
||||
.popsection
|
||||
ld \r,100b@toc(2)
|
||||
.endm
|
||||
|
||||
.data
|
||||
.data
|
||||
.p2align 3
|
||||
_C_LABEL(__minbrk):
|
||||
.long _C_LABEL(_end)
|
||||
.text
|
||||
.quad _C_LABEL(_end)
|
||||
_C_LABEL(__curbrk):
|
||||
.quad _C_LABEL(_end)
|
||||
|
||||
ENTRY(_brk)
|
||||
LdAddr %r5,_end
|
||||
cmpld %r5,%r3 # if (&_end <= r3)
|
||||
addis %r9,%r2,_C_LABEL(__minbrk)@toc@ha
|
||||
ldptru %r5,_C_LABEL(__minbrk)@toc@l(%r9)
|
||||
cmpptrl %r5,%r3 # if (__minbrk <= r3)
|
||||
#ifdef __PPC_ISEL__
|
||||
iselgt %r3,%r5,%r3
|
||||
#else
|
||||
bgt 0f
|
||||
mr %r5,%r3 # r5 = r3
|
||||
0:
|
||||
mr %r3,%r5 # new break value
|
||||
li %r0,SYS_break
|
||||
sc # assume, that r5 is kept
|
||||
#endif
|
||||
_DOSYSCALL(break) # assume that r5 is preserved
|
||||
bso 1f
|
||||
LdAddr %r6,__curbrk
|
||||
std %r5,0(%r6)
|
||||
stptr %r5,__SIZEOF_POINTER__(%r9)
|
||||
blr # return 0
|
||||
|
||||
1:
|
||||
b PIC_PLT(_C_LABEL(__cerror))
|
||||
|
||||
BRANCH_TO_CERROR()
|
||||
END(_brk)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cerror.S,v 1.5 2013/09/12 15:36:15 joerg Exp $ */
|
||||
/* $NetBSD: cerror.S,v 1.6 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include "SYS.h"
|
||||
|
@ -13,29 +13,26 @@
|
|||
ENTRY(__cerror)
|
||||
#ifdef _REENTRANT
|
||||
mflr %r0
|
||||
stwu %r1,-16(%r1) # allocate new stack frame
|
||||
stw %r0,20(%r1)
|
||||
stw %r31,8(%r1)
|
||||
streg %r0,__SIZEOF_POINTER__(%r1)
|
||||
stptru %r1,-(4*__SIZEOF_POINTER__)(%r1) # allocate new stack frame
|
||||
streg %r31,(3*__SIZEOF_POINTER__)(%r1)
|
||||
mr %r31,%r3 # stash away in callee-saved register
|
||||
bl PIC_PLT(_C_LABEL(__errno))
|
||||
stw %r31,0(%r3)
|
||||
lwz %r0,20(%r1)
|
||||
lwz %r31,8(%r1)
|
||||
nop
|
||||
stint %r31,0(%r3)
|
||||
|
||||
ldreg %r31,(3*__SIZEOF_POINTER__)(%r1)
|
||||
addi %r1,%r1,4*__SIZEOF_POINTER__
|
||||
ldreg %r0,__SIZEOF_POINTER__(%r1)
|
||||
mtlr %r0
|
||||
la %r1,16(%r1)
|
||||
#else
|
||||
#ifdef __PIC__
|
||||
mflr %r10
|
||||
bl _GLOBAL_OFFSET_TABLE_@local-4
|
||||
mflr %r4
|
||||
lwz %r4,_C_LABEL(errno)@got(%r4)
|
||||
.pushsection ".toc", "aw"
|
||||
.Lerrno:.tc errno[TC], errno
|
||||
.popsection
|
||||
lwz %r4,_C_LABEL(.Lerrno)@toc(%r2)
|
||||
stw %r3,0(%r4)
|
||||
mtlr %r10
|
||||
#else
|
||||
lis %r4,_C_LABEL(errno)@ha
|
||||
stw %r3,_C_LABEL(errno)@l(%r4)
|
||||
#endif /* __PIC__ */
|
||||
#endif /* _REENTRANT */
|
||||
li %r3,-1
|
||||
li %r4,-1
|
||||
blr
|
||||
END(__cerror)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fork.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */
|
||||
/* $NetBSD: fork.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
/*
|
||||
* pid = fork();
|
||||
|
@ -13,3 +13,4 @@ _SYSCALL(__fork,fork)
|
|||
addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent
|
||||
and %r3,%r3,%r4 # return 0 in child, pid in parent
|
||||
blr
|
||||
END(__fork)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getcontext.S,v 1.4 2011/10/29 16:03:33 christos Exp $ */
|
||||
/* $NetBSD: getcontext.S,v 1.5 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -30,11 +30,11 @@
|
|||
*/
|
||||
|
||||
#include "SYS.h"
|
||||
#include "assym.h"
|
||||
|
||||
#if defined(SYSLIBC_SCCS) && !defined(lint)
|
||||
.text
|
||||
.asciz "$NetBSD: getcontext.S,v 1.4 2011/10/29 16:03:33 christos Exp $"
|
||||
#endif /* SYSLIBC_SCCS && !lint */
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: getcontext.S,v 1.5 2014/08/23 02:24:22 matt Exp $")
|
||||
#endif /* LIBC_SCCS && !lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(getcontext, _getcontext)
|
||||
|
@ -42,12 +42,12 @@ WEAK_ALIAS(getcontext, _getcontext)
|
|||
|
||||
ENTRY(_getcontext)
|
||||
mr %r5,%r3 # must save pointer
|
||||
li %r0,SYS_getcontext
|
||||
sc
|
||||
_DOSYSCALL(getcontext)
|
||||
bso 1f
|
||||
mflr %r4
|
||||
stw %r4,(48 + 34 * 4)(%r5) # saved pc <- lr
|
||||
stw %r3,(48 + 3 * 4)(%r5) # arrange for return value 0
|
||||
stptr %r4,UC_GREGS_PC(%r5) # saved pc <- lr
|
||||
stint %r3,UC_GREGS_R3(%r5) # arrange for return value 0
|
||||
blr
|
||||
1:
|
||||
b PIC_PLT(_C_LABEL(__cerror))
|
||||
BRANCH_TO_CERROR()
|
||||
END(_getcontext)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pipe.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */
|
||||
/* $NetBSD: pipe.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
|
@ -8,12 +8,12 @@ WEAK_ALIAS(pipe, _pipe)
|
|||
|
||||
ENTRY(_pipe)
|
||||
mr %r5,%r3 # save pointer
|
||||
li %r0,SYS_pipe
|
||||
sc # assume, that r5 is kept
|
||||
_DOSYSCALL(pipe) # assume, that r5 is kept
|
||||
bso 1f
|
||||
stw %r3,0(%r5) # success, store fds
|
||||
stw %r4,4(%r5)
|
||||
stint %r3,0(%r5) # success, store fds
|
||||
stint %r4,4(%r5)
|
||||
li %r3,0
|
||||
blr # and return 0
|
||||
1:
|
||||
b PIC_PLT(_C_LABEL(__cerror))
|
||||
BRANCH_TO_CERROR()
|
||||
END(_pipe)
|
||||
|
|
|
@ -1,46 +1,43 @@
|
|||
/* $NetBSD: ptrace.S,v 1.2 2013/09/12 15:36:15 joerg Exp $ */
|
||||
/* $NetBSD: ptrace.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
ENTRY(ptrace)
|
||||
#ifdef _REENTRANT
|
||||
mflr %r0
|
||||
stwu %r1,-32(%r1)
|
||||
stw %r0,36(%r1)
|
||||
stw %r3,8(%r1)
|
||||
stw %r4,12(%r1)
|
||||
stw %r5,16(%r1)
|
||||
stw %r6,20(%r1)
|
||||
streg %r0,SZREG(%r1)
|
||||
stregu %r1,-(SZREG*6)(%r1)
|
||||
streg %r3,(SZREG*2)(%r1)
|
||||
streg %r4,(SZREG*3)(%r1)
|
||||
streg %r5,(SZREG*4)(%r1)
|
||||
streg %r6,(SZREG*5)(%r1)
|
||||
|
||||
bl PIC_PLT(_C_LABEL(__errno))
|
||||
nop
|
||||
li %r7,0
|
||||
stw %r7,0(%r3)
|
||||
stint %r7,0(%r3)
|
||||
|
||||
lwz %r3,8(%r1)
|
||||
lwz %r4,12(%r1)
|
||||
lwz %r5,16(%r1)
|
||||
lwz %r0,36(%r1)
|
||||
lwz %r6,20(%r1)
|
||||
ldreg %r3,(SZREG*2)(%r1)
|
||||
ldreg %r4,(SZREG*3)(%r1)
|
||||
ldreg %r5,(SZREG*4)(%r1)
|
||||
ldreg %r6,(SZREG*5)(%r1)
|
||||
addi %r1,%r1,SZREG*6
|
||||
ldreg %r0,SZREG(%r1)
|
||||
mtlr %r0
|
||||
la %r1,32(%r1)
|
||||
#else
|
||||
#ifdef __PIC__
|
||||
mflr %r0
|
||||
bl _GLOBAL_OFFSET_TABLE_@local-4
|
||||
mflr %r7
|
||||
lwz %r7,_C_LABEL(errno)@got(%r7)
|
||||
.pushsection ".toc","aw"
|
||||
.Lerrno:
|
||||
.tc errno[TC], errno
|
||||
.popsection
|
||||
addis %r7,%r2,_C_LABEL(errno)@toc@ha
|
||||
ldptr %r7,_C_LABEL(errno)@toc@l(%r7)
|
||||
li %r8,0
|
||||
stw %r8,0(%r7)
|
||||
stint %r8,0(%r7)
|
||||
mtlr 0
|
||||
#else
|
||||
lis %r7,_C_LABEL(errno)@ha
|
||||
li %r8,0
|
||||
stw %r8,_C_LABEL(errno)@l(%r7)
|
||||
#endif /* __PIC__ */
|
||||
#endif /* _REENTRANT */
|
||||
li %r0,SYS_ptrace
|
||||
sc
|
||||
_DOSYSCALL(ptrace)
|
||||
bso 1f
|
||||
blr
|
||||
1:
|
||||
b PIC_PLT(_C_LABEL(__cerror))
|
||||
BRANCH_TO_CERROR()
|
||||
END(ptrace)
|
||||
|
|
|
@ -1,37 +1,24 @@
|
|||
/* $NetBSD: sbrk.S,v 1.4 2014/08/13 15:19:22 joerg Exp $ */
|
||||
/* $NetBSD: sbrk.S,v 1.5 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
.hidden _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(_end)
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(sbrk, _sbrk)
|
||||
#endif
|
||||
|
||||
|
||||
.data
|
||||
_C_LABEL(__curbrk):
|
||||
.long _C_LABEL(_end)
|
||||
.text
|
||||
|
||||
.macro LdAddr r,sym
|
||||
.pushsection ".toc","aw"
|
||||
100: .tc \sym[TC],\sym
|
||||
.popsection
|
||||
ld \r,100b@toc(2)
|
||||
.endm
|
||||
|
||||
ENTRY(_sbrk)
|
||||
LdAddr %r6,__curbrk
|
||||
addis %r8,%r2,_C_LABEL(__curbrk)@toc@ha
|
||||
ldptru %r6,_C_LABEL(__curbrk)@toc@l(%r8)
|
||||
add %r3,%r3,%r6
|
||||
mr %r7,%r3 # r7 = new break
|
||||
li %r0,SYS_break
|
||||
sc # break(new_break)
|
||||
_DOSYSCALL(break) # break(new_break)
|
||||
bso 1f
|
||||
mr %r3,%r6 # set return value
|
||||
LdAddr %r6,__curbrk
|
||||
std %r7,0(%r6)
|
||||
stptr %r7,0(%r8) # record new break
|
||||
blr
|
||||
1:
|
||||
b PIC_PLT(_C_LABEL(__cerror))
|
||||
BRANCH_TO_CERROR()
|
||||
END(_sbrk)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* $NetBSD: syscall.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */
|
||||
/* $NetBSD: syscall.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
RSYSCALL(syscall)
|
||||
/* aliased to __syscall */
|
||||
|
|
Loading…
Reference in New Issue