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 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.
--- libc/elf/dl-lookup.c.nodef Tue Feb 27 22:22:10 2001
+++ libc/elf/dl-lookup.c Fri May 4 09:10:30 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.nodef Tue Feb 27 22:22:10 2001
+++ libc/elf/do-lookup.h Fri May 4 09:05:52 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
@@ -125,13 +125,25 @@ FCT (const char *undef_name, unsigned lo
if (verstab != NULL)
{
ElfW(Half) ndx = verstab[symidx] & 0x7fff;
- if (ndx > 2) /* map->l_versions[ndx].hash != 0) */
+ if (ndx > 1) /* map->l_versions[ndx].hash != 0) */
{
- /* Don't accept hidden symbols. */
- if ((verstab[symidx] & 0x8000) == 0 && num_versions++ == 0)
- /* No version so far. */
- versioned_sym = sym;
- continue;
+ if ((verstab[symidx] & 0x8000) == 0)
+ {
+ /* We found the default version. */
+ *version_name = map->l_versions[ndx].name;
+ goto found_it;
+ }
+ else
+ {
+ /* We found a hidden symbol. Only one version is
+ allowed. */
+ if (num_versions++ == 0)
+ {
+ versioned_sym = sym;
+ *version_name = map->l_versions[ndx].name;
+ }
+ continue;
+ }
}
}
#endif