Free Wildebeest Free Wildebeest - 1 year ago 122
Linux Question

How do I find the direct shared object dependencies of a Linux (ELF) binary?

How can I easily find out the direct shared object dependencies of a Linux binary (in ELF format)?

I'm aware of the ldd tool, but that appears to output all dependencies of a binary, including the dependencies of any shared objects that binary is dependent on.

Mat Mat
Answer Source

You can use readelf to explore the ELF headers. readelf -d will list the direct dependencies as NEEDED sections.

 $ readelf -d elfbin

Dynamic section at offset 0xe30 contains 22 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: []
 0x0000000000000001 (NEEDED)             Shared library: []
 0x000000000000000c (INIT)               0x400520
 0x000000000000000d (FINI)               0x400758
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download