如何解释ldd程序的输出?

时间:2020-12-19 14:09:00
[root@wdctc1281 bin]#  ldd node
        linux-vdso.so.1 =>  (0x00007fffd33f2000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f70f7855000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f70f764d000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f70f7345000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f70f7043000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f70f6e2d000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f70f6c10000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f70f684f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f70f7a61000)

What does the first line and last line mean? They don't look like the normal

第一行和最后一行是什么意思?它们看起来不像正常

xxxx.so => /lib64/xxxxx.so (0xxxxxxxxxxxxxxxxxxxx)

format.

格式。

2 个解决方案

#1


9  

the first line is the VDSO. this is described in depth in the vdso(7) manpage. basically it's a shared library that's embedded in your kernel and automatically loaded whenever a new process is exec-ed. that's why there's no filesystem path on the right side -- there is none! the file only exists in the kernel memory (well, not 100% precise, but see the man page for more info).

第一行是VDSO。这在vdso(7)联机帮助页中有详细描述。基本上它是一个嵌入在你的内核中的共享库,并在执行新进程时自动加载。这就是为什么右侧没有文件系统路径 - 没有!该文件仅存在于内核内存中(嗯,不是100%精确,但请参阅手册页以获取更多信息)。

the last line is the ELF interpreter. this is described in depth in the ld.so(8) manpage. the reason it has a full path is because your program has the full path hardcoded in it. the reason it doesn't have an entry on the right side is that it's not linked against (directly) and thus no search was performed. you can check this by running:

最后一行是ELF解释器。这在ld.so(8)联机帮助页中有详细描述。它有一个完整路径的原因是因为你的程序有完整的路径硬编码。它没有右侧条目的原因是它没有(直接)链接,因此没有进行搜索。你可以通过运行来检查:

$ readelf -l node | grep interpreter
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
$ scanelf -i node
ET_EXEC /lib64/ld-linux-x86-64.so.2 node

all the other lines are libraries you've linked against. you can see those by looking at DT_NEEDED tags when you run readelf -d on the file. since those files lack full paths, the ld.so needs to perform a dynamic path search for it. that's actually what the lines are telling you: "libdl.so.2 is needed, so when i searched for it, i found it at /lib64/libdl.so.2 (and was loaded into memory at address 0x00007f70f7855000)"

所有其他行都是您链接的库。当您在文件上运行readelf -d时,可以通过查看DT_NEEDED标记来查看这些标记。由于这些文件缺少完整路径,因此ld.so需要对其执行动态路径搜索。这实际上是线条告诉你的:“需要libdl.so.2,所以当我搜索它时,我在/lib64/libdl.so.2找到它(并被加载到地址0x00007f70f7855000的内存中)”

#2


4  

ldd filename shows you the program shared libraries used by the file.

ldd filename显示文件使用的程序共享库。

libc.so.6, for example, is libc shared object version 6, which sits in /lib64 and its memory location is 0x00007f70f684f000.

例如,libc.so.6是libc共享对象版本6,它位于/ lib64中,其内存位置为0x00007f70f684f000。

The last line talks about ld-linux-x86-64.so version 2 under /lib64. This fellow will find and load shared libraries node needs. It will prep those libraries and run them. So, speaking in very crude terms, ld-linux-x86-64 is the runner. libc.so.6 and others are loaded and ldd shows the location of those shared libraries and memory locations. That is my understanding.

最后一行讨论了/ lib64下的ld-linux-x86-64.so版本2。这个人将找到并加载共享库节点需求。它将准备这些库并运行它们。因此,用非常粗略的术语来说,ld-linux-x86-64是跑步者。加载了libc.so.6和其他文件,ldd显示了这些共享库和内存位置的位置。这是我的理解。

#1


9  

the first line is the VDSO. this is described in depth in the vdso(7) manpage. basically it's a shared library that's embedded in your kernel and automatically loaded whenever a new process is exec-ed. that's why there's no filesystem path on the right side -- there is none! the file only exists in the kernel memory (well, not 100% precise, but see the man page for more info).

第一行是VDSO。这在vdso(7)联机帮助页中有详细描述。基本上它是一个嵌入在你的内核中的共享库,并在执行新进程时自动加载。这就是为什么右侧没有文件系统路径 - 没有!该文件仅存在于内核内存中(嗯,不是100%精确,但请参阅手册页以获取更多信息)。

the last line is the ELF interpreter. this is described in depth in the ld.so(8) manpage. the reason it has a full path is because your program has the full path hardcoded in it. the reason it doesn't have an entry on the right side is that it's not linked against (directly) and thus no search was performed. you can check this by running:

最后一行是ELF解释器。这在ld.so(8)联机帮助页中有详细描述。它有一个完整路径的原因是因为你的程序有完整的路径硬编码。它没有右侧条目的原因是它没有(直接)链接,因此没有进行搜索。你可以通过运行来检查:

$ readelf -l node | grep interpreter
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
$ scanelf -i node
ET_EXEC /lib64/ld-linux-x86-64.so.2 node

all the other lines are libraries you've linked against. you can see those by looking at DT_NEEDED tags when you run readelf -d on the file. since those files lack full paths, the ld.so needs to perform a dynamic path search for it. that's actually what the lines are telling you: "libdl.so.2 is needed, so when i searched for it, i found it at /lib64/libdl.so.2 (and was loaded into memory at address 0x00007f70f7855000)"

所有其他行都是您链接的库。当您在文件上运行readelf -d时,可以通过查看DT_NEEDED标记来查看这些标记。由于这些文件缺少完整路径,因此ld.so需要对其执行动态路径搜索。这实际上是线条告诉你的:“需要libdl.so.2,所以当我搜索它时,我在/lib64/libdl.so.2找到它(并被加载到地址0x00007f70f7855000的内存中)”

#2


4  

ldd filename shows you the program shared libraries used by the file.

ldd filename显示文件使用的程序共享库。

libc.so.6, for example, is libc shared object version 6, which sits in /lib64 and its memory location is 0x00007f70f684f000.

例如,libc.so.6是libc共享对象版本6,它位于/ lib64中,其内存位置为0x00007f70f684f000。

The last line talks about ld-linux-x86-64.so version 2 under /lib64. This fellow will find and load shared libraries node needs. It will prep those libraries and run them. So, speaking in very crude terms, ld-linux-x86-64 is the runner. libc.so.6 and others are loaded and ldd shows the location of those shared libraries and memory locations. That is my understanding.

最后一行讨论了/ lib64下的ld-linux-x86-64.so版本2。这个人将找到并加载共享库节点需求。它将准备这些库并运行它们。因此,用非常粗略的术语来说,ld-linux-x86-64是跑步者。加载了libc.so.6和其他文件,ldd显示了这些共享库和内存位置的位置。这是我的理解。