简体   繁体   English

C 系统调用的 Linux 64 汇编等效项是什么?

[英]What is the Linux 64 Assembly Equivalent for C's system call?

(Question edited, thanks to @fuz) (问题已编辑,感谢@fuz)

What is the Linux 64 Assembly Equivalent for C's system call? C 系统调用的 Linux 64 汇编等效项是什么?

I want to write assembly that essentially has the same function as calling the CLI in C, such as system("ls -l") .我想编写与在 C 中调用 CLI 基本具有相同 function 的程序集,例如system("ls -l")

The code I want to reproduce has essentially the same function as the following C:我要重现的代码与以下 C 具有基本相同的 function:

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

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

    exit(0);
}

The system libc function is not a kernel system call. system libc function不是kernel 系统调用。 That's why its man page is system(3) not system(2) .这就是为什么它的手册页是system(3)而不是system(2)

It's implemented on top of fork(2) + execve(2), and the waitpid(2) system calls.它是在 fork(2) + execve(2) 和waitpid(2)系统调用之上实现的。 In fact that's the first thing the system(3) man page says, Go read it.事实上,这是system(3)手册页所说的第一件事,Go 阅读了它。 just like you should read the Linux man page for any actual system call or library function you want to know about.就像您应该阅读 Linux 手册页以了解您想了解的任何实际系统调用或库 function。

Use strace on a program that calls it, or single-step into it with GDB, or read the glibc source code.在调用它的程序上使用strace ,或者使用 GDB 单步进入它,或者阅读 glibc 源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM