Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the system call numbers different in amd64 linux?

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?

like image 332
fuz Avatar asked Apr 23 '12 13:04

fuz


People also ask

What is system call number in Linux?

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 so many different system calls required?

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).

How does Linux implement system calls?

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.

How system calls are called by number and name in Linux?

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.


1 Answers

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.

like image 173
user1202136 Avatar answered Sep 19 '22 19:09

user1202136