A tool for displaying the dependency tree of ELF-formatted binaries.
- CMake 3.10 or later
- C++20 compatible compiler (GCC, Clang, etc.)
- libelf development library
cd /workspaces/ddtree
mkdir -p build
cd build
cmake ..
makeThe compiled binary will be located at build/ddtree.
- libelf library
On Debian/Ubuntu systems, you can install it using:
sudo apt install libelf1For building from source, you also need the development headers:
sudo apt install libelf-devddtree [OPTION...] <binary_path>| Option | Description |
|---|---|
-h, --help |
Print usage information |
-v, --version |
Print version information |
--librarypath <path> |
Colon-separated list of directories to search for libraries (default: "") |
--max-depth <depth> |
Maximum depth of the dependency tree, 0 means unlimited (default: 0) |
--use-ldconfig=<true/false> |
Whether to parse ld.so.conf for additional library paths (default: true) |
--ldconfig-path <path> |
Path to ld.so.conf (default: /etc/ld.so.conf) |
--resolve-symlinks=<true/false> |
Resolve symlinks when displaying library paths |
--output-format=<format> |
Output format: tree (default), list, or set |
$ ddtree /bin/lsOutput:
ls (/bin/ls)
+- libselinux.so.1 (/usr/lib/x86_64-linux-gnu/libselinux.so.1)
| +- libpcre2-8.so.0 (/usr/lib/x86_64-linux-gnu/libpcre2-8.so.0)
| | `- libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
| | `- ld-linux-x86-64.so.2 (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
| +- libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
| `- ld-linux-x86-64.so.2 (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
`- libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
$ ddtree --max-depth 2 /bin/lsOutput:
ls (/bin/ls)
+- libselinux.so.1 (/usr/lib/x86_64-linux-gnu/libselinux.so.1)
| +- libpcre2-8.so.0 (/usr/lib/x86_64-linux-gnu/libpcre2-8.so.0)
| +- libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
| `- ld-linux-x86-64.so.2 (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
`- libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
$ ddtree --output-format list /bin/bashOutput (note that libc.so.6 is listed multiple times):
bash (/bin/bash)
libtinfo.so.6 (/usr/lib/x86_64-linux-gnu/libtinfo.so.6)
libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
ld-linux-x86-64.so.2 (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
$ ddtree --output-format set /bin/bashOutput (duplicate libc.so.6 is removed):
bash (/bin/bash)
libtinfo.so.6 (/usr/lib/x86_64-linux-gnu/libtinfo.so.6)
libc.so.6 (/usr/lib/x86_64-linux-gnu/libc.so.6)
ld-linux-x86-64.so.2 (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
$ ddtree --librarypath /usr/local/lib:/opt/lib /path/to/binary$ ddtree --resolve-symlinks=true /path/to/binary