Elliott Hughes | bdff26d | 2013-02-11 17:08:16 -0800 | [diff] [blame] | 1 | #include <machine/asm.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 2 | #include <sys/linux-syscalls.h> |
| 3 | |
| 4 | #ifndef __NR_vfork |
| 5 | #define __NR_vfork 190 |
| 6 | #endif |
| 7 | |
| 8 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 9 | /* Get rid of the stack modifications (popl/ret) after vfork() success. |
| 10 | * vfork is VERY sneaky. One has to be very careful about what can be done |
| 11 | * between a successful vfork and a a subsequent execve() |
| 12 | */ |
| 13 | |
Elliott Hughes | bdff26d | 2013-02-11 17:08:16 -0800 | [diff] [blame] | 14 | ENTRY(vfork) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 15 | /* grab the return address */ |
| 16 | popl %ecx |
| 17 | movl $__NR_vfork, %eax |
| 18 | int $0x80 |
| 19 | cmpl $-129, %eax |
| 20 | jb 1f |
| 21 | negl %eax |
| 22 | pushl %eax |
| 23 | call __set_errno |
| 24 | orl $-1, %eax |
| 25 | 1: |
| 26 | jmp *%ecx |
Elliott Hughes | bdff26d | 2013-02-11 17:08:16 -0800 | [diff] [blame] | 27 | END(vfork) |