Zet - How do I find the linked libraries needed for a elf binary?

How do I find the linked libraries needed for a elf binary?

You can use ldd.

Here’s a quick summary of how to use ldd to see the linked libraries for a Linux binary:

What is ldd?

ldd (List Dynamic Dependencies) is a command-line utility that shows the shared libraries a program depends on. It displays the paths and versions of these libraries.

Basic Syntax:

ldd <path-to-binary>

Example:

If you want to see the linked libraries for a binary like /bin/ls, run:

ldd /bin/ls

The output will show each linked library, its path, and its address in memory, something like this:

linux-vdso.so.1 (0x00007ffcd65d2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3c4b2b9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3c4b6c3000)

Common Use Cases:

  • Troubleshooting: Identify missing dependencies for a program.
  • Debugging: See which versions of libraries are being used.
  • Deployment: Ensure the correct libraries are present on the target system.

Notes:

  • ldd is not safe to use on untrusted executables since it directly loads the binary to resolve dependencies. To check without running the binary, use objdump -p or readelf -d as safer alternatives.

#linux #cLibraries #linking