new_perl
new_perl

Reputation: 7735

Where do you check the prototypes of syscalls on x86-64 machines?

That is, how do you know

how many parameters a specific syscall expects,

which register each parameter should be in,

and finally what each parameter means?

Is there a man alike command to tell you that?

Upvotes: 6

Views: 1340

Answers (3)

muixirt
muixirt

Reputation: 126

Linux man-pages project (of course C-centric)

Upvotes: 2

J-16 SDiZ
J-16 SDiZ

Reputation: 26910

see also: What are the calling conventions for UNIX & Linux system calls on x86-64

What you are looking for is the kernel ABI, I can't find the official site, but there is a blog with info like this.

In x64 with int 80h call, it is:

value   storage
syscall nr  rax
arg 1   rdi
arg 2   rsi
arg 3   rdx
arg 4   r10
arg 5   r9
arg 6   r8

Upvotes: 3

Corey Henderson
Corey Henderson

Reputation: 7455

There is no manual for system calls that I know of, it's something you have to dig into the source code for.

This header file is useful, as it has many of the system calls prototyped with arguments:

include/linux/syscalls.h

It conains definitions, like:

asmlinkage long sys_getresuid(uid_t __user *ruid, uid_t __user *euid, uid_t __user *suid);
asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid);
asmlinkage long sys_getpgid(pid_t pid);
asmlinkage long sys_getpgrp(void);
asmlinkage long sys_getsid(pid_t pid);
asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist);

The arch syscalls header file has the rest of the system calls, one that are arch dependant:

arch/x86/include/asm/syscalls.h

(these files are as of 2.6.32 - earlier / later versions of the kernels may have different file/directory names).

Keep in mind that the internals of the linux kernel change fairly often, and there isn't a whole lot of effort put into keeping a stable ABI between major kernel versions. So, you'll have to look at the kernel source code of the kernel you're currently running, and don't expect it to automatically compile on any other kernel version.

Upvotes: 1

Related Questions