gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 10:03:09 25 4
gpt4 key购买 nike

了解 Linux 内核execve() 调用每个 linux_binfmt 对象的 load_binary(),并且 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.

mosvy wrote:

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:

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

in a calling convention where all arguments are passed on the stack.

_start 函数的开头”是指要执行的可执行文件的入口点吗?

哪个是正确的? IE。 execve() 是否设置寄存器来调用动态链接器或要执行的可执行文件?

最佳答案

_start 是可执行文件的入口点。在 C 中你可能认为 main 是入口点,但这只是程序员的观点。编译器可能会在 _start 中插入其他代码,以便在调用 main 之前运行。

我的解释是,您所质疑的一切都发生在调用 _start(或看似调用 _start)之前。

关于linux - `execve()` 是否设置寄存器来调用动态链接器或要执行的可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54518805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com