Live data from Hacker News

Linux System Call Table

thevivekpandey.github.io

21–30 of 65 posts

Re: Linux System Call Table

#21

Actually, the syscall numbers are wrong! This reference seems better: http://blog.rchapman.org/posts/Linux_System_Call_Table_for_x... Consider simple C program: #define _GNU_SOURCE #include int main(){ syscall(276); } Strace'ing it shows the syscall used is tee, just as the reference I linked shows, and not pwritev as in OP's table.

I think you're right - the submitted table has no entries for "fork" and "clone".

Re: Linux System Call Table

#22
post #9
post #6

If man pages were up to date, this should be the index of chapter 2. I have discover unix with sun in the 90s and I am very nostalgic of the quality of man pages. At that time, man pages were complete and up to date. My latest frustration was with the option -m of df command. Chapter 2 should be updated each time a new version of kernel is installed.

It's very strange that adding/updating documentation isn't treated as a basic requirement for a patch that adds to or modifies Linux's public interfaces.

Man pages aren't even in the kernel tree.

Re: Linux System Call Table

#23
So the issues noticed so far:

* Missing syscalls

* Wrong syscall numbers

* Wrong calling convention

* Links to source are to wrong version

Does the table get actually anything right? I mean this is pretty spectacular cascade of failures.

Re: Linux System Call Table

#24
post #6

If man pages were up to date, this should be the index of chapter 2. I have discover unix with sun in the 90s and I am very nostalgic of the quality of man pages. At that time, man pages were complete and up to date. My latest frustration was with the option -m of df command. Chapter 2 should be updated each time a new version of kernel is installed.

Michael Kerris keeps and up to date reference [1]. Even details _all_ system calls [2].

[1] https://www.kernel.org/doc/man-pages/

[2] http://man7.org/linux/man-pages/dir_section_2.html

Re: Linux System Call Table

#25
post #23

So the issues noticed so far: * Missing syscalls * Wrong syscall numbers * Wrong calling convention * Links to source are to wrong version Does the table get actually anything right? I mean this is pretty spectacular cascade of failures.

At least for x86, you can get this same information fairly easily directly from the source. The table is located at arch/x86/entry/syscalls/syscall_64.tbl, from there you can grep for the function with git grep. For example, git grep 'SYSCALL_DEFINE.*read'.

Re: Linux System Call Table

#27

That's all cool and everything, but the registers are wrong... Not only are they 32-bit (eax vs. rax), but their order is wrong too - the first argument in x86-64 ABI is rdi, for example.

The registers look correct for the i386 ABI. eax for the system call number, then ebx, ecx, edx, esi, edi, ebp for the next 6 arguments.

I skimmed a couple files in the code. And it seems like it might be parsing this information out of some other sources, and maybe getting confused about the info it's grabbing?

https://github.com/thevivekpandey/syscalls-table-64bit

Re: Linux System Call Table

#28

This is great! It would be even more useful to have this for Mac OSX too. A lot of the projects I do ends up being on both Mac and Linux. It's always a pain to find the corresponding number for the system call on Mac.

There is a bsd/kern/syscalls.master file for every kernel at https://opensource.apple.com/source/xnu/

Re: Linux System Call Table

#29

This is great! It would be even more useful to have this for Mac OSX too. A lot of the projects I do ends up being on both Mac and Linux. It's always a pain to find the corresponding number for the system call on Mac.

System calls have not stability guarantee on macOS. You should use libc instead. In general the use of syscalls directly is fairly limited. Edit: for instance go broke once for macOS Sierra, when Apple changed the gettimeofday system call: https://github.com/golang/go/issues/16570

Linux doesn't guarantee syscall stability either. Just make sure your wrappers can use a syscall table chosen at runtime, depending on which kernel you are running.

Re: Linux System Call Table

#30
post #29

Earlier quoted context omitted.

System calls have not stability guarantee on macOS. You should use libc instead. In general the use of syscalls directly is fairly limited. Edit: for instance go broke once for macOS Sierra, when Apple changed the gettimeofday system call: https://github.com/golang/go/issues/16570

Linux doesn't guarantee syscall stability either. Just make sure your wrappers can use a syscall table chosen at runtime, depending on which kernel you are running.

if you're going to implement that kind of overhead why not just use libc?
Post reply on HN