On Wed, Jul 26, 2023 at 01:04:26AM +0800, Zhangjin Wu wrote:
My old 'reply' is not rigorous, since the syscall6() uses stack to pass the 6th argument, so, our new syscall.h didn't support it currently, the syscalls I have tested about "=r" instead of "=a" were only syscall1-5().
Yeah, it won't fit with the new design.
i386 runs out of GPRs very quickly. Given that, it had a hard time implementing syscall6() properly in nolibc. The calling convention itself actually doesn't require stack for executing 'int $0x80'.
The reason of why it uses stack is because the %ebp register cannot be listed in the clobber list nor in the constraint if -fomit-frame-pointer is not activated. Thus, we have to carefully preserve the value on the stack before using %ebp as the 6-th argument to the syscall. It's a hack to make it work on i386.
Ok, so, with the new syscalls.h proposed, we'd better keep i386 syscall6() as-is.
For the left syscall1-5(), is there any risk when use '=r' instead of 'r'?
Using "=r" instead of "r" doesn't make sense.
Did you mean "=r" instead of "=a"?
Yeah, sorry.
If that's what you mean:
So far I don't see the risk of using "=r" instead of "=a" as long as the variable is properly marked as 'register' + asm("eax").
Thanks. Zhangjin
-- Ammar Faizi