ldd doesn't work on dynamically linked binary

两盒软妹~` 提交于 2019-11-29 06:38:26

问题


I have a binary that uses a bunch of .so files.

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

bash-3.00$ ldd foo
        not a dynamic executable
bash-3.00$

readelf does show the list of shared libraries used by the binary..

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 ?


回答1:


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.




回答2:


Note that in Fedora 21, to get ldd to identify 32bit .so files, I had to install the following:

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.



来源:https://stackoverflow.com/questions/16807560/ldd-doesnt-work-on-dynamically-linked-binary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!