ld如何自我加载?

时间:2018-12-14 20:31:48

标签: compilation operating-system fork ld

当我执行/lib64/ld-linux-x86-64.so.2 ./a.out时,它会加载我的a.out程序。

但是/lib64/ld-linux-x86-64.so.2首先是如何加载的?

此外,/lib64/ld-linux-x86-64.so.2在下面使用什么?叉子还是克隆...?

1 个答案:

答案 0 :(得分:0)

通常/lib64/ld-linux-x86-64.so.2是指向动态链接器的链接。
例如,它可能是指向/lib/x86_64-linux-gnu/ld-2.27.so
的链接 您可以通过ls -l命令检查链接。

您还可以尝试执行ld.so文件: 然后您将得到这样的输出-它将回答您的问题: You have invoked `ld.so', the helper program for shared library executables. This program usually lives in the file `/lib/ld.so', and special directives in executable files using ELF shared libraries tell the system's program loader to load the helper program from this file. This helper program loads the shared libraries needed by the program executable, prepares the program to run, and runs it. You may invoke this helper program directly from the command line to load and run an ELF executable file; this is like executing that file itself, but always uses this helper program from the file you specified, instead of the helper program file specified in the executable file you run. This is mostly of use for maintainers to test new versions of this helper program; chances are you did not intend to run this program.

原因请参阅手册页:
http://man7.org/linux/man-pages/man8/ld.so.8.html
也许如果您想将其真正挖掘出资源:
https://www.gnu.org/software/binutils/