Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine direct shared object dependencies of a Linux binary?

Tags:

linux

elf

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.

like image 741
Free Wildebeest Avatar asked Jun 05 '11 11:06

Free Wildebeest


People also ask

How do you find shared library dependencies?

Steps to find shared library dependency in Linux:Launch your preferred terminal application. Get absolute path of the program you want to check. Print shared object dependencies using ldd. Print verbose dependency info using ldd.

How do I find shared libraries in Linux?

In order to view all the shared libraries used by an executable we make use of the Linux command utility known as ldd. We can easily locate the shared libraries on a Linux machine, as they usually start with lib* prefix.

How use ldd command in Linux?

Basic usage of ldd is fairly simple - just run the 'ldd' command along with an executable or shared object file name as input. So you can see all shared library dependencies have been produced in output.


1 Answers

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: [libssl.so.1.0.0]  0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]  0x000000000000000c (INIT)               0x400520  0x000000000000000d (FINI)               0x400758  ... 
like image 158
Mat Avatar answered Sep 23 '22 23:09

Mat