Re: [RFC PATCH v1 3/6] tools/nolibc: i386: Implement syscall with 6 arguments

From: Ammar Faizi
Date: Sun Mar 20 2022 - 11:09:12 EST


On 3/20/22 5:42 PM, Alviro Iskandar Setiawan wrote:
On Sun, Mar 20, 2022 at 5:33 PM Alviro Iskandar Setiawan wrote:
[...]
I don't think you can safely use redzone from inline Assembly. The
compiler may also use redzone for a leaf function. In case the syscall
is done at the same time, your %ebp saving will clobber the redzone
that the compiler uses.

It turned out we don't have a redzone for 32-bit.


-4(%esp) may be used by the compiler on a leaf call, you can't clobber that.

Yeah, this is still wrong even with a redzone.

Using xchgl to preserve %ebp in the same place where the arg6 is
stored in memory is a better solution and doesn't clobber anything.

xchgl %ebp, %[arg6]
int $0x80
xchgl %ebp, %[arg6]

Addressed your review in my response to David.

Thanks!

--
Ammar Faizi