OSDN Git Service

Remove TEXTREL relocations for ARM.
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / arm / clone.S
1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Pat Beirne <patb@corelcomputer.com>
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 /* clone() is even more special than fork() as it mucks with stacks
21    and invokes a function in the right context after its all over.  */
22
23 #define _ERRNO_H
24 #include <bits/errno.h>
25 #include <sys/syscall.h>
26
27 #ifdef __NR_clone
28 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
29
30         .text
31         .globl __clone
32         .type __clone,%function
33         .align 4
34 __clone:
35         @ sanity check args
36         cmp     r0, #0
37         cmpne   r1, #0
38         moveq   r0, #-EINVAL
39         beq     __error
40
41         @ insert the args onto the new stack
42         sub     r1, r1, #8
43         str     r3, [r1, #4]
44         @ save the function pointer as the 0th element
45         str     r0, [r1]
46
47         @ do the system call
48         @ get flags
49         mov     r0, r2
50         @ new sp is already in r1
51         swi     __NR_clone
52         movs    a1, a1
53         blt     __error
54         movne    pc, lr
55
56         @ pick the function arg and call address off the stack and execute
57         ldr     r0, [sp, #4]
58         mov     lr, pc
59         ldr     pc, [sp]
60
61         @ and we are done, passing the return value through r0
62 #ifdef __PIC__
63         b       _exit(PLT)
64 #else
65         b       _exit
66 #endif
67
68 __error:
69         b       __syscall_error
70
71         .size __clone,.-__clone
72
73         .weak clone
74         clone = __clone
75
76 #endif