This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dlinfo for the calling shared library


* Carlos O'Donell:

> 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?

I think we call _dl_name_match_p, and it starts like this:

| /* Test whether given NAME matches any of the names of the given object.  */
| int
| _dl_name_match_p (const char *name, const struct link_map *map)
| {
|   if (strcmp (name, map->l_name) == 0)
|     return 1;

So we should recognize this and treat the object as equivalent to an
already-loaded object.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]