LDD(1)
๐ ldd โ list dynamic object dependencies
okay bestie, welcome to ldd(1), from the General Commands Manual section. this is the tool that tells you what your program is emotionally dependent on (it's shared libraries, the dependency is shared libraries ๐). let's get into it.
โจ SYNOPSIS โจ
ldd [-a] [-f format [-f format]] program ...
that's it. that's the whole vibe. short, iconic, to the point. ๐
๐ธ DESCRIPTION ๐ธ
so like, ldd displays all the shared objects that are needed to run the given program, or to load the given shared object. that's its whole job and it does it beautifully. ๐
and here's the thing that makes it different from nm(1) โ ldd gives you the โindirectโ dependencies too. like, the ones that come from needed shared objects that themselves depend on yet other shared objects. it's giving "friend of a friend of a friend", it's giving six degrees of separation but make it ELF. no cap, it goes all the way down. ๐ฆ
now, the -f situation. you can give zero, one, or two -f options, and the argument is a format string that gets passed to rtld(1), which lets you customize ldd's output however you want. here's the mapping, and yes you need to know it:
- if one
-fis given โ it setsLD_TRACE_LOADED_OBJECTS_FMT1 - if two are given โ they set
LD_TRACE_LOADED_OBJECTS_FMT1andLD_TRACE_LOADED_OBJECTS_FMT2, respectively
see rtld(1) for all the details, including a list of the recognized conversion characters. ๐
and then:
-aโ displays the list of all objects that are needed by each loaded object. like, not just the top-level ones, the whole entire tree. main character energy for real. ๐
๐ง IMPLEMENTATION NOTES ๐ง
heads up bestie, this one's a little unhinged ๐
ldd lists the dependencies of an executable by setting rtld(1) environment variables and running the executable in a child process. yeah. it literally runs your program to find out what your program needs. that's the technique.
and because of that: if the executable is corrupt or invalid, ldd may therefore fail without providing any diagnostic error messages. so if it just... does nothing, or dies silently, don't come for it โ that's the design. ๐ญ it's not ghosting you on purpose, it's just how the child process thing works.
๐ EXAMPLES ๐
here's a shell pipeline example that uses the -f option. it prints a report of all ELF binaries in the current directory which link against the old libc.so.6. obsessed with this actually. ๐ฅ
find . -type f | xargs file -F ' ' | grep 'ELF.*dynamically' | cut
-f1 -d' ' | xargs ldd -f '%A %o\n' | grep -F libc.so.6
look at that pipeline go. find, file, grep, cut, ldd, grep again โ team effort, everyone ate. ๐
๐ซถ SEE ALSO ๐ซถ
go read rtld(1) though, seriously, it's got the conversion character lore you need for -f. iykyk. โจ
โญ HISTORY โญ
a ldd utility first appeared in SunOS 4.0, and it appeared in its current form in FreeBSD 1.1. glow-up of the century tbh. ๐
<div align="center">๐ธ that's the whole page, bestie ๐ธ</div>
this little gem comes to you from Debian, dated March 21, 2023 โ mwah, ily, go check your dependencies ๐๐
๐ฆ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms