ld-linux.so.2 和 linux-gate.so.1 是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19981862/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are ld-linux.so.2 and linux-gate.so.1?
提问by e271p314
When I run ldd program
I get an output of the form
当我运行时,ldd program
我得到了表单的输出
linux-gate.so.1 => (0xb77ae000)
libstdc++.so.6 => /lib/libstdc++.so.6 (0xb76bc000)
libm.so.6 => /lib/libm.so.6 (0xb7691000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7674000)
libc.so.6 => /lib/libc.so.6 (0xb74c2000)
/lib/ld-linux.so.2 (0xb77af000)
Can you explain the output and the reason linux-gate.so.1
and ld-linux.so.2
show differently than other entries? What are their roles?
你能解释输出和原因,linux-gate.so.1
并ld-linux.so.2
与其他条目不同吗?他们的角色是什么?
采纳答案by Petesh
I hope that you're not asking about the main entries, which are stating that for the requested library libm.so.6
it was found in the file /lib/libm.so.6
, for example, but are asking about the two outliers.
我希望您不是在询问主要条目,例如,这些条目表明对于请求的库,libm.so.6
它是在文件中找到的/lib/libm.so.6
,而是询问两个异常值。
Why are they displayed differently? for linux-gate.so.1
it's because it's not actually a file on-disk - it's exposed by the kernel as the mechanism for making system calls. For /lib/ld-linux.so.2
it's because this is the programinterpreter that is used for actually running the application.
为什么它们的显示方式不同?为linux-gate.so.1
这是因为它实际上不是在磁盘上的一个文件-它是由内核的机制来进行系统调用暴露。对于/lib/ld-linux.so.2
它,因为这是程序被用于实际运行的应用程序的解释。
There's a pretty good blog entrydescribing the linux-gate.so, and it explains it pretty well.
有一个很好的博客条目描述了 linux-gate.so,它很好地解释了它。
For /lib/ld-linux.so.2
, you have to understand a little of what happens when you launch an ELF binary. The short answer is that the kernel handler for these types of binaries uses this file for the purposes of launching the application.
对于/lib/ld-linux.so.2
,您必须了解一些启动 ELF 二进制文件时会发生什么。简短的回答是这些类型的二进制文件的内核处理程序使用这个文件来启动应用程序。
The main purpose of this program is to map the binary into memory, load any referenced libraries in the program (e.g. the libm.so.6 previously mentioned), and then hand off control to the starting address of the binary being executed.
该程序的主要目的是将二进制文件映射到内存中,加载程序中任何引用的库(例如前面提到的 libm.so.6),然后将控制权移交给正在执行的二进制文件的起始地址。
This program is defined as part of the structure of the ELF file, in the INTERP
section of the program header. For 32bit linux binaries, this is the typical name of the 32bit interpreter. For 64bit binaries, you'll find it is typically called ld-linux-x86_64.so.2
(for 64bit x86 platforms).
该程序被定义为 ELF 文件结构的INTERP
一部分,位于程序头的部分。对于 32 位 linux 二进制文件,这是 32 位解释器的典型名称。对于 64 位二进制文件,您会发现它通常被称为ld-linux-x86_64.so.2
(对于 64 位 x86 平台)。
You can determine this information yourself using readelf -l
, and the INTERP section:
您可以使用readelf -l
和 INTERP 部分自己确定此信息:
INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238
0x000000000000001c 0x000000000000001c R 1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]