From ef108730dc05fe3fc4d4cf5ff89a544b0d615fe6 Mon Sep 17 00:00:00 2001 From: Hubert Badocha Date: Wed, 29 Nov 2023 20:24:32 +0100 Subject: [PATCH] ia32/vfork: simplify assembly JIRA: RTOS-697 --- arch/ia32/syscalls.S | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/arch/ia32/syscalls.S b/arch/ia32/syscalls.S index ef4a78d8..568a26b1 100644 --- a/arch/ia32/syscalls.S +++ b/arch/ia32/syscalls.S @@ -32,27 +32,17 @@ sym: \ .size sym, .-sym -.bss -vfork_address: -.space 4 -.text .globl vfork .type vfork, @function .align 4, 0x90 vfork: - mov (%esp), %eax - mov %eax, (vfork_address) + /* Save the return address as child will override parent's stack. + * Syscalls restore all registers but %eax thus %edx will not be overwritten. + * %edx is used as it need not to be restored before function exit. */ + mov (%esp), %edx movl $4, %eax int $0x80 - cmp $0, %eax - jz vfork_child - push %eax - mov (vfork_address), %eax - mov %eax, 4(%esp) - pop %eax - ret -vfork_child: - mov $0, %eax + mov %edx, (%esp) ret .size vfork, .-vfork