From 37756a838922d080448793aa5ab5e90c5aba78c1 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 7 Dec 2004 14:01:11 +0000 Subject: Updated to fedora-glibc-20041207T1331 --- sysdeps/unix/sysv/linux/arm/clone.S | 2 +- sysdeps/unix/sysv/linux/arm/mmap.S | 4 ++-- sysdeps/unix/sysv/linux/arm/mmap64.S | 4 ++-- sysdeps/unix/sysv/linux/arm/socket.S | 4 ++-- sysdeps/unix/sysv/linux/arm/sysdep.h | 4 ++-- sysdeps/unix/sysv/linux/arm/vfork.S | 4 ++-- sysdeps/unix/sysv/linux/i386/clone.S | 36 ++++++++++++++++++++++++++++++++-- sysdeps/unix/sysv/linux/x86_64/clone.S | 20 +++++++++++++++++-- 8 files changed, 63 insertions(+), 15 deletions(-) (limited to 'sysdeps/unix/sysv/linux') diff --git a/sysdeps/unix/sysv/linux/arm/clone.S b/sysdeps/unix/sysv/linux/arm/clone.S index 1c6f7861cf..bf07fb3952 100644 --- a/sysdeps/unix/sysv/linux/arm/clone.S +++ b/sysdeps/unix/sysv/linux/arm/clone.S @@ -45,7 +45,7 @@ ENTRY(__clone) swi SYS_ify(clone) movs a1, a1 blt PLTJMP(C_SYMBOL_NAME(__syscall_error)) - RETINSTR(movne, pc, lr) + RETINSTR(ne, lr) @ pick the function arg and call address off the stack and execute ldr r0, [sp, #4] diff --git a/sysdeps/unix/sysv/linux/arm/mmap.S b/sysdeps/unix/sysv/linux/arm/mmap.S index 7beba6841c..cf6f253378 100644 --- a/sysdeps/unix/sysv/linux/arm/mmap.S +++ b/sysdeps/unix/sysv/linux/arm/mmap.S @@ -51,7 +51,7 @@ ENTRY (__mmap) ldr r5, [sp], #4 cmn r0, $4096 - RETINSTR(movcc, pc, lr) + RETINSTR(cc, lr) b PLTJMP(syscall_error) .Linval: @@ -83,7 +83,7 @@ ENTRY (__mmap) add sp, sp, #16 cmn r0, $4096 - RETINSTR(movcc, pc, lr) + RETINSTR(cc, lr) b PLTJMP(syscall_error); #endif diff --git a/sysdeps/unix/sysv/linux/arm/mmap64.S b/sysdeps/unix/sysv/linux/arm/mmap64.S index f8361b5cbf..b4b712c2f2 100644 --- a/sysdeps/unix/sysv/linux/arm/mmap64.S +++ b/sysdeps/unix/sysv/linux/arm/mmap64.S @@ -43,12 +43,12 @@ ENTRY (__mmap64) # ifdef __ASSUME_MMAP2_SYSCALL ldr r4, [sp], #4 ldr r5, [sp], #4 - RETINSTR(movcc, pc, lr) + RETINSTR(cc, lr) b PLTJMP(syscall_error) # else ldrcc r4, [sp], #4 ldrcc r5, [sp], #4 - RETINSTR(movcc, pc, lr) + RETINSTR(cc, lr) cmn r0, $ENOSYS bne .Lerror /* The current kernel does not support mmap2. Fall back to plain diff --git a/sysdeps/unix/sysv/linux/arm/socket.S b/sysdeps/unix/sysv/linux/arm/socket.S index 3e93ceb6d2..212a489afe 100644 --- a/sysdeps/unix/sysv/linux/arm/socket.S +++ b/sysdeps/unix/sysv/linux/arm/socket.S @@ -91,7 +91,7 @@ ENTRY (__socket) /* r0 is < 0 if there was an error. */ cmn r0, $124 - RETINSTR(movcc, pc, r14) + RETINSTR(cc, r14) b PLTJMP(SYSCALL_ERROR) #if defined NEED_CANCELLATION && defined CENABLE @@ -114,7 +114,7 @@ ENTRY (__socket) /* r0 is < 0 if there was an error. */ cmn r0, $124 - RETINSTR(movcc, pc, r14) + RETINSTR(cc, r14) b PLTJMP(SYSCALL_ERROR) #endif diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h index fda7c5b267..668aa1a2f1 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -54,7 +54,7 @@ cmn r0, $4096; #define PSEUDO_RET \ - RETINSTR(movcc, pc, lr); \ + RETINSTR(cc, lr); \ b PLTJMP(SYSCALL_ERROR) #undef ret #define ret PSEUDO_RET @@ -71,7 +71,7 @@ DO_CALL (syscall_name, args); #define PSEUDO_RET_NOERRNO \ - RETINSTR(mov, pc, lr); + DO_RET (lr); #undef ret_NOERRNO #define ret_NOERRNO PSEUDO_RET_NOERRNO diff --git a/sysdeps/unix/sysv/linux/arm/vfork.S b/sysdeps/unix/sysv/linux/arm/vfork.S index bba1a548ba..9ef5114b24 100644 --- a/sysdeps/unix/sysv/linux/arm/vfork.S +++ b/sysdeps/unix/sysv/linux/arm/vfork.S @@ -32,7 +32,7 @@ ENTRY (__vfork) #ifdef __NR_vfork swi __NR_vfork cmn a1, #4096 - RETINSTR(movcc, pc, lr) + RETINSTR(cc, lr) # ifdef __ASSUME_VFORK_SYSCALL b PLTJMP(C_SYMBOL_NAME(__syscall_error)) @@ -47,7 +47,7 @@ ENTRY (__vfork) /* If we don't have vfork, fork is close enough. */ swi __NR_fork cmn a1, #4096 - RETINSTR(movcc, pc, lr) + RETINSTR(cc, lr) b PLTJMP(C_SYMBOL_NAME(__syscall_error)) #elif !defined __NR_vfork # error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined" diff --git a/sysdeps/unix/sysv/linux/i386/clone.S b/sysdeps/unix/sysv/linux/i386/clone.S index 94c6a72548..acd43dfb0b 100644 --- a/sysdeps/unix/sysv/linux/i386/clone.S +++ b/sysdeps/unix/sysv/linux/i386/clone.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,1997,98,99,2000,02,03 Free Software Foundation, Inc. +/* Copyright (C) 1996,1997,98,99,2000,02,03,04 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@tamu.edu) @@ -42,6 +42,9 @@ #define __NR_clone 120 #define SYS_clone 120 +#define CLONE_VM 0x00000100 +#define CLONE_THREAD 0x00010000 + .text ENTRY (BP_SYM (__clone)) /* Sanity check arguments. */ @@ -74,7 +77,9 @@ ENTRY (BP_SYM (__clone)) movl %eax,8(%ecx) /* Don't leak any information. */ movl $0,4(%ecx) +#ifndef RESET_PID movl $0,(%ecx) +#endif /* Do the system call */ pushl %ebx @@ -85,6 +90,12 @@ ENTRY (BP_SYM (__clone)) movl FLAGS+12(%esp),%ebx movl CTID+12(%esp),%edi movl $SYS_ify(clone),%eax + +#ifdef RESET_PID + /* Remember the flag value. */ + movl %ebx, (%ecx) +#endif + int $0x80 popl %edi popl %esi @@ -98,7 +109,13 @@ L(pseudo_end): ret L(thread_start): - subl %ebp,%ebp /* terminate the stack frame */ + /* Note: %esi is zero. */ + movl %esi,%ebp /* terminate the stack frame */ +#ifdef RESET_PID + testl $CLONE_THREAD, %edi + je L(newpid) +L(haspid): +#endif call *%ebx #ifdef PIC call L(here) @@ -110,6 +127,21 @@ L(here): movl $SYS_ify(exit), %eax int $0x80 +#ifdef RESET_PID + .subsection 2 +L(newpid): + testl $CLONE_VM, %edi + movl $-1, %eax + jne L(nomoregetpid) + movl $SYS_ify(getpid), %eax + ENTER_KERNEL +L(nomoregetpid): + movl %eax, %gs:PID + movl %eax, %gs:TID + jmp L(haspid) + .previous +#endif + PSEUDO_END (BP_SYM (__clone)) weak_alias (BP_SYM (__clone), BP_SYM (clone)) diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S index d182fe2f9e..9695e1eaf8 100644 --- a/sysdeps/unix/sysv/linux/x86_64/clone.S +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S @@ -26,6 +26,9 @@ #include #include +#define CLONE_VM 0x00000100 +#define CLONE_THREAD 0x00010000 + /* The userland implementation is: int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg), the kernel entry is: @@ -80,16 +83,29 @@ ENTRY (BP_SYM (__clone)) testq %rax,%rax jl SYSCALL_ERROR_LABEL - jz thread_start + jz L(thread_start) L(pseudo_end): ret -thread_start: +L(thread_start): /* Clear the frame pointer. The ABI suggests this be done, to mark the outermost frame obviously. */ xorq %rbp, %rbp +#ifdef RESET_PID + testq $CLONE_THREAD, %rdi + jne 1f + testq $CLONE_VM, %rdi + movl $-1, %eax + jne 2f + movq $SYS_ify(getpid), %rax + syscall +2: movl %eax, %fs:PID + movl %eax, %fs:TID +1: +#endif + /* Set up arguments for the function call. */ popq %rax /* Function to call. */ popq %rdi /* Argument. */ -- cgit 1.4.1