Fix PIC bugs.

This commit is contained in:
eeh 2000-07-18 22:38:11 +00:00
parent f310f1fd32
commit 067b7521b5
10 changed files with 52 additions and 47 deletions

View File

@ -37,7 +37,7 @@
* @(#)SYS.h 8.1 (Berkeley) 6/4/93
*
* from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp
* $NetBSD: SYS.h,v 1.3 2000/06/26 06:31:39 kleink Exp $
* $NetBSD: SYS.h,v 1.4 2000/07/18 22:39:25 eeh Exp $
*/
#include <machine/asm.h>
@ -57,7 +57,7 @@
#ifdef PIC
#define ERROR() \
PIC_PROLOGUE(%g1,%g2); \
ld [%g1+_C_LABEL(__cerror)],%g2; jmp %g2; nop
ldx [%g1+_C_LABEL(__cerror)],%g2; jmp %g2; nop
#else
#define ERROR() \
sethi %hi(_C_LABEL(__cerror)),%g1; or %lo(_C_LABEL(__cerror)),%g1,%g1; \

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigsetjmp14.S,v 1.1 1998/10/08 02:27:59 eeh Exp $ */
/* $NetBSD: __sigsetjmp14.S,v 1.2 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1995 Paul Kranenburg
* All rights reserved.
@ -39,8 +39,8 @@ ENTRY(__sigsetjmp14)
cmp %o1,0
st %o1,[%o0+0x38] ! jmpbuf[JBLEN]
bne,a 1f
ld [%g1+_C_LABEL(__setjmp14)], %g1 ! if (%o1 != 0) goto _setjmp;
ld [%g1+_C_LABEL(_setjmp)], %g1 ! else goto __setjmp;
ldx [%g1+_C_LABEL(__setjmp14)], %g1 ! if (%o1 != 0) goto _setjmp;
ldx [%g1+_C_LABEL(_setjmp)], %g1 ! else goto __setjmp;
1:
jmp %g1
nop
@ -50,8 +50,8 @@ ENTRY(__siglongjmp14)
ld [%o0+0x38],%g2 ! jmpbuf[JBLEN]
cmp %g2,0
bne,a 1f
ld [%g1+_C_LABEL(__longjmp14)], %g1 ! if (%g2 != 0) goto _longjmp;
ld [%g1+_C_LABEL(_longjmp)], %g1 ! else goto __longjmp;
ldx [%g1+_C_LABEL(__longjmp14)], %g1 ! if (%g2 != 0) goto _longjmp;
ldx [%g1+_C_LABEL(_longjmp)], %g1 ! else goto __longjmp;
1:
jmp %g1
nop

View File

@ -1,4 +1,4 @@
/* $NetBSD: sigsetjmp.S,v 1.2 1998/10/08 02:27:59 eeh Exp $ */
/* $NetBSD: sigsetjmp.S,v 1.3 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1995 Paul Kranenburg
* All rights reserved.
@ -39,8 +39,8 @@ ENTRY(sigsetjmp)
cmp %o1,0
st %o1,[%o0+0x38] ! jmpbuf[JBLEN]
bne,a 1f
ld [%g1+_C_LABEL(setjmp)], %g1 ! if (%o1 != 0) goto _setjmp;
ld [%g1+_C_LABEL(_setjmp)], %g1 ! else goto __setjmp;
ldx [%g1+_C_LABEL(setjmp)], %g1 ! if (%o1 != 0) goto _setjmp;
ldx [%g1+_C_LABEL(_setjmp)], %g1 ! else goto __setjmp;
1:
jmp %g1
nop
@ -50,8 +50,8 @@ ENTRY(siglongjmp)
ld [%o0+0x38],%g2 ! jmpbuf[JBLEN]
cmp %g2,0
bne,a 1f
ld [%g1+_C_LABEL(longjmp)], %g1 ! if (%g2 != 0) goto _longjmp;
ld [%g1+_C_LABEL(_longjmp)], %g1 ! else goto __longjmp;
ldx [%g1+_C_LABEL(longjmp)], %g1 ! if (%g2 != 0) goto _longjmp;
ldx [%g1+_C_LABEL(_longjmp)], %g1 ! else goto __longjmp;
1:
jmp %g1
nop

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs.S,v 1.3 1999/12/30 15:30:26 eeh Exp $ */
/* $NetBSD: ffs.S,v 1.4 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@
#if 0
.asciz "@(#)ffs.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: ffs.S,v 1.3 1999/12/30 15:30:26 eeh Exp $")
RCSID("$NetBSD: ffs.S,v 1.4 2000/07/18 22:39:25 eeh Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
@ -84,10 +84,10 @@ ENTRY(ffs)
* one, we just return the table value plus 24. This means
* that ffstab[0] must be -24 so that ffs(0) will return 0.
*/
ENTRY(_C_LABEL(ffs))
ENTRY(ffs)
#ifdef PIC
PIC_PROLOGUE(%o1,%o2)
ld [%o1 + _C_LABEL(__ffstab)], %o2
PIC_PROLOGUE(%o1, %o2)
PICCY_SET(_C_LABEL(__ffstab), %o2, %o3)
#else
set _C_LABEL(__ffstab), %o2
#endif
@ -121,7 +121,7 @@ ENTRY(_C_LABEL(ffs))
retl
add %o0, 24, %o0
ENTRY(_C_LABEL(__ffstab))
RODATA(__ffstab)
.byte -24,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 00-0f */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 10-1f */
.byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 20-2f */

View File

@ -1,4 +1,4 @@
/* $NetBSD: brk.S,v 1.5 2000/06/26 06:25:46 kleink Exp $ */
/* $NetBSD: brk.S,v 1.6 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@
#if 0
.asciz "@(#)brk.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: brk.S,v 1.5 2000/06/26 06:25:46 kleink Exp $")
RCSID("$NetBSD: brk.S,v 1.6 2000/07/18 22:39:25 eeh Exp $")
#endif
#endif /* SYSLIBC_SCCS and not lint */
@ -59,15 +59,16 @@ WEAK_ALIAS(brk, _brk)
#endif
.data
.align 8
_C_LABEL(__minbrk):
.long _C_LABEL(_end) ! lower brk limit; also for gmon code
.xword _C_LABEL(_end) ! lower brk limit; also for gmon code
.text
ENTRY(_brk)
#ifdef PIC
PIC_PROLOGUE(%o5,%o4)
ld [%o5 + _C_LABEL(__minbrk)], %o4
ld [%o4], %o1 ! %o1 = minbrk
ldx [%o5 + _C_LABEL(__minbrk)], %o4
ldx [%o4], %o1 ! %o1 = minbrk
cmp %o1, %o0 ! if (minbrk > %o0)
bg,a 0f
mov %o1, %o0 ! %o0 = minbrk
@ -75,15 +76,16 @@ ENTRY(_brk)
mov %o0, %o2 ! save argument to syscall
mov SYS_break, %g1
t ST_SYSCALL
set _C_LABEL(__curbrk), %o3
bcc,a 1f
ld [%o5 + _C_LABEL(__curbrk)], %o4
ldx [%o5 + %o3], %o4
ERROR()
1:
retl ! success, return 0 & record new break
st %o2, [%o4]
#else
sethi %hi(_C_LABEL(__minbrk)), %o1 ! %o1 = minbrk
ld [%o1 + %lo(_C_LABEL(__minbrk))], %o1
ldx [%o1 + %lo(_C_LABEL(__minbrk))], %o1
cmp %o1, %o0 ! if (minbrk > %o0)
bg,a 0f
mov %o1, %o0 ! %o0 = minbrk
@ -96,5 +98,5 @@ ENTRY(_brk)
ERROR()
1:
retl ! success, return 0 & record new break
st %o2, [%g1 + %lo(_C_LABEL(__curbrk))]
stx %o2, [%g1 + %lo(_C_LABEL(__curbrk))]
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: cerror.S,v 1.2 1999/01/14 22:48:22 kleink Exp $ */
/* $NetBSD: cerror.S,v 1.3 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@
#if 0
.asciz "@(#)cerror.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: cerror.S,v 1.2 1999/01/14 22:48:22 kleink Exp $")
RCSID("$NetBSD: cerror.S,v 1.3 2000/07/18 22:39:25 eeh Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
@ -63,7 +63,8 @@ FUNC(__cerror)
.globl _C_LABEL(errno)
#ifdef PIC
FUNC(__cerror)
ld [%g1 + _C_LABEL(errno)], %g1
PIC_PROLOGUE(%g1, %o3)
ldx [%g1 + _C_LABEL(errno)], %g1
st %o0, [%g1]
mov -1, %o0
retl

View File

@ -1,4 +1,4 @@
/* $NetBSD: ptrace.S,v 1.1 1998/09/11 04:56:34 eeh Exp $ */
/* $NetBSD: ptrace.S,v 1.2 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@
#if 0
.asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: ptrace.S,v 1.1 1998/09/11 04:56:34 eeh Exp $")
RCSID("$NetBSD: ptrace.S,v 1.2 2000/07/18 22:39:25 eeh Exp $")
#endif
#endif /* SYSLIBC_SCCS and not lint */
@ -53,7 +53,7 @@
ENTRY(ptrace)
#ifdef PIC
PIC_PROLOGUE(%g1,%g2)
ld [%g1 + _C_LABEL(errno)], %g1
ldx [%g1 + _C_LABEL(errno)], %g1
st %g0, [%g1]
#else
sethi %hi(_C_LABEL(errno)), %g1

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbrk.S,v 1.5 2000/06/26 06:25:46 kleink Exp $ */
/* $NetBSD: sbrk.S,v 1.6 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@
#if 0
.asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: sbrk.S,v 1.5 2000/06/26 06:25:46 kleink Exp $")
RCSID("$NetBSD: sbrk.S,v 1.6 2000/07/18 22:39:25 eeh Exp $")
#endif
#endif /* SYSLIBC_SCCS and not lint */
@ -58,15 +58,17 @@ WEAK_ALIAS(sbrk, _sbrk)
#endif
.data
.align 8
_C_LABEL(__curbrk):
.long _C_LABEL(_end)
.xword _C_LABEL(_end)
.text
ENTRY(_sbrk)
#ifdef PIC
PIC_PROLOGUE(%o5,%o4)
ld [%o5 + _C_LABEL(__curbrk)], %o2
ld [%o2], %o3 ! %o3 = old break
set _C_LABEL(__curbrk), %o3
ldx [%o5 + %o3], %o2
ldx [%o2], %o3 ! %o3 = old break
add %o3, %o0, %o4 ! %o4 = new break
mov %o4, %o0 ! copy for syscall
mov SYS_break, %g1
@ -76,10 +78,10 @@ ENTRY(_sbrk)
ERROR()
1:
retl ! and update curbrk
st %o4, [%o2]
stx %o4, [%o2]
#else
sethi %hi(_C_LABEL(__curbrk)), %o2
ld [%o2 + %lo(_C_LABEL(__curbrk))], %o3 ! %o3 = old break
ldx [%o2 + %lo(_C_LABEL(__curbrk))], %o3 ! %o3 = old break
add %o3, %o0, %o4 ! %o4 = new break
mov %o4, %o0 ! copy for syscall
mov SYS_break, %g1
@ -89,5 +91,5 @@ ENTRY(_sbrk)
ERROR()
1:
retl ! and update curbrk
st %o4, [%o2 + %lo(_C_LABEL(__curbrk))]
stx %o4, [%o2 + %lo(_C_LABEL(__curbrk))]
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: setlogin.S,v 1.1 1998/09/11 04:56:35 eeh Exp $ */
/* $NetBSD: setlogin.S,v 1.2 2000/07/18 22:39:25 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
@ -44,7 +44,7 @@
#if 0
.asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: setlogin.S,v 1.1 1998/09/11 04:56:35 eeh Exp $")
RCSID("$NetBSD: setlogin.S,v 1.2 2000/07/18 22:39:25 eeh Exp $")
#endif
#endif /* SYSLIBC_SCCS and not lint */
@ -55,7 +55,7 @@
SYSCALL(setlogin)
#ifdef PIC
PIC_PROLOGUE(%g1,%g2)
ld [%g1 + _C_LABEL(__logname_valid)], %g1
ldx [%g1 + _C_LABEL(__logname_valid)], %g1
retl
st %g0, [%g1]
#else

View File

@ -1,4 +1,4 @@
/* $NetBSD: asm.h,v 1.11 2000/07/14 20:59:07 eeh Exp $ */
/* $NetBSD: asm.h,v 1.12 2000/07/18 22:38:11 eeh Exp $ */
/*
* Copyright (c) 1994 Allen Briggs
@ -69,9 +69,9 @@
* to work without a stack frame (doing so requires saving %o7) .
*/
#define PIC_PROLOGUE(dest,tmp) \
3: rd %pc, tmp; \
sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \
rd %pc, tmp; \
or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \
add dest,tmp,dest
/*