Linux 中的系统调用是如何定位的?

发布于 2024-08-09 15:18:43 字数 360 浏览 0 评论 0原文

我正在尝试在 Red Hat 8.0 中添加一个新的系统调用,但我对该机制的某些方面感到困惑。我一直在遵循本指南:http://www.linuxjournal.com/article/3326 其中详细介绍了更新 entry.Sunistd.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 #includes, 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两仪 2024-08-16 15:18:44

C 库提供的函数恰好看起来像系统调用。实际发生的情况是调用 C 库函数,然后进行系统调用。

如果添加新的系统调用,那么为了使其易于使用,您需要将其添加到 C 库并重新编译。

或者您可以使用C库提供的系统调用函数和宏:syscall和_syscall。

尝试 man syscallman _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 and man _syscall to see details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文