Closed bmillwood closed 4 months ago
I didn't see this issue until now. I don't think it's really necessary to have an extensive comparison documented somewhere. It's just a few points:
libtree
is about 100 - 200x faster than lddtree
:
~ $ time libtree /usr/bin/* > /dev/null 2>&1
real 0m0.255s
user 0m0.048s
sys 0m0.206s
~ $ time /usr/bin/python3 /usr/bin/lddtree /usr/bin/* > /dev/null 2>&1
real 0m47.448s
user 0m45.647s
sys 0m1.508s
libtree
is trivial to install (from source all you need is a c99 compiler, or you use prebuilt binaries); lddtree
uses bash, python, and binutils (?). For me apt install pax-utils
didn't even work because apparently you have to run it like /usr/bin/python3 /usr/bin/lddtree
because I happened to have a different python in my PATH -- not exactly user friendly.libtree
in v3, so libtree
is single-purpose: show (static) dependencies of executables and libraries in a pretty way. *And yeah, libtree was motivated partly because of that odd behavior of ldd
. It's a re-implementation of the resolver with prettier printing. That means that libtree just parses the dynamic section of ELF files. I don't think there is any risk in attempting to parse an untrusted / malformed ELF file, it will just fail.
* Bundling was removed because it's more complicated and also lddtree gets it wrong. There is another tool (I forgot which) that does a much better job at bundling dynamically opened libraries and files by tracing the executable as it runs, and it also bundles libc by copying the dynamic linker and adding wrapper scripts for executables. Even that is no guarantee for it to work. Point is I wanted to have a tool that does one thing really well, and not add features that will cause infinite maintenance.
Thanks, that reply is exactly what I wanted :)
(I'm tempted to say you should just link this issue from the README or something, but I guess I shouldn't assume that every question I have is an FAQ)
While looking for tools like this, I happened across this one and also
lddtree
, a part of pax-utils.I think it could be interesting / useful to mention that tool here too, and describe whether
libtree
differs in philosophy or purpose or functionality in any non-obvious ways. Superficially, it looks likelibtree
makes more effort to have pretty and visually clear output, whereaslddtree
appears to have more features targeted around copying a binary together with its libraries to a new location, but I haven't looked super closely at either of them.For your convenience, I provide the output of
lddtree --help
below. One other thing I notice is that thelddtree
help specifically mentions that it doesn't load or run the supplied code, just reads it. I expect this is also true oflibtree
, which has led e.g. this blog post to recommend usinglibtree
instead ofldd
. Note though that kernel.org mailing list thread "ldd: Do not recommend binutils as the safer option" suggests that running anything on an untrusted binary is risky outside of a properly sandboxed environment anyway. (In case you're curious, I found both the blog post and mailing list thread while reading this gist about the xz backdoor.)