Kaynağa Gözat

fork/vfork weak in libc, strong in libpthread

Peter S. Mazinger 19 yıl önce
ebeveyn
işleme
48143d8a8f

+ 7 - 5
libc/sysdeps/linux/arm/vfork.S

@@ -2,7 +2,7 @@
 /* vfork for uClibc
  *
  * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
- * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
  * Written by Erik Andersen <andersen@uclibc.org>
  *
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -16,11 +16,12 @@
 
 #ifdef __NR_fork
 .text
-.global	vfork
-.type	vfork,%function
+.global	__vfork
+.hidden	__vfork
+.type	__vfork,%function
 .align 4
 
-vfork:
+__vfork:
 
 #ifdef __NR_vfork
 	swi	__NR_vfork
@@ -43,6 +44,7 @@ vfork:
 __error:
 	b	__syscall_error
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)
 #endif

+ 7 - 4
libc/sysdeps/linux/bfin/vfork.S

@@ -8,11 +8,14 @@
 #include <asm/unistd.h>
 
 .text
-.global _vfork
-.type	_vfork,STT_FUNC;
+.global ___vfork
+.hidden ___vfork
+.type	___vfork,STT_FUNC;
 .align 4
-_vfork:
+___vfork:
 	p0 = __NR_vfork;
 	excpt 0;
 	rts;
-.size _vfork,.-_vfork
+.size ___vfork,.-___vfork
+//weak_alias(___vfork,_vfork)
+//libc_hidden_def(_vfork)

+ 1 - 1
libc/sysdeps/linux/common/fork.c

@@ -15,7 +15,7 @@
 #define __NR___libc_fork __NR_fork
 _syscall0(pid_t, __libc_fork);
 libc_hidden_proto(fork)
-strong_alias(__libc_fork,fork)
+weak_alias(__libc_fork,fork)
 libc_hidden_def(fork)
 #endif
 #endif

+ 8 - 5
libc/sysdeps/linux/common/vfork.c

@@ -1,18 +1,21 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
 /* Trivial implementation for arches that lack vfork */
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/syscall.h>
 
 #ifdef __NR_fork
-
-libc_hidden_proto(vfork)
-
 libc_hidden_proto(fork)
 
-pid_t vfork(void)
+pid_t attribute_hidden __vfork(void)
 {
     return fork();
 }
+libc_hidden_proto(vfork)
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)
-
 #endif

+ 1 - 1
libc/sysdeps/linux/cris/fork.c

@@ -15,5 +15,5 @@ SYSCALL__ (__libc_fork, 0)
      /* i dunno what the blurb above is useful for. we just return. */
 __asm__("ret\n\tnop");
 libc_hidden_proto(fork)
-strong_alias(__libc_fork,fork)
+weak_alias(__libc_fork,fork)
 libc_hidden_def(fork)

+ 3 - 2
libc/sysdeps/linux/e1/vfork.c

@@ -8,7 +8,8 @@
 #include <sys/syscall.h>
 #include <errno.h>
 
+#define __NR___vfork __NR_vfork
+attribute_hidden _syscall0(pid_t, __vfork);
 libc_hidden_proto(vfork)
-
-_syscall0(pid_t, vfork);
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 6 - 4
libc/sysdeps/linux/frv/vfork.S

@@ -24,10 +24,11 @@
 #include <bits/errno.h>
 
        .text
-       .globl	vfork
-       .type	vfork,@function
+       .globl	__vfork
+       .hidden	__vfork
+       .type	__vfork,@function
 /* int vfork(void) */
-vfork:
+__vfork:
 	setlos.p #__NR_vfork, gr7
 	setlos	#-4096, gr4
 	tra	gr0, gr0
@@ -40,6 +41,7 @@ vfork:
 	ldd	@(gr14, gr15), gr14
 	jmpl	@(gr14, gr0)
 
-       .size   vfork,.-vfork
+       .size   __vfork,.-__vfork
 
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 8 - 4
libc/sysdeps/linux/h8300/vfork.S

@@ -12,10 +12,11 @@
 #endif
 	.text
 	.align 2
