From 1d0a433095987a7426d92b42fb2b71e9699c8524 Mon Sep 17 00:00:00 2001 From: itohy Date: Mon, 18 Oct 1999 03:24:28 +0000 Subject: [PATCH] ELF PIC support. --- lib/libc/arch/m68k/gen/__sigsetjmp14.S | 12 ++++++------ lib/libc/arch/m68k/gen/_setjmp.S | 6 +++--- lib/libc/arch/m68k/gen/sigsetjmp.S | 12 ++++++------ lib/libc/arch/m68k/sys/Ovfork.S | 13 +++++++++---- lib/libc/arch/m68k/sys/__vfork14.S | 13 +++++++++---- lib/libc/arch/m68k/sys/brk.S | 13 +++++++++++-- lib/libc/arch/m68k/sys/cerror.S | 13 +++++++++---- lib/libc/arch/m68k/sys/ptrace.S | 13 +++++++++---- lib/libc/arch/m68k/sys/sbrk.S | 12 ++++++++++-- lib/libc/arch/m68k/sys/setlogin.S | 9 +++++++-- 10 files changed, 79 insertions(+), 37 deletions(-) diff --git a/lib/libc/arch/m68k/gen/__sigsetjmp14.S b/lib/libc/arch/m68k/gen/__sigsetjmp14.S index f88a4b30a95a..8fd89e0dfafc 100644 --- a/lib/libc/arch/m68k/gen/__sigsetjmp14.S +++ b/lib/libc/arch/m68k/gen/__sigsetjmp14.S @@ -1,4 +1,4 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.1 1998/10/05 02:34:18 thorpej Exp $ */ +/* $NetBSD: __sigsetjmp14.S,v 1.2 1999/10/18 03:24:28 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)_setjmp.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: __sigsetjmp14.S,v 1.1 1998/10/05 02:34:18 thorpej Exp $") + RCSID("$NetBSD: __sigsetjmp14.S,v 1.2 1999/10/18 03:24:28 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -67,15 +67,15 @@ ENTRY(__sigsetjmp14) movl d1,a0@(_JBLEN * 4) /* save at end of area */ tstl d1 bne dosig - jra _C_LABEL(_setjmp) + jra PIC_PLT(_C_LABEL(_setjmp)) dosig: - jra _C_LABEL(__setjmp14) + jra PIC_PLT(_C_LABEL(__setjmp14)) ENTRY(__siglongjmp14) movl sp@(4),a0 /* save area pointer */ tstl a0@(_JBLEN * 4) /* check mask... */ bne didsig - jra _C_LABEL(_longjmp) + jra PIC_PLT(_C_LABEL(_longjmp)) didsig: - jra _C_LABEL(__longjmp14) + jra PIC_PLT(_C_LABEL(__longjmp14)) diff --git a/lib/libc/arch/m68k/gen/_setjmp.S b/lib/libc/arch/m68k/gen/_setjmp.S index 8c53f25f8fe2..421af7a0a684 100644 --- a/lib/libc/arch/m68k/gen/_setjmp.S +++ b/lib/libc/arch/m68k/gen/_setjmp.S @@ -1,4 +1,4 @@ -/* $NetBSD: _setjmp.S,v 1.4 1998/07/01 06:44:14 thorpej Exp $ */ +/* $NetBSD: _setjmp.S,v 1.5 1999/10/18 03:24:29 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)_setjmp.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: _setjmp.S,v 1.4 1998/07/01 06:44:14 thorpej Exp $") + RCSID("$NetBSD: _setjmp.S,v 1.5 1999/10/18 03:24:29 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -88,5 +88,5 @@ ok: rts botch: - jbsr _C_LABEL(longjmperror) + jbsr PIC_PLT(_C_LABEL(longjmperror)) stop #0 diff --git a/lib/libc/arch/m68k/gen/sigsetjmp.S b/lib/libc/arch/m68k/gen/sigsetjmp.S index c7af8bdc945f..4ca7e5d52b16 100644 --- a/lib/libc/arch/m68k/gen/sigsetjmp.S +++ b/lib/libc/arch/m68k/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $NetBSD: sigsetjmp.S,v 1.4 1998/07/01 06:44:14 thorpej Exp $ */ +/* $NetBSD: sigsetjmp.S,v 1.5 1999/10/18 03:24:29 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)_setjmp.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: sigsetjmp.S,v 1.4 1998/07/01 06:44:14 thorpej Exp $") + RCSID("$NetBSD: sigsetjmp.S,v 1.5 1999/10/18 03:24:29 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -67,15 +67,15 @@ ENTRY(sigsetjmp) movl d1,a0@(_JBLEN * 4 ) /* save at end of area */ tstl d1 bne dosig - jra _C_LABEL(_setjmp) + jra PIC_PLT(_C_LABEL(_setjmp)) dosig: - jra _C_LABEL(setjmp) + jra PIC_PLT(_C_LABEL(setjmp)) ENTRY(siglongjmp) movl sp@(4),a0 /* save area pointer */ tstl a0@(_JBLEN * 4) /* check mask... */ bne didsig - jra _C_LABEL(_longjmp) + jra PIC_PLT(_C_LABEL(_longjmp)) didsig: - jra _C_LABEL(longjmp) + jra PIC_PLT(_C_LABEL(longjmp)) diff --git a/lib/libc/arch/m68k/sys/Ovfork.S b/lib/libc/arch/m68k/sys/Ovfork.S index d94a77d4cd58..f7d60af4bfd4 100644 --- a/lib/libc/arch/m68k/sys/Ovfork.S +++ b/lib/libc/arch/m68k/sys/Ovfork.S @@ -1,4 +1,4 @@ -/* $NetBSD: Ovfork.S,v 1.9 1999/05/02 20:52:02 kleink Exp $ */ +/* $NetBSD: Ovfork.S,v 1.10 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)Ovfork.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: Ovfork.S,v 1.9 1999/05/02 20:52:02 kleink Exp $") + RCSID("$NetBSD: Ovfork.S,v 1.10 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -79,13 +79,13 @@ err: .globl _C_LABEL(__errno) movl a0,sp@- movl d0,sp@- -#ifdef PIC +#if defined(PIC) && !defined(__ELF__) movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(_C_LABEL(__errno):l),a1 jsr a1@ #else - jbsr _C_LABEL(__errno) + jbsr PIC_PLT(_C_LABEL(__errno)) #endif /* PIC */ #ifdef __SVR4_ABI__ movl sp@+,a0@ @@ -97,9 +97,14 @@ err: #else .globl _C_LABEL(errno) #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a1 + movl a1@(_C_LABEL(errno)@GOT:w),a1 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(_C_LABEL(errno):w),a1 +#endif movl d0,a1@ #else movl d0,_C_LABEL(errno) diff --git a/lib/libc/arch/m68k/sys/__vfork14.S b/lib/libc/arch/m68k/sys/__vfork14.S index 76878390de1c..f6fb2090a929 100644 --- a/lib/libc/arch/m68k/sys/__vfork14.S +++ b/lib/libc/arch/m68k/sys/__vfork14.S @@ -1,4 +1,4 @@ -/* $NetBSD: __vfork14.S,v 1.4 1999/05/02 20:52:03 kleink Exp $ */ +/* $NetBSD: __vfork14.S,v 1.5 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)Ovfork.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: __vfork14.S,v 1.4 1999/05/02 20:52:03 kleink Exp $") + RCSID("$NetBSD: __vfork14.S,v 1.5 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -76,13 +76,13 @@ err: .globl _C_LABEL(__errno) movl a0,sp@- movl d0,sp@- -#ifdef PIC +#if defined(PIC) && !defined(__ELF__) movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(_C_LABEL(__errno):l),a1 jsr a1@ #else - jbsr _C_LABEL(__errno) + jbsr PIC_PLT(_C_LABEL(__errno)) #endif /* PIC */ #ifdef __SVR4_ABI__ movl sp@+,a0@ @@ -94,9 +94,14 @@ err: #else .globl _C_LABEL(errno) #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a1 + movl a1@(_C_LABEL(errno)@GOT:w),a1 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(_C_LABEL(errno):w),a1 +#endif movl d0,a1@ #else movl d0,_C_LABEL(errno) diff --git a/lib/libc/arch/m68k/sys/brk.S b/lib/libc/arch/m68k/sys/brk.S index 518f1db28d2f..fbc6ae3e2513 100644 --- a/lib/libc/arch/m68k/sys/brk.S +++ b/lib/libc/arch/m68k/sys/brk.S @@ -1,4 +1,4 @@ -/* $NetBSD: brk.S,v 1.8 1999/05/02 23:19:50 kleink Exp $ */ +/* $NetBSD: brk.S,v 1.9 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)brk.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: brk.S,v 1.8 1999/05/02 23:19:50 kleink Exp $") + RCSID("$NetBSD: brk.S,v 1.9 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -58,9 +58,14 @@ _C_LABEL(__minbrk): ENTRY(brk) #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a1 + movl a1@(_C_LABEL(__minbrk)@GOT:w),a0 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(_C_LABEL(__minbrk):w),a0 +#endif movl a0@,d0 #else movl _C_LABEL(__minbrk),d0 @@ -73,7 +78,11 @@ ok: trap #0 jcs err #ifdef PIC +#ifdef __ELF__ + movl a1@(CURBRK@GOT:w),a0 +#else movl a1@(CURBRK:w),a0 +#endif movl sp@(4),a0@ #else movl sp@(4),CURBRK diff --git a/lib/libc/arch/m68k/sys/cerror.S b/lib/libc/arch/m68k/sys/cerror.S index ab5c9f53a38c..46d5f448f6a0 100644 --- a/lib/libc/arch/m68k/sys/cerror.S +++ b/lib/libc/arch/m68k/sys/cerror.S @@ -1,4 +1,4 @@ -/* $NetBSD: cerror.S,v 1.11 1999/05/02 20:52:03 kleink Exp $ */ +/* $NetBSD: cerror.S,v 1.12 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)cerror.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: cerror.S,v 1.11 1999/05/02 20:52:03 kleink Exp $") + RCSID("$NetBSD: cerror.S,v 1.12 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -55,13 +55,13 @@ _ENTRY(CERROR) #ifdef _REENTRANT movl d0,sp@- -#ifdef PIC +#if defined(PIC) && !defined(__ELF__) movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a0 lea pc@(0,a0:l),a0 movl a0@(_C_LABEL(__errno):l),a0 jsr a0@ #else - jbsr _C_LABEL(__errno) + jbsr PIC_PLT(_C_LABEL(__errno)) #endif #ifndef __SVR4_ABI__ movl d0,a0 @@ -69,9 +69,14 @@ _ENTRY(CERROR) movl sp@+,a0@ #else #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a0 + movl a0@(_C_LABEL(errno)@GOT:w),a0 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a0 lea pc@(0,a0:l),a0 movl a0@(_C_LABEL(errno):w),a0 +#endif movl d0,a0@ #else movl d0,_C_LABEL(errno) diff --git a/lib/libc/arch/m68k/sys/ptrace.S b/lib/libc/arch/m68k/sys/ptrace.S index d95ba33990f4..766744c34b48 100644 --- a/lib/libc/arch/m68k/sys/ptrace.S +++ b/lib/libc/arch/m68k/sys/ptrace.S @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.S,v 1.8 1999/05/02 23:19:50 kleink Exp $ */ +/* $NetBSD: ptrace.S,v 1.9 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)ptrace.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: ptrace.S,v 1.8 1999/05/02 23:19:50 kleink Exp $") + RCSID("$NetBSD: ptrace.S,v 1.9 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -55,13 +55,13 @@ ENTRY(ptrace) #ifdef _REENTRANT -#ifdef PIC +#if defined(PIC) && !defined(__ELF__) movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a0 lea pc@(0,a0:l),a0 movl a0@(_C_LABEL(__errno):l),a0 jsr a0@ #else - jbsr _C_LABEL(__errno) + jbsr PIC_PLT(_C_LABEL(__errno)) #endif /* PIC */ #ifndef __SVR4_ABI__ movl d0,a0 @@ -69,9 +69,14 @@ ENTRY(ptrace) clrl a0@ #else #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a0 + movl a0@(_C_LABEL(errno)@GOT:w),a0 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a0 lea pc@(0,a0:l),a0 movl a0@(_C_LABEL(errno):w),a0 +#endif clrl a0@ #else clrl _C_LABEL(errno) diff --git a/lib/libc/arch/m68k/sys/sbrk.S b/lib/libc/arch/m68k/sys/sbrk.S index af4b256d3f5a..85fb6a982331 100644 --- a/lib/libc/arch/m68k/sys/sbrk.S +++ b/lib/libc/arch/m68k/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $NetBSD: sbrk.S,v 1.8 1999/05/02 23:19:50 kleink Exp $ */ +/* $NetBSD: sbrk.S,v 1.9 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,7 @@ #if 0 RCSID("from: @(#)sbrk.s 5.1 (Berkeley) 5/12/90") #else - RCSID("$NetBSD: sbrk.S,v 1.8 1999/05/02 23:19:50 kleink Exp $") + RCSID("$NetBSD: sbrk.S,v 1.9 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -56,9 +56,14 @@ CURBRK: .long _C_LABEL(end) ENTRY(sbrk) #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a1 + movl a1@(CURBRK@GOT:w),a1 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(CURBRK:w),a1 +#endif movl a1@,d0 #else movl CURBRK,d0 @@ -73,6 +78,9 @@ ENTRY(sbrk) #else movl CURBRK,d0 movl sp@(4),CURBRK +#endif +#ifdef __SVR4_ABI__ + movl d0,a0 #endif rts err: diff --git a/lib/libc/arch/m68k/sys/setlogin.S b/lib/libc/arch/m68k/sys/setlogin.S index 123a79e635ed..cb4384e959bb 100644 --- a/lib/libc/arch/m68k/sys/setlogin.S +++ b/lib/libc/arch/m68k/sys/setlogin.S @@ -1,4 +1,4 @@ -/* $NetBSD: setlogin.S,v 1.5 1998/07/01 06:44:15 thorpej Exp $ */ +/* $NetBSD: setlogin.S,v 1.6 1999/10/18 03:24:30 itohy Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -39,7 +39,7 @@ #if 0 RCSID("from: @(#)setlogin.s 5.1 (Berkeley) 5/6/91") #else - RCSID("$NetBSD: setlogin.S,v 1.5 1998/07/01 06:44:15 thorpej Exp $") + RCSID("$NetBSD: setlogin.S,v 1.6 1999/10/18 03:24:30 itohy Exp $") #endif #endif /* LIBC_SCCS and not lint */ @@ -47,9 +47,14 @@ SYSCALL(setlogin) #ifdef PIC +#ifdef __ELF__ + lea pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),a1 + movl a1@(_C_LABEL(__logname_valid)@GOT:w),a1 +#else movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),a1 lea pc@(0,a1:l),a1 movl a1@(_C_LABEL(__logname_valid):w),a1 +#endif clrl a1@ #else clrl _C_LABEL(__logname_valid)