I can't find a dedicated official website to search for such information .
For 开发者_StackOverflowexample,if I want to do exit
,how should I do it with syscall
introduced in x86_64?
Any manual for this kind of details?
I'm on Centos.
Glibc sysdeps/unix/sysv/linux/x86_64/syscall.S
, see if this helps.
Let the C library do it for you:
movl $0, %rdi # or whatever exit code you want (0-127)
call _exit
You really do not want to make system calls yourself. The C library insulates you from a bunch of low-level ABI issues (many system calls exist in more than one version, depending on exactly which kernel you have; some of them don't require an actual trap into supervisor mode; etc), it knows how to set errno
, and it will pick the most efficient trap sequence for the architecture and kernel version.
精彩评论