-	.globl _errno
-	.globl _vfork
-	.type	 vfork,@function
-_vfork:
+	.globl	_errno
+	.globl	___vfork
+	.hidden	___vfork
+	.type	___vfork,@function
+___vfork:
 	mov.l	@sp+, er1
 	sub.l	er0,er0
 	mov.b	#__NR_vfork,r0l
@@ -35,3 +36,6 @@ fix_errno:
 	sub.l	er0,er0
 	dec.l	#1,er0
 	jmp	@er1                     /* don't return,  just jmp directly */
+
+//weak_alias(___vfork,_vfork)
+//libc_hidden_def(_vfork)

+ 9 - 10
libc/sysdeps/linux/i386/vfork.S

@@ -1,25 +1,23 @@
 /*
- * June 3, 2003             Erik Andersen
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
 
 #include <features.h>
 #include <sys/syscall.h>
 
 #ifndef __NR_vfork
-
 /* No vfork so use fork instead */
-strong_alias(fork,vfork)
-strong_alias(vfork,__libc_fork)
-
+hidden_strong_alias(__libc_fork,__vfork)
 #else
-
 .text
-.global vfork
-.type   vfork,%function
+.global __vfork
+.hidden __vfork
+.type   __vfork,%function
 .align 1<<4
 
-vfork:
+__vfork:
 	popl %ecx
 	movl $__NR_vfork,%eax
 	int $0x80
@@ -28,6 +26,7 @@ vfork:
 	jae __syscall_error
 	ret
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
 #endif
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 16 - 23
libc/sysdeps/linux/i960/vfork.S

@@ -1,24 +1,14 @@
-#
-# clone.S, part of the i960 support for the uClibc library.
-#
-# Copyright (C) 2002 by Okiok Data Ltd.  http://www.okiok.com/
-#
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Library General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option) any
-# later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this program; if not, write to the Free Software Foundation, Inc.,
-# at 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Derived from an old port of uC-libc to the i960 by Keith Adams (kma@cse.ogi.edu).
-#
+/*
+ * clone.S, part of the i960 support for the uClibc library.
+ *
+ * Copyright (C) 2002 by Okiok Data Ltd.  http://www.okiok.com/
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+/*
+ * Derived from an old port of uC-libc to the i960 by Keith Adams (kma@cse.ogi.edu).
+ */
 
 #include <sys/syscall.h>
         
@@ -26,8 +16,9 @@
 #define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
 #endif
      
-        .globl _vfork
-_vfork: 
+        .globl	___vfork
+        .hidden	___vfork
+___vfork:
         mov         g13, r3
         ldconst     __NR_vfork, g13
         calls       0
@@ -38,3 +29,5 @@ _vfork:
 1:      
         ret
 
+//weak_alias(___vfork,_vfork)
+//libc_hidden_def(_vfork)

+ 6 - 4
libc/sysdeps/linux/m68k/vfork.S

@@ -17,10 +17,11 @@
 	.text
 	.align 2
 	.globl errno
-	.globl	vfork
-	.type	vfork,@function
+	.globl	__vfork
+	.hidden	__vfork
+	.type	__vfork,@function
 
-vfork:
+__vfork:
 	movl	%sp@+, %a1               /* save the return address for later */
 	movl	IMM __NR_vfork,%d0
 	trap	#0
@@ -39,5 +40,6 @@ fix_errno:
 	movl	IMM -1, %d0
 	jmp		%a1@                     /* don't return,  just jmp directly */
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 11 - 9
libc/sysdeps/linux/microblaze/vfork.S

@@ -1,14 +1,14 @@
 /*
  * libc/sysdeps/linux/microblaze/vfork.S -- `vfork' syscall for linux/microblaze
  *
- *  Copyright (C) 2003  John Williams <jwilliams@itee.uq.edu.au>
- *  Copyright (C) 2001  NEC Corporation
- *  Copyright (C) 2001  Miles Bader <miles@gnu.org>
+ * Copyright (C) 2001  NEC Corporation
+ * Copyright (C) 2001  Miles Bader <miles@gnu.org>
+ * Copyright (C) 2003  John Williams <jwilliams@itee.uq.edu.au>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License.  See the file COPYING.LIB in the main
- * directory of this archive for more details.
- * 
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+/* 
  * Written by Miles Bader <miles@gnu.org>
  * Microblaze port by John Williams
  */
