Question: Is there a way to get the list of all dynamic libraries needed by a given elf through API?
Yuri
yuri at rawbw.com
Tue Jul 2 02:54:31 UTC 2019
I want to get the same information that 'ldd <elf-file>' returns, but
from a C/C++ program without launching external processes.
It is possible to find the list of elf's shared library dependencies
using libelf. But I couldn't find how to map library names to full
library paths.
ldd(1) sets a certain environment variable, forks and calls execl(3),
and the "ld.so magic" does the rest.
Obviously, if one needs to do the same from their own C program, forking
is a much less attractive option compared to the API way.
Is there an API to find such mappings? If no, why doesn't it exist?
Thank you,
Yuri
More information about the freebsd-hackers
mailing list