Linux 中的系统调用是如何定位的?
我正在尝试在 Red Hat 8.0 中添加一个新的系统调用,但我对该机制的某些方面感到困惑。我一直在遵循本指南:http://www.linuxjournal.com/article/3326 其中详细介绍了更新 entry.S
和 unistd.h
中系统调用表的步骤。
但是,我似乎无法弄清楚编译器如何从这些信息中实际找到系统调用的实现位置。显然有一些涉及#include的东西,但我找不到任何包含的迹象,也找不到代码中的许多系统调用。我需要做什么才能找到我的系统调用?
I'm trying to add a new syscall in Red Hat 8.0 and I'm confused about some aspect of the mechanism. I've been following this guide: http://www.linuxjournal.com/article/3326 which details the steps of updating the syscall table in entry.S
and unistd.h
.
However, I can't seem to figure out how the compiler actually finds where the syscall is implemented from this information. Obviously there's something that involves #include
s, but I can't find any indications of includes being made, nor locate many of the syscalls in the code. What do I need to do for my syscall to be found?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C 库提供的函数恰好看起来像系统调用。实际发生的情况是调用 C 库函数,然后进行系统调用。
如果添加新的系统调用,那么为了使其易于使用,您需要将其添加到 C 库并重新编译。
或者您可以使用C库提供的系统调用函数和宏:syscall和_syscall。
尝试
man syscall
和man _syscall
查看详细信息。The C library provides functions which happen to look like system calls. What actually happens is that the C library function is called and then it makes the system call.
If you add a new system call, then to make it easily usable you would need to add it to the C library and recompile that too.
Or you can use the syscall function and macros provided by the C library: syscall and _syscall.
Try
man syscall
andman _syscall
to see details.