Radix cross Linux

Radix Linux distribution for embedded systems.

637 Commits   4 Branches   3 Tags
author: Andrey V.Kosteltsev <kx@radix.pro> 2016-10-29 12:41:50 +0000 committer: Andrey V.Kosteltsev <kx@radix.pro> 2016-10-29 12:41:50 +0000 commit: 29071b24e90e41d5edbdd13ebd2b99df887476a6 parent: 76d426714ca0d081814a9c573212e6173aeffda5
Commit Summary:
GLIBC 2.23 vfork aliases fix for MIPS and SPARC architectures
Diffstat:
8 files changed, 207 insertions, 7 deletions
diff --git a/libs/glibc/2.23-i18n/PATCHES b/libs/glibc/2.23-i18n/PATCHES
index 849a16340..482e2f950 100644
--- a/libs/glibc/2.23-i18n/PATCHES
+++ b/libs/glibc/2.23-i18n/PATCHES
@@ -1,3 +1,4 @@
 
-../../../sources/GNU/glibc/2.23/patches/glibc-2.23-i18n.patch     -p0
-../../../sources/GNU/glibc/2.23/patches/glibc-2.23-zoneinfo.patch -p0
+../../../sources/GNU/glibc/2.23/patches/glibc-2.23-i18n.patch        -p0
+../../../sources/GNU/glibc/2.23/patches/glibc-2.23-vfork-alias.patch -p0
+../../../sources/GNU/glibc/2.23/patches/glibc-2.23-zoneinfo.patch    -p0
diff --git a/libs/glibc/2.23/PATCHES b/libs/glibc/2.23/PATCHES
index d3332fa2b..5b9c6156f 100644
--- a/libs/glibc/2.23/PATCHES
+++ b/libs/glibc/2.23/PATCHES
@@ -1,4 +1,5 @@
 
-../../../sources/GNU/glibc/2.23/patches/glibc-2.23-i18n.patch     -p0
-../../../sources/GNU/glibc/2.23/patches/glibc-2.23-zoneinfo.patch -p0
-../../../sources/iana/tz/patches/glibc-2.23-tzcode-2016a.patch    -p0
+../../../sources/GNU/glibc/2.23/patches/glibc-2.23-i18n.patch        -p0
+../../../sources/GNU/glibc/2.23/patches/glibc-2.23-vfork-alias.patch -p0
+../../../sources/GNU/glibc/2.23/patches/glibc-2.23-zoneinfo.patch    -p0
+../../../sources/iana/tz/patches/glibc-2.23-tzcode-2016a.patch       -p0
diff --git a/sources/GNU/glibc/2.23/Makefile b/sources/GNU/glibc/2.23/Makefile
index 24eabdeb5..523acbe86 100644
--- a/sources/GNU/glibc/2.23/Makefile
+++ b/sources/GNU/glibc/2.23/Makefile
@@ -14,6 +14,7 @@ tarballs    = $(addsuffix .tar.xz, $(addprefix glibc-, $(versions)))
 sha1s       = $(addsuffix .sha1sum, $(tarballs))
 
 patches     = $(CURDIR)/patches/glibc-2.23-i18n.patch
+patches    += $(CURDIR)/patches/glibc-2.23-vfork-alias.patch
 patches    += $(CURDIR)/patches/glibc-2.23-zoneinfo.patch
 
 .NOTPARALLEL: $(patches)
@@ -49,8 +50,9 @@ $(sha1s): $(tarballs)
 
 $(patches): $(sha1s)
 	@echo -e "\n======= Create Patches =======\n" ; \
-	 ( cd create-glibc-2.23-i18n-patch     ; ./create.patch.sh ) ; \
-	 ( cd create-glibc-2.23-zoneinfo-patch ; ./create.patch.sh ) ; \
+	 ( cd create-glibc-2.23-i18n-patch        ; ./create.patch.sh ) ; \
+	 ( cd create-glibc-2.23-vfork-alias-patch ; ./create.patch.sh ) ; \
+	 ( cd create-glibc-2.23-zoneinfo-patch    ; ./create.patch.sh ) ; \
 	 echo -e "\n"
 
 download_clean:
