0

I'm learning how to implement the system call for my own x86_64 OS project. I know that syscall instruction is used for system call, and the underlying operations from https://www.felixcloutier.com/x86/syscall.html.

I also noticed that in Linux, the system call number is specified in %rax.

What I don't understand is, how does syscall find the address of the system call via %rax. I assume that the table of system call must be stored somewhere.

I'm looking for more detailed explanation on how syscall knows the address of the called system calls.

  • 1
    I believe the systemcall handler code simply uses `%rax` to index into a global table of function pointers, after doing range checking. – Petr Skocik Feb 01 '23 at 17:10
  • The syscall instruction just transfers control to a single kernel entry point. Determining the operation to perform is done by the kernel software. Using rax to specify the operation is a software convention. The syscall instruction itself doesn't use rax at all. – prl Feb 01 '23 at 22:46

0 Answers0