@@ -27,7 +27,7 @@
 
 .global C_SYMBOL_NAME(errno)
 
-C_ENTRY (vfork):
+C_ENTRY (__vfork):
 	addi	r12, r0, SYS_vfork
 	bralid	r17, 0x08;
 	nop
@@ -39,4 +39,6 @@ C_ENTRY (vfork):
 	swi	r3, r0, C_SYMBOL_NAME(errno);
 	rtsd	r15, 8			// error return
 	nop
-C_END(vfork)
+C_END(__vfork)
+//weak_alias(__vfork,vfork)
+//libc_hidden_def(vfork)

+ 6 - 4
libc/sysdeps/linux/nios/vfork.S

@@ -22,9 +22,10 @@
 
    .text
    .align 2
-   .globl vfork
-   .type  vfork,@function
-vfork:
+   .globl __vfork
+  .hidden __vfork
+  .type   __vfork,@function
+__vfork:
 	MOVIP	%g1, __NR_vfork
 	trap	63
 	
@@ -48,5 +49,6 @@ fix_errno:
 	ret
 	restore
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 10 - 6
libc/sysdeps/linux/nios2/vfork.S

@@ -16,12 +16,16 @@
 #include <bits/errno.h>
 #include <sys/syscall.h>
 
-#ifdef __NR_fork
+#ifndef __NR_vfork
+#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
+#endif
+
 .text
-.global	vfork
-.type	vfork,%function
+.global	__vfork
+.hidden	__vfork
+.type	__vfork,%function
 .align 4
-vfork:
+__vfork:
     movui   r2, TRAP_ID_SYSCALL
     movui   r3, __NR_vfork
     trap
@@ -47,6 +51,6 @@ fix_errno:
     addi  sp, sp, 8
     ret
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)
-#endif

+ 13 - 6
libc/sysdeps/linux/powerpc/vfork.S

@@ -1,25 +1,32 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
 #include <features.h>
 #include <sys/syscall.h>
 
 #ifndef __NR_vfork
 
 /* No vfork so use fork instead */
-strong_alias(fork,vfork)
-strong_alias(vfork,__libc_fork)
+strong_alias(fork,__libc_fork)
+hidden_strong_alias(__libc_fork,__vfork)
 
 #else
 
 .text
-.global vfork
-.type   vfork,@function
+.global __vfork
+.hidden __vfork
+.type   __vfork,@function
 .type   __syscall_error,@function
 
-vfork:
+__vfork:
 	li	0, __NR_vfork
 	sc
 	bnslr+
 	b	__syscall_error
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
 #endif
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 3 - 3
libc/sysdeps/linux/powerpc/vfork.c

@@ -3,15 +3,13 @@
 #include <errno.h>
 #include <sys/syscall.h>
 
-libc_hidden_proto(vfork)
-
 #define __syscall_clobbers \
 	"r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
 #define __syscall_return(type) \
 	return (__sc_err & 0x10000000 ? errno = __sc_ret, __sc_ret = -1 : 0), \
 	       (type) __sc_ret
 
-pid_t vfork(void)
+pid_t attribute_hidden __vfork(void)
 {
 	unsigned long __sc_ret, __sc_err;
 	register unsigned long __sc_0 __asm__ ("r0");
@@ -48,4 +46,6 @@ pid_t vfork(void)
 
 	__syscall_return (pid_t);
 }
+libc_hidden_proto(vfork)
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 6 - 4
libc/sysdeps/linux/sh/vfork.S

@@ -32,11 +32,12 @@
    and the process ID of the new process to the old process.  */
 
 .text
-.globl	vfork
-.type	vfork,@function
+.globl	__vfork
+.hidden	__vfork
+.type	__vfork,@function
 .align 4
 
-vfork:
+__vfork:
 	mov.w	.L2, r3
 	trapa	#0x10
 	mov     r0, r1
@@ -106,7 +107,8 @@ vfork:
 .L3:
 	.word	__NR_fork
 
-.size   vfork, .-vfork
+.size   __vfork, .-__vfork
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)
 
 #include "syscall_error.S"

