Update.
* elf/dl-sym.c (_dl_sym): Use exact check for caller PC in range of DSO address space. (_dl_vsym): Likewise.
This commit is contained in:
parent
0d0db00c02
commit
f92338be6e
|
@ -1,5 +1,9 @@
|
||||||
2000-10-23 Ulrich Drepper <drepper@redhat.com>
|
2000-10-23 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-sym.c (_dl_sym): Use exact check for caller PC in range
|
||||||
|
of DSO address space.
|
||||||
|
(_dl_vsym): Likewise.
|
||||||
|
|
||||||
* elf/dl-sym.c (_dl_sym): For RTLD_DEFAULT, search in objects
|
* elf/dl-sym.c (_dl_sym): For RTLD_DEFAULT, search in objects
|
||||||
global scope if we can determine it.
|
global scope if we can determine it.
|
||||||
|
|
||||||
|
|
60
elf/dl-sym.c
60
elf/dl-sym.c
|
@ -35,20 +35,23 @@ _dl_sym (void *handle, const char *name, void *who)
|
||||||
struct link_map *match;
|
struct link_map *match;
|
||||||
struct link_map *l;
|
struct link_map *l;
|
||||||
|
|
||||||
|
/* If the address is not recognized the call comes from the main
|
||||||
|
program (we hope). */
|
||||||
|
match = _dl_loaded;
|
||||||
|
|
||||||
/* Find the highest-addressed object that CALLER is not below. */
|
/* Find the highest-addressed object that CALLER is not below. */
|
||||||
match = NULL;
|
for (l = _dl_loaded; l != NULL; l = l->l_next)
|
||||||
for (l = _dl_loaded; l; l = l->l_next)
|
if (l->l_addr != 0 && caller >= l->l_map_start && caller < l->l_map_end)
|
||||||
if (caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
|
{
|
||||||
match = l;
|
/* There must be exactly one DSO for the range of the virtual
|
||||||
|
memory. Otherwise something is really broken. */
|
||||||
|
match = l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (handle == RTLD_DEFAULT)
|
if (handle == RTLD_DEFAULT)
|
||||||
{
|
/* Search the global scope as seen in the caller object. */
|
||||||
/* Search the global scope as seen in the caller object. */
|
result = _dl_lookup_symbol (name, match, &ref, match->l_scope, 0, 0);
|
||||||
if (match != NULL)
|
|
||||||
result = _dl_lookup_symbol (name, match, &ref, match->l_scope, 0, 0);
|
|
||||||
else
|
|
||||||
result = _dl_lookup_symbol (name, match, &ref, _dl_global_scope, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (handle != RTLD_NEXT)
|
if (handle != RTLD_NEXT)
|
||||||
|
@ -56,22 +59,17 @@ _dl_sym (void *handle, const char *name, void *who)
|
||||||
/* Search the scope of the given object. */
|
/* Search the scope of the given object. */
|
||||||
struct link_map *map = handle;
|
struct link_map *map = handle;
|
||||||
|
|
||||||
if (match == NULL)
|
|
||||||
/* If the address is not recognized the call comes from the
|
|
||||||
main program (we hope). */
|
|
||||||
match = _dl_loaded;
|
|
||||||
|
|
||||||
result = _dl_lookup_symbol (name, match, &ref, map->l_local_scope,
|
result = _dl_lookup_symbol (name, match, &ref, map->l_local_scope,
|
||||||
0, 1);
|
0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! match)
|
if (__builtin_expect (match == _dl_loaded, 0))
|
||||||
_dl_signal_error (0, NULL, N_("\
|
_dl_signal_error (0, NULL, N_("\
|
||||||
RTLD_NEXT used in code not dynamically loaded"));
|
RTLD_NEXT used in code not dynamically loaded"));
|
||||||
|
|
||||||
l = match;
|
l = match;
|
||||||
while (l->l_loader)
|
while (l->l_loader != NULL)
|
||||||
l = l->l_loader;
|
l = l->l_loader;
|
||||||
|
|
||||||
result = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope,
|
result = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope,
|
||||||
|
@ -79,7 +77,7 @@ RTLD_NEXT used in code not dynamically loaded"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref)
|
if (ref != NULL)
|
||||||
return DL_SYMBOL_ADDRESS (result, ref);
|
return DL_SYMBOL_ADDRESS (result, ref);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -103,24 +101,32 @@ _dl_vsym (void *handle, const char *name, const char *version, void *who)
|
||||||
/* We don't have a specific file where the symbol can be found. */
|
/* We don't have a specific file where the symbol can be found. */
|
||||||
vers.filename = NULL;
|
vers.filename = NULL;
|
||||||
|
|
||||||
|
/* If the address is not recognized the call comes from the main
|
||||||
|
program (we hope). */
|
||||||
|
match = _dl_loaded;
|
||||||
|
|
||||||
/* Find the highest-addressed object that CALLER is not below. */
|
/* Find the highest-addressed object that CALLER is not below. */
|
||||||
match = NULL;
|
for (l = _dl_loaded; l != NULL; l = l->l_next)
|
||||||
for (l = _dl_loaded; l; l = l->l_next)
|
if (l->l_addr != 0 && caller >= l->l_map_start && caller < l->l_map_end)
|
||||||
if (caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
|
{
|
||||||
match = l;
|
/* There must be exactly one DSO for the range of the virtual
|
||||||
|
memory. Otherwise something is really broken. */
|
||||||
|
match = l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (handle == RTLD_DEFAULT)
|
if (handle == RTLD_DEFAULT)
|
||||||
/* Search the global scope. */
|
/* Search the global scope. */
|
||||||
result = _dl_lookup_versioned_symbol (name, match, &ref, _dl_global_scope,
|
result = _dl_lookup_versioned_symbol (name, match, &ref, match->l_scope,
|
||||||
&vers, 0, 0);
|
&vers, 0, 0);
|
||||||
else if (handle == RTLD_NEXT)
|
else if (handle == RTLD_NEXT)
|
||||||
{
|
{
|
||||||
if (! match)
|
if (match == _dl_loaded)
|
||||||
_dl_signal_error (0, NULL, N_("\
|
_dl_signal_error (0, NULL, N_("\
|
||||||
RTLD_NEXT used in code not dynamically loaded"));
|
RTLD_NEXT used in code not dynamically loaded"));
|
||||||
|
|
||||||
l = match;
|
l = match;
|
||||||
while (l->l_loader)
|
while (l->l_loader != NULL)
|
||||||
l = l->l_loader;
|
l = l->l_loader;
|
||||||
|
|
||||||
result = _dl_lookup_versioned_symbol_skip (name, l, &ref,
|
result = _dl_lookup_versioned_symbol_skip (name, l, &ref,
|
||||||
|
@ -135,7 +141,7 @@ RTLD_NEXT used in code not dynamically loaded"));
|
||||||
map->l_local_scope, &vers, 0, 1);
|
map->l_local_scope, &vers, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref)
|
if (ref != NULL)
|
||||||
return DL_SYMBOL_ADDRESS (result, ref);
|
return DL_SYMBOL_ADDRESS (result, ref);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue