Linux ldd 不适用于动态链接的二进制文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16807560/
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
ldd doesn't work on dynamically linked binary
提问by Manohar
I have a binary that uses a bunch of .so files.
我有一个使用一堆 .so 文件的二进制文件。
bash-3.00$ file foo
foo: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.21, dynamically linked (uses shared libs), not stripped
But if I run ldd on this file, its not able to pick up the .so files the binary is dependent on.'
但是如果我在这个文件上运行 ldd ,它就无法获取二进制文件所依赖的 .so 文件。
bash-3.00$ ldd foo
not a dynamic executable
bash-3.00$
readelf does show the list of shared libraries used by the binary..
readelf 确实显示了二进制文件使用的共享库列表。
bash-3.00$ readelf -d foo
Dynamic segment at offset 0x17c810 contains 70 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libdl.so.2]
Why is ldd not able to pick up the library dependencies in this case ?
在这种情况下,为什么 ldd 无法获取库依赖项?
回答by jmajnert
Like one of the comment says - you tried using ldd on 64 bit system to inspect a 32-bit ELF object. ldd uses the standard dynamic linker to trace the dependencies, so if your platform doesn't have the linker required by the ELF object being inspected, ldd fails. Readelf and objdump are more robust in these situations.
就像其中一条评论所说 - 您尝试在 64 位系统上使用 ldd 来检查 32 位 ELF 对象。ldd 使用标准动态链接器来跟踪依赖关系,因此如果您的平台没有被检查的 ELF 对象所需的链接器,ldd 将失败。Readelf 和 objdump 在这些情况下更加健壮。
回答by eresonance
Note that in Fedora 21, to get ldd to identify 32bit .so files, I had to install the following:
请注意,在 Fedora 21 中,为了让 ldd 识别 32 位 .so 文件,我必须安装以下内容:
sudo yum install glibc.i686 libgcc.i686 libstdc++.i686 glibc-devel.i686
I'm not sure which one of those fixed the "not a dynamic executable" error I was seeing in ldd.
我不确定其中哪一个修复了我在 ldd 中看到的“不是动态可执行文件”错误。