Where do you test prototypes of system calls on x86-64 machines?

That is, as you know

how many parameters a particular system call expects

which registers each parameter should be in

and finally, what does each parameter mean?

Is there a man command to tell you this?

+6
source share
3 answers

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

What you are looking for is the core of ABI, I can’t find the official site, but there is a blog with information like this.

On x64 with int 80h call this:

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

Man page project for man pages (of course, C-centric)

+2
source

There is no guide for system calls that I know of, this is what you need to paste into the source code.

This header file is useful because it has many system calls prototyped with arguments:

include/linux/syscalls.h

It contains definitions, for example:

 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 contains the rest of the system calls, which depend on the form:

arch/x86/include/asm/syscalls.h

(these files are equal to 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 quite often, and there is not much effort to maintain a stable ABI between major versions of the kernel. Thus, you will have to look at the source code of the kernel of the kernel you are currently working in, and do not expect it to be automatically compiled into any other version of the kernel.

+1
source

Source: https://habr.com/ru/post/904284/


All Articles