I noticed that the x86 int $0x80
and the amd64 syscall
system calls have different numbers. For instance, sys_exit
is syscall 1 in x86 and syscall 60 in amd64. Is there a (historical) reason for the different system call numbering schemes?
A system call is a procedure that provides the interface between a process and the operating system. It is the way by which a computer program requests a service from the kernel of the operating system. Different operating systems execute different system calls.
Why are system calls necessary? The need for system calls is closely tied to the modern operating system model with user mode and kernel mode, which was implemented as a response to the rising number of processes being carried out simultaneously in computers' main memory (working memory).
On Linux, the arguments are passed using ebx , ecx , edx , esi , and edi . On Windows, the arguments are copied from the stack. The handler then performs some sort of lookup (to find the address of the function) and executes the system call. After the system call is completed, the iret instruction returns to user-mode.
System calls are identified by their numbers. The number of the call foo is __NR_foo . For example, the number of _llseek used above is __NR__llseek , defined as 140 in /usr/include/asm-i386/unistd.
The syscall interface is supposed to be very stable and only additions are allowed. Talking advantage of the fact that the syscall interface is different for each architecture, the Linux guys most likely decided to clean up some accumulated cruft and start the amd64 syscalls from scratch.
Reference: linux/Documentation/ABI/stable/syscalls
This interface matches much of the POSIX interface and is based on it and other Unix based interfaces. It will only be added to over time, and not have things removed from it.
Note that this interface is different for every architecture that Linux supports. Please see the architecture-specific documentation for details on the syscall numbers that are to be mapped to each syscall.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With