简体   繁体   English

execve()是否设置寄存器以调用动态链接器或要执行的可执行文件?

[英]Does `execve()` set up registers to invoke dynamic linker or the executable to be executed?

Understanding the Linux Kernel says execve() calls load_binary() of each linux_binfmt object, and load_binary() 深入理解Linux内核execve()调用load_binary()每个linux_binfmt对象, load_binary()

Invokes the start_thread( ) macro to modify the values of the User Mode registers eip and esp saved on the Kernel Mode stack, so that they point to the entry point of the dynamic linker and to the top of the new User Mode stack, respectively. 调用start_thread()宏来修改保存在内核模式堆栈中的用户模式寄存器eip和esp的值,以便它们分别指向动态链接器入口和新用户模式堆栈的顶部。

mosvy wrote: mosvy写道:

What happens is that the kernel arranges for the execve system call, upon returning to user mode, to have the IP (instruction pointer) register set to point to the beginning of the _start function , and the SP (stack pointer) register set to point to the beginning of the argv + env string list, so the effect from the point of view of user mode is as if someone had called the _start function as: 发生的事情是内核在返回用户模式时安排execve系统调用,以将IP(指令指针)寄存器设置为指向_start函数的开头 ,而将SP(堆栈指针)寄存器设置为指向到argv + env字符串列表的开头,因此从用户模式的角度来看,效果就像有人调用_start函数一样:

 _start(argc, argv0, argv1, ... , NULL, env0, env1, ... NULL) 

in a calling convention where all arguments are passed on the stack. 在调用约定中,所有参数都在堆栈上传递。

By "the beginning of the _start function", did he mean the entry point of the executable to be executed ? 通过“ _start函数的开始”,他是指要执行的可执行文件的入口点吗?

Which one is correct? 哪一个是正确的? Ie does execve() set up registers to invoke dynamic linker or the executable to be executed? execve()设置寄存器以调用动态链接器或要执行的可执行文件?

_start is the entry point of an executable. _start是可执行文件的入口点。 In C you may think that main is the entry point, but this is just the point of view of the programmer. 在C语言中,您可能认为main是切入点,但这只是程序员的观点。 The compiler may insert other code in _start, to run before calling main. 编译器可以在_start中插入其他代码,以在调用main之前运行。

My interpretation is that everything described in you question, happens before calling _start (or seeming to call _start). 我的解释是,您所描述的所有问题都发生在调用_start(或似乎要调用_start)之前。

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

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