I have dlopen()
'ed a library, and I want to invert back from the handle it passes to me to the full pathname of shared library. On Linux and friends, I know that I can use dlinfo()
to get the linkmap and iterate through those structures, but I can't seem to find an analogue on OSX. The closest thing I can do is to either:
Use
dyld_image_count()
anddyld_get_image_name()
, iterate over all the currently opened libraries and hope I can guess which one corresponds to my handleSomehow find a symbol that lives inside of the handle I have, and pass that to
dladdr()
.
If I have apriori knowledge as to a symbol name inside of the library I just opened, I can dlsym()
that and then use dladdr()
. That works fine. But in the general case where I have no idea what is inside this shared library, I would need to be able to enumerate symbols to do that, which I don't know how to do either.
So any tips on how to lookup the pathname of a library from its dlopen
handle would be very much appreciated. Thanks!