在32位的Linux系统调用或SYSENTER? [英] Syscall or sysenter on 32 bits Linux?

查看:536
本文介绍了在32位的Linux系统调用或SYSENTER?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于MS-DOS,我知道使用中断系统调用。在旧报纸,我看到了参考 INT 80H 来调用Linux系统的功能。由于相当长的时间了,我知道 INT 80H 赞成系统调用指令pcated德$ P $。但我不能得到它我的32位机器上工作。

Since MS‑DOS, I know system invocation using interrupts. In old papers, I saw reference to int 80h to invoke system functions on Linux. Since a rather long time now, I know int 80h is deprecated in favour of the syscall instruction. But I can't get it working on my 32 bits machine.

系统调用指令只有64位平台上使用?没有32位的Linux利用系统调用

Is the syscall instruction to be used on 64 bits platform only? Doesn't 32 bits Linux makes use of syscall?

在我的32位的Linux(Ubuntu的precise),这个程序有核心转储终止:

On my 32 bits Linux (Ubuntu Precise), this program terminates with a core dump:

global _start

_start:
        mov     eax, 4                ; 4 is write
        mov     ebx, 1                ; 1 is stdout
        mov     ecx, message          ; address of string
        mov     edx, length           ; number of bytes
        syscall

        mov     eax, 1                ; 1 is exit
        xor     ebx, ebx              ; return code 0
        syscall

message:
        db  10,"Hello, World",10,10
length  equ $ - message

我和 SYSENTER 尝试,而不是系统调用,但它崩溃了同样的方式。

I've tried with sysenter instead of syscall, but it crashes the same way.

推荐答案

在一些网络搜索,我要降落的StackOverflow这个话题的其他:<一href=\"http://stackoverflow.com/questions/13595033/linux-invoke-a-system-call-via-sysenter-tutorial\">Linux通过调用SYSENTER教程系统调用。它说,调用系统推荐的方式,既不用 INT 80H 也不系统调用也不 SYSENTER ,但 linux-gate.so

After some web searching, I landed to this other topic on StackOverflow: Linux invoke a system call via sysenter tutorial. It says the recommended way to invoke the system, is neither using int 80h nor syscall nor sysenter, but linux-gate.so.

不过仍对崩溃和核心转储的问题。我的猜测是最后,虽然可以系统调用 SYSENTER 指令作为CPU的指令,可能是Linux内核只没有设置正确这个切入点,当它决定它不是在一个给定的硬件平台,真正有用的。

Still remains the question about the crash and core‑dump. My guess is finally that although either syscall or sysenter instructions are available as a CPU instruction, may be the Linux kernel just does not set‑up properly this "entry point" when it decide it's not really useful on a given hardware platform.

好像在32位平台上, SYSENTER 系统调用 可以同时可用,它总是可用,仅在64位平台。

Seems on 32 bits platform, sysenter or syscall may be available, while it's always available, only on 64 bits platform.

虽然我觉得这个回答我的问题,我还是欢迎更多的材料,像我上述猜测的权威参考。

Although I feel this answer my question, I still welcome more material, like an authoritative reference for my above guess.

- 更新 -

至少,我能找到这里面确认以上。这仍然不是一个权威的参考,但似乎很可信,我相信。

At least, I could find this which confirm the above. That's still not an authoritative reference but seems trustable enough I believe.

什么是Linux-gate.so.1?,说:

调用系统调用的preferred的方法是
  按内核在启动时确定,然后
  显然这个盒子采用SYSENTER。

The preferred way of invoking a system call is determined by the kernel at boot time, and evidently this box uses sysenter.

另外,从其他来源,样品FASM汇编源,通过 linux-gate.so 来调用系统功能(如果你使用NASM需要一些翻译):< A HREF =HTTP://shaurz.word$p$pss.com/2008/06/02/finding-linux-gateso1-in-assembly/相对=nofollow>查找Linux的gate.so.1在大会。

Also, from another source, a sample FASM assembly source (needs some translations if you use NASM), to call a system function via linux-gate.so: Finding linux-gate.so.1 in Assembly .

这篇关于在32位的Linux系统调用或SYSENTER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