This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Compatibility symlink from old dynamic loader name to new dynamicloader name doesn't work.
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Roland McGrath <roland at hack dot frob dot com>
- Cc: "Carlos O'Donell" <carlos_odonell at mentor dot com>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Wed, 24 Oct 2012 15:16:32 -0400
- Subject: Re: Compatibility symlink from old dynamic loader name to new dynamicloader name doesn't work.
- References: <5087FAD8.5000605@mentor.com><20121024171655.3969E2C09A@topped-with-meat.com>
On Wed, Oct 24, 2012 at 1:16 PM, Roland McGrath <roland@hack.frob.com> wrote:
> The patch is clearly a dismal kludge that would never be acceptable.
>
> I don't understand why the stat-based logic at the top of
> _dl_map_object_from_fd is not handling this case already.
There are a couple of filename checks in _dl_map_object, but the files
names aren't the same name:
~~~ e.g.
soname = ((const char *) D_PTR (l, l_info[DT_STRTAB])
+ l->l_info[DT_SONAME]->d_un.d_val);
if (strcmp (name, soname) != 0)
continue;
~~~
Then in _dl_map_object_from_fd we check only that the inodes are the
same, which isn't true for a symlink.
~~~ e.g.
/* Look again to see if the real name matched another already loaded. */
for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
if (l->l_removed == 0 && l->l_ino == st.st_ino && l->l_dev == st.st_dev)
...
#ifdef SHARED
/* When loading into a namespace other than the base one we must
avoid loading ld.so since there can only be one copy. Ever. */
if (__builtin_expect (nsid != LM_ID_BASE, 0)
&& ((st.st_ino == GL(dl_rtld_map).l_ino
&& st.st_dev == GL(dl_rtld_map).l_dev)
|| _dl_name_match_p (name, &GL(dl_rtld_map))))
...
~~~
The code probably works for a hardlink.
It seems rather sloppy that your choice of hardlink vs. symlink can
break things.
>> In summary:
>> - To support compatibility symlinks from old dynamic loader names to new
>> dynamic loader names will require refactoring _dl_map_object_from_fd to
>> actually detect if two DSOs are the same.
>
> That's exactly what it already does.
Unfortunately I don't see how without following the symlink, which it
doesn't do.
Cheers,
Carlos.