【发布时间】:2012-05-21 23:17:32
【问题描述】:
我想检查在 glibc 中执行系统调用的代码。我发现了类似的东西。
ENTRY (syscall)
movq %rdi, %rax /* Syscall number -> rax. */
movq %rsi, %rdi /* shift arg1 - arg5. */
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %r10
movq %r9, %r8
movq 8(%rsp),%r9 /* arg6 is on the stack. */
syscall /* Do the system call. */
cmpq $-4095, %rax /* Check %rax for error. */
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
L(pseudo_end):
ret /* Return to caller. */
现在我的问题是系统调用(在cmpq 指令之前)是否是指令?其次,如果是指令,ENTRY(syscall)是什么意思? ENTRY(我不知道 ENTRY 是什么)和指令的名称相同?其次,L(pseudo_end)是什么?
【问题讨论】:
-
是的。它与 x86 中的
int 0x80相同。 -
请注意,通常专用代码用于每个系统调用,从常量设置
%rax(保存寄存器),并跳过设置未使用的参数。
标签: c linux gcc x86-64 machine-instruction