[Toybox] Implementing ldd.
rob at landley.net
Thu Jan 13 11:16:21 PST 2022
In theory ldd is a subset of readelf, so we've already got most of the code. In
practice, the OTHER thing it does is try to dlopen() each library so it can get
a path and address out of /proc/self/maps.
The problem is if you're statically linked, bionic links in a dlopen() stub
return ing NULL. Which makes sense because you couldn't USE the dlopen() result
because of the old "now we have two heap pointers and if you malloc() from the
dynamic one and free() into the static one and you've cross-linked your heaps"
problem, but all I'm trying to do is get the path to the file and the preferred
Not entirely sure the right thing to do here. This is one of those "almost
entirely trivial, except for the land mine" things. I guess I can just print the
library name from the ELF info but not the => part when dlopen() returns null?
More information about the Toybox