什么是ld-linux.so.2和linux-gate.so.1? [英] What are ld-linux.so.2 and linux-gate.so.1?

查看:295
本文介绍了什么是ld-linux.so.2和linux-gate.so.1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行ldd program时,我得到以下形式的输出

When I run ldd program I get an output of the form

    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)

您能解释一下输出以及linux-gate.so.1ld-linux.so.2与其他条目显示不同的原因吗?他们的作用是什么?

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?

推荐答案

我希望您不要询问主要条目,这些条目说明对于请求的库libm.so.6,它是在文件/lib/libm.so.6中找到的,例如,但询问的是两个异常值.

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.

为什么它们显示的不同?对于linux-gate.so.1,是因为它实际上不是磁盘上的文件-内核将其公开为进行系统调用的机制.对于/lib/ld-linux.so.2,是因为这是用于实际运行应用程序的 program 解释器.

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 program interpreter that is used for actually running the application.

有一个相当不错的

There's a pretty good blog entry describing the linux-gate.so, and it explains it pretty well.

对于/lib/ld-linux.so.2,您必须了解启动ELF二进制文件时会发生的一些情况.简短的答案是,这些类型的二进制文件的内核处理程序使用此文件来启动应用程序.

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.

该程序的主要目的是将二进制文件映射到内存中,在程序中加载任何引用的库(例如,前面提到的libm.so.6),然后将控制权移交给正在执行的二进制文件的起始地址

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.

在程序头文件的INTERP部分中,该程序被定义为ELF文件结构的一部分.对于32位linux二进制文件,这是32位解释器的典型名称.对于64位二进制文​​件,您会发现它通常称为ld-linux-x86_64.so.2(对于64位x86平台).

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).

您可以使用readelf -l和INTERP部分自己确定此信息:

You can determine this information yourself using readelf -l, and the INTERP section:

INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
               0x000000000000001c 0x000000000000001c  R      1
    [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

这篇关于什么是ld-linux.so.2和linux-gate.so.1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