C的系统调用的Linux 64系统调用号是什么?

问题描述 投票:-1回答:1

C的系统调用的Linux 64系统调用号是什么?

我想编写实质上具有与在C中调用CLI相同的功能的程序集,例如system("ls -l"),并且需要知道程序集rax系统调用号。

我想重现的代码与以下C:具有基本上相同的功能:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   system("ls -l");

    exit(0);
}

但是它是程序集,类似于以下内容(但是我正在寻找的系统代码表示为X

section .data
    clitext: db "ls -l",0
    clitextlength: equ $-clitext
section .text
    global _start

_start:
    mov rax, X
    mov rsi, clitext    
    mov rdx, clitextlength
    syscall

    mov rax, 60
    mov rdi, 0
    syscall

完整的系统调用表的示例为here

c linux assembly x86-64 system-calls
1个回答
1
投票

system libc函数是不是内核系统调用。因此,其手册页是system(3)而不是system(3)

它在fork(2)+ execve(2)之上实现,并且system(2)系统调用。实际上,这是waitpid(2)手册页说的第一句话!继续阅读它,就像您应该阅读Linux手册页以了解任何您想了解的实际系统调用或库函数一样。

在调用它的程序中使用system(3),或者与GDB一起使用它,或者阅读glibc源代码。

© www.soinside.com 2019 - 2024. All rights reserved.