在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这个话题的其他: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.
调用系统调用的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需要一些翻译):查找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 .