dlinfo for the calling shared library

Carlos O'Donell carlos@redhat.com
Wed Jul 10 16:21:00 GMT 2019


On 7/10/19 10:15 AM, Florian Weimer wrote:
> * Zack Weinberg:
> 
>> Do we have a supported way to make dlinfo() queries for the shared
>> library from which the call originates, without the library having to
>> know its own soname?  (If it knows its own soname, it can call dlopen
>> on itself, but I'm looking into a scenario where that information is
>> not available.)
> 
> dladdr1 with RTLD_DL_LINKMAP returns the link map, which has a public
> l_name member in <link.h>.  If you do not want to use the handle/link
> map equivalence, you could dlopen l_name, and that should give you back
> the same handle in an official way.

What happens if l_name is different on disk now and has a distinct SONAME?
Doesn't this introduce a race condition?

If you open by SONAME then you should always get the already loaded in-memory
object which might have changed from the on-disk contents.

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list