LDD(1)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.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 -f is given โ†’ it sets LD_TRACE_LOADED_OBJECTS_FMT1
  • if two are given โ†’ they set LD_TRACE_LOADED_OBJECTS_FMT1 and LD_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