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!
This commit is contained in:
parent
40336aba3d
commit
b46734f0ca
|
@ -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 _SYSCALL(x,y) \
|
||||
.text; \
|
||||
911: mov.l 912f, r3; \
|
||||
braf r3; \
|
||||
nop; \
|
||||
.align 2; \
|
||||
912: .long cerror-(911b+6); \
|
||||
_SYSCALL_NOERROR(x,y); \
|
||||
bf 911b; \
|
||||
nop
|
||||
#else
|
||||
#define _SYSCALL(x,y) \
|
||||
.text; \
|
||||
911: mov.l 912f, r3; \
|
||||
|
||||
#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 cerror; \
|
||||
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: JUMP_CERROR; \
|
||||
_SYSCALL_NOERROR(x,y); \
|
||||
bf 911b; \
|
||||
nop
|
||||
#endif
|
||||
|
||||
#define SYSCALL_NOERROR(x) \
|
||||
_SYSCALL_NOERROR(x,x)
|
||||
|
|
|
@ -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 @@ ENTRY(__clone)
|
|||
inval:
|
||||
mov #EINVAL, r0
|
||||
err:
|
||||
mov.l .L_cerror, r1
|
||||
2: JUMP r1
|
||||
nop
|
||||
JUMP_CERROR
|
||||
/* NOTREACHED */
|
||||
|
||||
3: rts
|
||||
|
@ -87,5 +85,4 @@ err:
|
|||
|
||||
.L_got: PIC_GOT_DATUM
|
||||
.L__exit: CALL_DATUM(_C_LABEL(_exit), 1b)
|
||||
.L_cerror: CALL_DATUM_LOCAL(cerror, 2b)
|
||||
SET_ENTRY_SIZE(__clone)
|
||||
|
|
|
@ -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 @@ ENTRY(_brk)
|
|||
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 @@ LSYS_break: .long SYS_break
|
|||
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)
|
||||
|
|
|
@ -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 @@ cerror:
|
|||
.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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ ENTRY(ptrace)
|
|||
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)
|
||||
|
|
|
@ -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"
|
||||
|
@ -79,24 +79,14 @@ ENTRY(_sbrk)
|
|||
rts
|
||||
mov.l r2, @r1
|
||||
err:
|
||||
mov.l Lcerror, r1
|
||||
#ifdef PIC
|
||||
braf r1
|
||||
#else
|
||||
jmp @r1
|
||||
#endif
|
||||
nop
|
||||
1:
|
||||
JUMP_CERROR
|
||||
|
||||
.align 2
|
||||
LSYS_break: .long SYS_break
|
||||
#ifdef PIC
|
||||
L_GOT: .long _GLOBAL_OFFSET_TABLE_
|
||||
Lcurbrk: .long curbrk@GOT
|
||||
Lcerror: .long cerror-1b
|
||||
#else
|
||||
Lcurbrk: .long curbrk
|
||||
Lcerror: .long cerror
|
||||
#endif
|
||||
|
||||
|
||||
SET_ENTRY_SIZE(_sbrk)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: compat_sigprocmask.S,v 1.1 2005/09/15 21:39:16 uwe Exp $ */
|
||||
/* $NetBSD: compat_sigprocmask.S,v 1.2 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: compat_sigprocmask.S,v 1.1 2005/09/15 21:39:16 uwe Exp $")
|
||||
RCSID("$NetBSD: compat_sigprocmask.S,v 1.2 2006/01/06 03:58:31 uwe Exp $")
|
||||
#endif /* SYSLIBC_SCCS and not lint */
|
||||
|
||||
#include "SYS.h"
|
||||
|
@ -65,21 +65,10 @@ out:
|
|||
rts
|
||||
nop
|
||||
err:
|
||||
mov.l Lcerror, r1
|
||||
#ifdef PIC
|
||||
braf r1
|
||||
#else
|
||||
jmp @r1
|
||||
#endif
|
||||
nop
|
||||
3:
|
||||
JUMP_CERROR
|
||||
|
||||
.align 2
|
||||
LSYS_sigprocmask13:
|
||||
.long SYS_compat_13_sigprocmask13
|
||||
Lcerror:
|
||||
#ifdef PIC
|
||||
.long cerror-3b
|
||||
#else
|
||||
.long cerror
|
||||
#endif
|
||||
|
||||
SET_ENTRY_SIZE(sigprocmask)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: compat_sigsuspend.S,v 1.1 2005/09/15 21:39:16 uwe Exp $ */
|
||||
/* $NetBSD: compat_sigsuspend.S,v 1.2 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: compat_sigsuspend.S,v 1.1 2005/09/15 21:39:16 uwe Exp $")
|
||||
RCSID("$NetBSD: compat_sigsuspend.S,v 1.2 2006/01/06 03:58:31 uwe Exp $")
|
||||
#endif /* SYSLIBC_SCCS and not lint */
|
||||
|
||||
#include "SYS.h"
|
||||
|
@ -52,21 +52,10 @@ ENTRY(sigsuspend)
|
|||
rts
|
||||
nop
|
||||
err:
|
||||
mov.l Lcerror, r1
|
||||
#ifdef PIC
|
||||
braf r1
|
||||
#else
|
||||
jmp @r1
|
||||
#endif
|
||||
nop
|
||||
1:
|
||||
JUMP_CERROR
|
||||
|
||||
.align 2
|
||||
LSYS_sigsuspend13:
|
||||
.long SYS_compat_13_sigsuspend13
|
||||
Lcerror:
|
||||
#ifdef PIC
|
||||
.long cerror-1b
|
||||
#else
|
||||
.long cerror
|
||||
#endif
|
||||
|
||||
SET_ENTRY_SIZE(sigsuspend)
|
||||
|
|
Loading…
Reference in New Issue