如何强制 gcc 使用 int 进行系统调用,而不是 sysenter?

发布于 2024-08-19 05:41:51 字数 289 浏览 1 评论 0原文

是否可以强制 gcc 对所有系统调用使用 int 指令,但不能使用 sysenter 指令?这个问题可能听起来很奇怪,但我必须用这种方式编译一些项目,比如Python和Firefox。

总结

感谢jbcreix,我下载了glibc 2.9源代码,并修改了sysdeps/unix/sysv/linux/i386/sysdep.h中的行,以通过#禁用sysenter的使用undef I386_USE_SYSENTER,它就可以工作了。

Is it possible to force gcc use int instruction for all the system calls, but not sysenter? This question may sound strange but I have to compile some projects like Python and Firefox this way.

Summary

Thanks to jbcreix, I've downloaded glibc 2.9 source code, and modified the lines in sysdeps/unix/sysv/linux/i386/sysdep.h, to disable use of sysenter by #undef I386_USE_SYSENTER, and it works.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

帅气称霸 2024-08-26 05:41:51

syscall.s 中将 sysenter 替换为 int 0x80 后重新编译 C 库,并再次链接。

这不是编译器生成的代码,这意味着您很幸运。

实际系统调用的最终起源在这里,正如OP所说:

http://cvs.savannah.gnu.org/viewvc/libc/sysdeps/unix/sysv/linux/i386/sysdep.h?root=libc&view =markup

正如我怀疑确实有一个 syscall.S 只是 glibc 源代码是一个迷宫。

http://cvs.savannah.gnu.org/viewvc/libc/sysdeps/unix/sysv/linux/i386/syscall.S?root=libc&view=markup

所以我认为他说得对,asveikau 。

Recompile your C library after replacing sysenter by int 0x80 in syscall.s and link again.

This is not compiler generated code which means you are lucky.

The ultimate origin of the actual syscall is here, as the OP says:

http://cvs.savannah.gnu.org/viewvc/libc/sysdeps/unix/sysv/linux/i386/sysdep.h?root=libc&view=markup

And as I suspected there really was a syscall.S it's just that the glibc sources are a labyrinth.

http://cvs.savannah.gnu.org/viewvc/libc/sysdeps/unix/sysv/linux/i386/syscall.S?root=libc&view=markup

So I think he got it right, asveikau.

当爱已成负担 2024-08-26 05:41:51

你不修改 gcc;您修改 libc(或更准确地说,重新编译它)和内核。 gcc 不发出 sysenter 指令;它生成对通用 syscall(2) 接口的调用,该接口为系统调用进入和退出提供了统一的前端。

或者,您可以使用奔腾; SYSENTER 直到 PII =] 才被引入。请注意以下 KernelTrap 链接,了解 Linux 使用的有趣方法: http://kerneltrap.org/node/531

You don't modify gcc; you modify libc (or more accurately, recompile it) and the kernel. gcc doesn't emit sysenter instructions; it generates calls to the generic syscall(2) interface, which presents a unified front end to system call entry and exit.

Or, you could use a Pentium; SYSENTER wasn't introduced until PII =]. Note the following KernelTrap link for the interesting methods used by Linux: http://kerneltrap.org/node/531

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