How do you check syscall for x86_64?

旧时模样 提交于 2019-12-07 10:39:39

问题


I can't find a dedicated official website to search for such information .

For example,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.


回答1:


Glibc sysdeps/unix/sysv/linux/x86_64/syscall.S, see if this helps.




回答2:


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.



来源:https://stackoverflow.com/questions/6537828/how-do-you-check-syscall-for-x86-64

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