How does execve call dynamic linker/loader (ld-linux.so.2)

只愿长相守 提交于 2019-11-28 00:12:22

My guess is that the linker/loader (/lib64/ld-linux.so.2) call is part of execve.

This is somewhat correct.

The kernel first looks at the main executable segments, and mmaps them into the new "process shell".

When it discovers that the executable has PT_INTERP segment, it mmaps that file's segments as well, and passes control to it.

Thus, upon "return" from execve() into user-mode, the interpreter (usually /lib64/ld-linux-x86-64.so.2 on Linux/x86_64) is already mapped in and running. It is then the job of that interpreter to relocate itself, to mmap the rest of required shared libraries, initialize them, and finally transfer control to the main executable.

If you want more details, start here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!