+ 5 - 5
libc/sysdeps/linux/sparc/fork.S

@@ -23,11 +23,11 @@
 #include <sys/syscall.h>
 
 .text
-.global	fork
-.type	fork,%function
+.global	__libc_fork
+.type	__libc_fork,%function
 .align 4
 
-fork:
+__libc_fork:
 	mov __NR_fork, %g1
 	ta	0x10
 	bcc,a	9000f
@@ -44,6 +44,6 @@ fork:
 	retl
 	and	%o0, %o1, %o0
 
-.size fork,.-fork
+.size __libc_fork,.-__libc_fork
+weak_alias(__libc_fork,fork)
 libc_hidden_def(fork)
-strong_alias(fork,__libc_fork)

+ 8 - 6
libc/sysdeps/linux/sparc/vfork.S

@@ -25,17 +25,18 @@
 #ifndef __NR_vfork
 /* No vfork so use fork instead */
 
-strong_alias(fork,vfork)
-strong_alias(vfork,__libc_fork)
+strong_alias(fork,__libc_fork)
+hidden_strong_alias(__libc_fork,__vfork)
 
 #else
 
 .text
-.global	vfork
-.type	vfork,%function
+.global	__vfork
+.hidden	__vfork
+.type	__vfork,%function
 .align 4
 
-vfork:
+__vfork:
 	mov __NR_vfork, %g1
 	ta	0x10
 	bcc,a	9000f
@@ -52,6 +53,7 @@ vfork:
 	retl
 	and	%o0, %o1, %o0
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
 #endif /* __NR_vfork */
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 4 - 2
libc/sysdeps/linux/v850/vfork.S

@@ -26,7 +26,7 @@
 
 .global C_SYMBOL_NAME(errno)
 
-C_ENTRY (vfork):
+C_ENTRY (__vfork):
 	addi	SYS_vfork, r0, r12
 	trap	0
 	addi	-125, r0, r11		// minimum err value
@@ -37,4 +37,6 @@ C_ENTRY (vfork):
 	subr	r0, r10
 	st.w	r10, 0[r11]
 	jmp	[lp]			// error return
-C_END(vfork)
+C_END(__vfork)
+//weak_alias(__vfork,vfork)
+//libc_hidden_def(vfork)

+ 8 - 6
libc/sysdeps/linux/x86_64/vfork.S

@@ -26,17 +26,18 @@
 
 #ifndef __NR_vfork
 /* No vfork so use fork instead */
-strong_alias(fork,vfork)
-strong_alias(vfork,__libc_fork)
+strong_alias(fork,__libc_fork)
+hidden_strong_alias(__libc_fork,__vfork)
 
 #else
 
 .text
-.global vfork
-.type	vfork,%function
+.global __vfork
+.hidden __vfork
+.type	__vfork,%function
 .align 16
 
-vfork:
+__vfork:
 
 	/* Pop the return PC value into RDI.  We need a register that
 	   is preserved by the syscall and that we're allowed to destroy. */
@@ -55,7 +56,8 @@ vfork:
 	/* Normal return.  */
 	ret
 
-.size vfork,.-vfork
+.size __vfork,.-__vfork
 
 #endif /* __NR_vfork */
+weak_alias(__vfork,vfork)
 libc_hidden_def(vfork)

+ 5 - 5
libpthread/linuxthreads.old/ptfork.c

@@ -78,9 +78,9 @@ static inline void pthread_call_handlers(struct handler_list * list)
   for (/*nothing*/; list != NULL; list = list->next) (list->handler)();
 }
 
-extern int __libc_fork(void);
+extern __typeof(fork) __libc_fork;
 
-pid_t __fork(void)
+pid_t attribute_hidden __fork(void)
 {
   pid_t pid;
   struct handler_list * prepare, * child, * parent;
@@ -101,13 +101,13 @@ pid_t __fork(void)
   }
   return pid;
 }
-weak_alias (__fork, fork)
+strong_alias(__fork,fork)
 
-pid_t __vfork(void)
+pid_t attribute_hidden __vfork(void)
 {
   return __fork();
 }
-weak_alias (__vfork, vfork)
+strong_alias(__vfork,vfork)
 
 #else