Issue
I have a confusion about the system call mechanism. In X86, System Call uses eax
to pass the system call number to kernel.
But what does it use to pass the parameters to kernel, at some place I am seeing it uses stack and at other places it says, it uses ebx
, ecx
, etc registers.
So can someone confirm which one is correct ?
Fore reference : this link says it uses stack.
And this link says it uses registers.
Solution
Both the links tell that the parameters are passed through registers like EBX, ECX, etc to the kernel space from the user space.
In the first reference page : 35/352, System Call Implementation/wrappers task 1st point, it is given that
the parameters available in the user stack are moved to the processor registers and then this registers are used to pass parameters of the syscall to the kernel space.
I think you must be confused after seeing the word stack in that point about implementing the libc wrappers like write()
which are callable from C, to interface between the system-call calling convention (6 regs) and the function-calling convention (stack args since user-space doesn't normally use -mregparm=3
)
Answered By - Santosh A Answer Checked By - Pedro (WPSolving Volunteer)