2001-11-01  Ulrich Drepper  <drepper@redhat.com>

	* elf/dl-load.c (_dl_map_object): Correct test of DF_1_NODEFLIB
	for rtld_search_dirs content.  Minor optimizations.
This commit is contained in:
Ulrich Drepper 2001-11-01 23:16:25 +00:00
parent 955891779a
commit 2f653c01fc
2 changed files with 45 additions and 21 deletions

View File

@ -1,3 +1,8 @@
2001-11-01 Ulrich Drepper <drepper@redhat.com>
* elf/dl-load.c (_dl_map_object): Correct test of DF_1_NODEFLIB
for rtld_search_dirs content. Minor optimizations.
2001-10-31 Ulrich Drepper <drepper@redhat.com> 2001-10-31 Ulrich Drepper <drepper@redhat.com>
* elf/dl-load.c (_dl_map_object): Make code a bit more compact by * elf/dl-load.c (_dl_map_object): Make code a bit more compact by

View File

@ -1467,7 +1467,7 @@ open_path (const char *name, size_t namelen, int preloaded,
if (fd != -1) if (fd != -1)
{ {
*realname = malloc (buflen); *realname = (char *) malloc (buflen);
if (*realname != NULL) if (*realname != NULL)
{ {
memcpy (*realname, buf, buflen); memcpy (*realname, buf, buflen);
@ -1573,8 +1573,11 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
if (l->l_rpath_dirs.dirs == NULL) if (l->l_rpath_dirs.dirs == NULL)
{ {
if (l->l_info[DT_RPATH] == NULL) if (l->l_info[DT_RPATH] == NULL)
/* There is no path. */ {
l->l_rpath_dirs.dirs = (void *) -1; /* There is no path. */
l->l_rpath_dirs.dirs = (void *) -1;
continue;
}
else else
{ {
/* Make sure the cache information is available. */ /* Make sure the cache information is available. */
@ -1582,13 +1585,10 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
+ l->l_info[DT_RPATH]->d_un.d_val); + l->l_info[DT_RPATH]->d_un.d_val);
decompose_rpath (&l->l_rpath_dirs, decompose_rpath (&l->l_rpath_dirs,
(const char *) ptrval, l, "RPATH"); (const char *) ptrval, l, "RPATH");
if (l->l_rpath_dirs.dirs != (void *) -1)
fd = open_path (name, namelen, preloaded,
&l->l_rpath_dirs, &realname, &fb);
} }
} }
else if (l->l_rpath_dirs.dirs != (void *) -1)
if (l->l_rpath_dirs.dirs != (void *) -1)
fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs, fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
&realname, &fb); &realname, &fb);
} }
@ -1607,15 +1607,22 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
fd = open_path (name, namelen, preloaded, &env_path_list, fd = open_path (name, namelen, preloaded, &env_path_list,
&realname, &fb); &realname, &fb);
/* Look at the RUNPATH information for this binary. */ /* Look at the RUNPATH information for this binary.
if (fd == -1 && loader != NULL
&& loader->l_runpath_dirs.dirs != (void *) -1) Note that this is no real loop. 'while' is used only to enable
us to use 'break' instead of a 'goto' to jump to the end. The
loop is always left after the first round. */
while (fd == -1 && loader != NULL
&& loader->l_runpath_dirs.dirs != (void *) -1)
{ {
if (loader->l_runpath_dirs.dirs == NULL) if (loader->l_runpath_dirs.dirs == NULL)
{ {
if (loader->l_info[DT_RUNPATH] == NULL) if (loader->l_info[DT_RUNPATH] == NULL)
/* No RUNPATH. */ {
loader->l_runpath_dirs.dirs = (void *) -1; /* No RUNPATH. */
loader->l_runpath_dirs.dirs = (void *) -1;
break;
}
else else
{ {
/* Make sure the cache information is available. */ /* Make sure the cache information is available. */
@ -1629,6 +1636,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
if (loader->l_runpath_dirs.dirs != (void *) -1) if (loader->l_runpath_dirs.dirs != (void *) -1)
fd = open_path (name, namelen, preloaded, fd = open_path (name, namelen, preloaded,
&loader->l_runpath_dirs, &realname, &fb); &loader->l_runpath_dirs, &realname, &fb);
break;
} }
if (fd == -1 if (fd == -1
@ -1638,17 +1646,22 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
for compatibility with Linux's ldconfig program. */ for compatibility with Linux's ldconfig program. */
const char *cached = _dl_load_cache_lookup (name); const char *cached = _dl_load_cache_lookup (name);
if (cached != NULL)
{
#ifdef SHARED #ifdef SHARED
l = loader ?: _dl_loaded; l = loader ?: _dl_loaded;
#else #else
l = loader; l = loader;
#endif #endif
if (cached)
{
/* If the loader has the DF_1_NODEFLIB flag set we must not /* If the loader has the DF_1_NODEFLIB flag set we must not
use a cache entry from any of these directories. */ use a cache entry from any of these directories. */
if (l && __builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0)) if (
#ifndef SHARED
/* 'l' is always != NULL for dynamically linked objects. */
l != NULL &&
#endif
__builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0))
{ {
const char *dirp = system_dirs; const char *dirp = system_dirs;
unsigned int cnt = 0; unsigned int cnt = 0;
@ -1668,10 +1681,10 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
while (cnt < nsystem_dirs_len); while (cnt < nsystem_dirs_len);
} }
if (cached) if (cached != NULL)
{ {
fd = open_verify (cached, &fb); fd = open_verify (cached, &fb);
if (__builtin_expect (fd, 0) != -1) if (__builtin_expect (fd != -1, 1))
{ {
realname = local_strdup (cached); realname = local_strdup (cached);
if (realname == NULL) if (realname == NULL)
@ -1686,7 +1699,13 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
/* Finally, try the default path. */ /* Finally, try the default path. */
if (fd == -1 if (fd == -1
&& (l == NULL || && ((l = loader ?: _dl_loaded)
/* 'l' is always != NULL for dynamically linked objects. */
#ifdef SHARED
,
#else
== NULL ||
#endif
__builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1)) __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
&& rtld_search_dirs.dirs != (void *) -1) && rtld_search_dirs.dirs != (void *) -1)
fd = open_path (name, namelen, preloaded, &rtld_search_dirs, fd = open_path (name, namelen, preloaded, &rtld_search_dirs,