Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jul 2019 19:54:27 -0700
From:      Yuri <yuri@rawbw.com>
To:        Freebsd hackers list <freebsd-hackers@FreeBSD.org>
Subject:   Question: Is there a way to get the list of all dynamic libraries needed by a given elf through API?
Message-ID:  <dfac779f-fa4f-a292-1a76-a9e7db5e024a@rawbw.com>

next in thread | raw e-mail | index | archive | help
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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?dfac779f-fa4f-a292-1a76-a9e7db5e024a>