This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: A patch for the unversioned lookup
On Wed, May 09, 2001 at 04:04:03PM -0700, H . J . Lu wrote:
> On Fri, May 04, 2001 at 09:18:23AM -0700, H . J . Lu wrote:
> > On Thu, May 03, 2001 at 11:14:02PM -0700, H . J . Lu wrote:
> > > >
> > >
> > > That is incorrect. Here is a new one. I will send a patch for a new
> > > testcase in glibc.
> > >
> > >
> >
> > Here is an update. I modified do_lookup to return version name and
> > print it out if asked. It is useful to know which vesion of an
> > unversioned symbol is bound to.
> >
> > H.J.
> > ----
> > 2001-05-04 H.J. Lu <hjl@gnu.org>
> >
> > * elf/dl-lookup.c (_dl_lookup_symbol): Get version name from
> > do_lookup and print it out if asked.
> > (_dl_lookup_symbol_skip): Likewise.
> >
> > * do-lookup.h (do_lookup): Return version name. Fix the
> > unversioned lookup against the nono-default version definition.
> >
>
> This patch is wrong. I will fix it.
>
>
The current glibc is ok. I was wrong. This patch doesn't fix any bug.
But it may help debug code.
H.J.
----
2001-05-03 H.J. Lu <hjl@gnu.org>
* elf/dl-lookup.c (_dl_lookup_symbol): Get version name from
do_lookup and print it out if asked.
(_dl_lookup_symbol_skip): Likewise.
* do-lookup.h (do_lookup): Return version name.
--- libc/elf/dl-lookup.c.version Wed May 9 16:22:07 2001
+++ libc/elf/dl-lookup.c Wed May 9 16:23:03 2001
@@ -197,13 +197,14 @@ _dl_lookup_symbol (const char *undef_nam
int protected;
int noexec = elf_machine_lookup_noexec_p (reloc_type);
int noplt = elf_machine_lookup_noplt_p (reloc_type);
+ const char *version_name = NULL;
++_dl_num_relocations;
/* Search the relevant loaded objects for a definition. */
for (scope = symbol_scope; *scope; ++scope)
- if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0, NULL,
- noexec, noplt))
+ if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0,
+ &version_name, NULL, noexec, noplt))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
@@ -242,12 +243,13 @@ _dl_lookup_symbol (const char *undef_nam
protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
- _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+ _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
(reference_name && reference_name[0]
? reference_name : (_dl_argv[0] ?: "<main program>")),
current_value.m->l_name[0]
? current_value.m->l_name : _dl_argv[0],
- protected ? "protected" : "normal", undef_name);
+ protected ? "protected" : "normal", undef_name,
+ version_name ?: "Base");
if (__builtin_expect (protected == 0, 1))
{
@@ -262,7 +264,7 @@ _dl_lookup_symbol (const char *undef_nam
for (scope = symbol_scope; *scope; ++scope)
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
- NULL, 0, 1))
+ &version_name, NULL, 0, 1))
break;
if (protected_value.s == NULL || protected_value.m == undef_map)
@@ -294,6 +296,7 @@ _dl_lookup_symbol_skip (const char *unde
struct r_scope_elem **scope;
size_t i;
int protected;
+ const char *version_name = NULL;
++_dl_num_relocations;
@@ -304,10 +307,10 @@ _dl_lookup_symbol_skip (const char *unde
if (i >= (*scope)->r_nlist
|| ! do_lookup (undef_name, hash, *ref, ¤t_value, *scope, i,
- skip_map, 0, 0))
+ &version_name, skip_map, 0, 0))
while (*++scope)
if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0,
- skip_map, 0, 0))
+ &version_name, skip_map, 0, 0))
break;
if (__builtin_expect (current_value.s == NULL, 0))
@@ -319,12 +322,13 @@ _dl_lookup_symbol_skip (const char *unde
protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
- _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+ _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
(reference_name && reference_name[0]
? reference_name : (_dl_argv[0] ?: "<main program>")),
current_value.m->l_name[0]
? current_value.m->l_name : _dl_argv[0],
- protected ? "protected" : "normal", undef_name);
+ protected ? "protected" : "normal", undef_name,
+ version_name ?: "Base");
if (__builtin_expect (protected == 0, 1))
{
@@ -339,10 +343,10 @@ _dl_lookup_symbol_skip (const char *unde
if (i >= (*scope)->r_nlist
|| !do_lookup (undef_name, hash, *ref, &protected_value, *scope, i,
- skip_map, 0, 1))
+ &version_name, skip_map, 0, 1))
while (*++scope)
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
- skip_map, 0, 1))
+ &version_name, skip_map, 0, 1))
break;
if (protected_value.s == NULL || protected_value.m == undef_map)
--- libc/elf/do-lookup.h.version Wed May 9 16:22:07 2001
+++ libc/elf/do-lookup.h Wed May 9 16:37:45 2001
@@ -22,7 +22,7 @@
# define ARG const struct r_found_version *const version,
#else
# define FCT do_lookup
-# define ARG
+# define ARG const char **version_name,
#endif
/* Inner part of the lookup functions. We return a value > 0 if we
@@ -129,10 +129,14 @@ FCT (const char *undef_name, unsigned lo
{
/* Don't accept hidden symbols. */
if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
- /* No version so far. */
- versioned_sym = sym;
+ {
+ /* No version so far. */
+ *version_name = map->l_versions[ndx].name;
+ versioned_sym = sym;
+ }
continue;
}
+ *version_name = map->l_versions[ndx].name;
}
#endif