How can I get a list of Linux system calls and number of args they take automatically?

情到浓时终转凉″ 提交于 2019-12-02 20:37:16
Matthew Slattery

strace (home page) has tables with all this stuff in (see linux/<platform>/syscallent.h). Source code available in GitHub/strace and GitLab/strace. For example, list of syscalls in x86_64 architecture are in this link.

The only list I know is the kernel source, in include/linux/syscalls.h. But that is only by name, not number; I think you need to use the syscall.h header for your particular platform to get the numbers. And there are a few #ifdefs in that file...

Documentation parsing:

http://asm.sourceforge.net/syscall.html Parse the HTML inside the <pre> tags.

or

http://syscalls.kernelgrok.com/ Convert JSON http://syscalls.kernelgrok.com/syscalls-2.6.35.4.js

ausyscall - a program that allows mapping syscall names and numbers

There are system calls with variable numbers of arguments - witness the open() call at the C level, where the third parameter is optional (might not be optional at the assembler level).

Your best bet might be to find the system calls identified by name in syscalls.h in the (preprocessed) source of the other system headers. From those, you can count the number of arguments. Just getting the right headers in place might be tricky, and there might conceivably be system calls that are never exposed as C functions directly (I haven't looked to see; it is fairly unlikely, though).

You might look at how another debugger, such as GDB, does the same job.

This post is worth reading. Hope this helps :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!