diff --git a/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/create.patch.sh b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/create.patch.sh
new file mode 100755
index 000000000..e9e12b829
--- /dev/null
+++ b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2.23
+
+tar --files-from=file.list -xJvf ../glibc-$VERSION.tar.xz
+mv glibc-$VERSION glibc-$VERSION-orig
+
+cp -rf ./glibc-$VERSION-new ./glibc-$VERSION
+
+diff -b --unified -Nr  glibc-$VERSION-orig  glibc-$VERSION > glibc-$VERSION-vfork-alias.patch
+
+mv glibc-$VERSION-vfork-alias.patch ../patches
+
+rm -rf ./glibc-$VERSION
+rm -rf ./glibc-$VERSION-orig
diff --git a/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/file.list b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/file.list
new file mode 100644
index 000000000..47c02e020
--- /dev/null
+++ b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/file.list
@@ -0,0 +1,3 @@
+glibc-2.23/sysdeps/unix/sysv/linux/mips/vfork.S
+glibc-2.23/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
+glibc-2.23/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
diff --git a/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/mips/vfork.S b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/mips/vfork.S
new file mode 100644
index 000000000..c0c0ce699
--- /dev/null
+++ b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -0,0 +1,113 @@
+/* Copyright (C) 2005-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* vfork() is just a special case of clone().  */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <asm/unistd.h>
+#include <sgidefs.h>
+#include <tls.h>
+
+
+/* int vfork() */
+
+	.text
+	.set		nomips16
+LOCALSZ= 1
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+GPOFF= FRAMESZ-(1*SZREG)
+NESTED(__vfork,FRAMESZ,sp)
+#ifdef __PIC__
+	SETUP_GP
+#endif
+	PTR_SUBU sp, FRAMESZ
+	cfi_adjust_cfa_offset (FRAMESZ)
+	SETUP_GP64_REG (a5, __vfork)
+#ifdef __PIC__
+	SAVE_GP (GPOFF)
+#endif
+#ifdef PROF
+# if (_MIPS_SIM != _ABIO32)
+	PTR_S		a5, GPOFF(sp)
+# endif
+	.set		noat
+	move		$1, ra
+# if (_MIPS_SIM == _ABIO32)
+	subu		sp,sp,8
+# endif
+	jal		_mcount
+	.set		at
+# if (_MIPS_SIM != _ABIO32)
+	PTR_L		a5, GPOFF(sp)
+# endif
+#endif
+
+	PTR_ADDU	sp, FRAMESZ
+	cfi_adjust_cfa_offset (-FRAMESZ)
+
+	/* Save the PID value.  */
+	READ_THREAD_POINTER(v1)	   /* Get the thread pointer.  */
+	lw	a2, PID_OFFSET(v1) /* Load the saved PID.  */
+	subu	a2, $0, a2	   /* Negate it.  */
+	bnez	a2, 1f		   /* If it was zero... */
+	lui	a2, 0x8000	   /* use 0x80000000 instead.  */
+1:	sw	a2, PID_OFFSET(v1) /* Store the temporary PID.  */
+
+	li		a0, 0x4112	/* CLONE_VM | CLONE_VFORK | SIGCHLD */
+	move		a1, sp
+
+	/* Do the system call */
+	li		v0,__NR_clone
+	syscall
+
+	/* Restore the old PID value in the parent.  */
+	beqz	v0, 1f		/* If we are the parent... */
+	READ_THREAD_POINTER(v1)	/* Get the thread pointer.  */
+	lw	a2, PID_OFFSET(v1) /* Load the saved PID.  */
+	subu	a2, $0, a2	   /* Re-negate it.  */
+	lui	a0, 0x8000	   /* Load 0x80000000... */
+	bne	a2, a0, 2f	   /* ... compare against it... */
+	li	a2, 0		   /* ... use 0 instead.  */
+2:	sw	a2, PID_OFFSET(v1) /* Restore the PID.  */
+1:
+
+	cfi_remember_state
+	bnez		a3,L(error)
+
+	/* Successful return from the parent or child.  */
+	RESTORE_GP64_REG
+	ret
+
+	/* Something bad happened -- no child created.  */
+L(error):
+	cfi_restore_state
+#ifdef __PIC__
+	PTR_LA		t9, __syscall_error
+	RESTORE_GP64_REG
+	jr		t9
+#else
+	RESTORE_GP64_REG
+	j		__syscall_error
+#endif
+	END(__vfork)
+
+#if IS_IN (libc)
+libc_hidden_def(__vfork)
+weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork)
+#endif
diff --git a/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
new file mode 100644
index 000000000..94f2c8d3e
--- /dev/null
+++ b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
@@ -0,0 +1,51 @@
+/* Copyright (C) 2004-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include <tcb-offsets.h>
+
+	.text
+	.globl		__syscall_error
+ENTRY(__vfork)
+	ld	[%g7 + PID], %o5
+	cmp	%o5, 0
+	bne	1f
+	 sub	%g0, %o5, %o4
+	sethi	%hi(0x80000000), %o4
+1:	st	%o4, [%g7 + PID]
+
+	LOADSYSCALL(vfork)
+	ta	0x10
+	bcc	2f
+	 mov	%o7, %g1
+	st	%o5, [%g7 + PID]
+	call	__syscall_error
+	 mov	%g1, %o7
+2:	sub	%o1, 1, %o1
+	andcc	%o0, %o1, %o0
+	bne,a	1f
+	 st	%o5, [%g7 + PID]
+1:	retl
+	 nop
+END(__vfork)
+
+#if IS_IN (libc)
+libc_hidden_def (__vfork)
+weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork)
+#endif
diff --git a/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
new file mode 100644
index 000000000..a7479e9f2
--- /dev/null
+++ b/sources/GNU/glibc/2.23/create-glibc-2.23-vfork-alias-patch/glibc-2.23-new/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
@@ -0,0 +1,51 @@
+/* Copyright (C) 2004-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include <tcb-offsets.h>
+
+	.text
+	.globl	__syscall_error
+ENTRY(__vfork)
+	ld	[%g7 + PID], %o5
+	sethi	%hi(0x80000000), %o3
+	cmp	%o5, 0
+	sub	%g0, %o5, %o4
+	move	%icc, %o3, %o4
+	st	%o4, [%g7 + PID]
+
+	LOADSYSCALL(vfork)
+	ta	0x6d
+	bcc,pt	%xcc, 2f
+	 mov	%o7, %g1
+	st	%o5, [%g7 + PID]
+	call	__syscall_error
+	 mov	%g1, %o7
+2:	sub	%o1, 1, %o1
+	andcc	%o0, %o1, %o0
+	bne,a,pt %icc, 1f
+	 st	%o5, [%g7 + PID]
+1:	retl
+	 nop
+END(__vfork)
+
+#if IS_IN (libc)
+libc_hidden_def (__vfork)
+weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork)
+#endif