问题描述
我怎样才能看到execve函数的实现(在x86_64 Linux下),它在未分配的库中?我想要这个,是因为我想知道如何使用汇编器来调用外部程序,而无需调用execve.我知道有一个名为execve的系统调用,但是我不知道如何使用它.
How can I see the implementation of function execve (under x86_64 Linux), it is in the library unistd?I want this because I want to know how can I call an external program using assembler, without calling execve.I know that there is a syscall named execve, but I don't know how can I use it.
如何将char *类型和char * []类型的变量放入寄存器?
How can I put a variable of type char * and type char * [] into registers ?
推荐答案
仅查看内核源代码(更具体地说:arch/YOUR-ARCH/kernel/head * .S)以了解体系结构上的系统调用约定(系统调用号和参数的寄存器和/或堆栈).
Just take a look at the kernel sources (more specifically: arch/YOUR-ARCH/kernel/head*.S) for the system call convention on your architecture (registers and/or stack for the syscall number and the parameters).
例如,在ARM上,您将 __ NR_execve
加载到r7,将参数加载到r0,r1,r2,然后使用 swi 0
.您可能会对对ARM EABI系统调用的这种移植感兴趣,以了解更多详细信息.
On ARM, for example, you would load __NR_execve
into r7, load the arguments into r0, r1, r2 and then use swi 0
. You might be interested in this explantion of ARM EABI syscalls for more details.
这篇关于函数execve的实现(unistd.h)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!