|
|
446cf2 |
commit 50b1b7a3905cbcdfbcc7eab335aa81478d711d1a
|
|
|
446cf2 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
446cf2 |
Date: Thu Oct 8 15:33:00 2020 +0200
|
|
|
446cf2 |
|
|
|
446cf2 |
elf: Make __rtld_env_path_list and __rtld_search_dirs global variables
|
|
|
446cf2 |
|
|
|
446cf2 |
They have been renamed from env_path_list and rtld_search_dirs to
|
|
|
446cf2 |
avoid linknamespace issues.
|
|
|
446cf2 |
|
|
|
446cf2 |
This change will allow future use these variables in diagnostics.
|
|
|
446cf2 |
|
|
|
446cf2 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
446cf2 |
|
|
|
446cf2 |
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
|
|
446cf2 |
index 1403a2e9c04e9a16..2eb4f35b2467f7d8 100644
|
|
|
446cf2 |
--- a/elf/dl-load.c
|
|
|
446cf2 |
+++ b/elf/dl-load.c
|
|
|
446cf2 |
@@ -98,7 +98,7 @@ int __stack_prot attribute_hidden attribute_relro
|
|
|
446cf2 |
|
|
|
446cf2 |
|
|
|
446cf2 |
/* This is the decomposed LD_LIBRARY_PATH search path. */
|
|
|
446cf2 |
-static struct r_search_path_struct env_path_list attribute_relro;
|
|
|
446cf2 |
+struct r_search_path_struct __rtld_env_path_list attribute_relro;
|
|
|
446cf2 |
|
|
|
446cf2 |
/* List of the hardware capabilities we might end up using. */
|
|
|
446cf2 |
#ifdef SHARED
|
|
|
446cf2 |
@@ -442,7 +442,7 @@ add_name_to_object (struct link_map *l, const char *name)
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Standard search directories. */
|
|
|
446cf2 |
-static struct r_search_path_struct rtld_search_dirs attribute_relro;
|
|
|
446cf2 |
+struct r_search_path_struct __rtld_search_dirs attribute_relro;
|
|
|
446cf2 |
|
|
|
446cf2 |
static size_t max_dirnamelen;
|
|
|
446cf2 |
|
|
|
446cf2 |
@@ -702,9 +702,9 @@ _dl_init_paths (const char *llp, const char *source)
|
|
|
446cf2 |
#endif
|
|
|
446cf2 |
|
|
|
446cf2 |
/* First set up the rest of the default search directory entries. */
|
|
|
446cf2 |
- aelem = rtld_search_dirs.dirs = (struct r_search_path_elem **)
|
|
|
446cf2 |
+ aelem = __rtld_search_dirs.dirs = (struct r_search_path_elem **)
|
|
|
446cf2 |
malloc ((nsystem_dirs_len + 1) * sizeof (struct r_search_path_elem *));
|
|
|
446cf2 |
- if (rtld_search_dirs.dirs == NULL)
|
|
|
446cf2 |
+ if (__rtld_search_dirs.dirs == NULL)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
errstring = N_("cannot create search path array");
|
|
|
446cf2 |
signal_error:
|
|
|
446cf2 |
@@ -715,16 +715,17 @@ _dl_init_paths (const char *llp, const char *source)
|
|
|
446cf2 |
+ ncapstr * sizeof (enum r_dir_status))
|
|
|
446cf2 |
/ sizeof (struct r_search_path_elem));
|
|
|
446cf2 |
|
|
|
446cf2 |
- rtld_search_dirs.dirs[0] = malloc (nsystem_dirs_len * round_size
|
|
|
446cf2 |
- * sizeof (*rtld_search_dirs.dirs[0]));
|
|
|
446cf2 |
- if (rtld_search_dirs.dirs[0] == NULL)
|
|
|
446cf2 |
+ __rtld_search_dirs.dirs[0]
|
|
|
446cf2 |
+ = malloc (nsystem_dirs_len * round_size
|
|
|
446cf2 |
+ * sizeof (*__rtld_search_dirs.dirs[0]));
|
|
|
446cf2 |
+ if (__rtld_search_dirs.dirs[0] == NULL)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
errstring = N_("cannot create cache for search path");
|
|
|
446cf2 |
goto signal_error;
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
- rtld_search_dirs.malloced = 0;
|
|
|
446cf2 |
- pelem = GL(dl_all_dirs) = rtld_search_dirs.dirs[0];
|
|
|
446cf2 |
+ __rtld_search_dirs.malloced = 0;
|
|
|
446cf2 |
+ pelem = GL(dl_all_dirs) = __rtld_search_dirs.dirs[0];
|
|
|
446cf2 |
strp = system_dirs;
|
|
|
446cf2 |
idx = 0;
|
|
|
446cf2 |
|
|
|
446cf2 |
@@ -811,27 +812,27 @@ _dl_init_paths (const char *llp, const char *source)
|
|
|
446cf2 |
if (*cp == ':' || *cp == ';')
|
|
|
446cf2 |
++nllp;
|
|
|
446cf2 |
|
|
|
446cf2 |
- env_path_list.dirs = (struct r_search_path_elem **)
|
|
|
446cf2 |
+ __rtld_env_path_list.dirs = (struct r_search_path_elem **)
|
|
|
446cf2 |
malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));
|
|
|
446cf2 |
- if (env_path_list.dirs == NULL)
|
|
|
446cf2 |
+ if (__rtld_env_path_list.dirs == NULL)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
errstring = N_("cannot create cache for search path");
|
|
|
446cf2 |
goto signal_error;
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
- (void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
|
|
|
446cf2 |
+ (void) fillin_rpath (llp_tmp, __rtld_env_path_list.dirs, ":;",
|
|
|
446cf2 |
source, NULL, l);
|
|
|
446cf2 |
|
|
|
446cf2 |
- if (env_path_list.dirs[0] == NULL)
|
|
|
446cf2 |
+ if (__rtld_env_path_list.dirs[0] == NULL)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
- free (env_path_list.dirs);
|
|
|
446cf2 |
- env_path_list.dirs = (void *) -1;
|
|
|
446cf2 |
+ free (__rtld_env_path_list.dirs);
|
|
|
446cf2 |
+ __rtld_env_path_list.dirs = (void *) -1;
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
- env_path_list.malloced = 0;
|
|
|
446cf2 |
+ __rtld_env_path_list.malloced = 0;
|
|
|
446cf2 |
}
|
|
|
446cf2 |
else
|
|
|
446cf2 |
- env_path_list.dirs = (void *) -1;
|
|
|
446cf2 |
+ __rtld_env_path_list.dirs = (void *) -1;
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
|
|
|
446cf2 |
@@ -1946,9 +1947,9 @@ open_path (const char *name, size_t namelen, int mode,
|
|
|
446cf2 |
if (sps->malloced)
|
|
|
446cf2 |
free (sps->dirs);
|
|
|
446cf2 |
|
|
|
446cf2 |
- /* rtld_search_dirs and env_path_list are attribute_relro, therefore
|
|
|
446cf2 |
- avoid writing into it. */
|
|
|
446cf2 |
- if (sps != &rtld_search_dirs && sps != &env_path_list)
|
|
|
446cf2 |
+ /* __rtld_search_dirs and __rtld_env_path_list are
|
|
|
446cf2 |
+ attribute_relro, therefore avoid writing to them. */
|
|
|
446cf2 |
+ if (sps != &__rtld_search_dirs && sps != &__rtld_env_path_list)
|
|
|
446cf2 |
sps->dirs = (void *) -1;
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
@@ -2096,8 +2097,8 @@ _dl_map_object (struct link_map *loader, const char *name,
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Try the LD_LIBRARY_PATH environment variable. */
|
|
|
446cf2 |
- if (fd == -1 && env_path_list.dirs != (void *) -1)
|
|
|
446cf2 |
- fd = open_path (name, namelen, mode, &env_path_list,
|
|
|
446cf2 |
+ if (fd == -1 && __rtld_env_path_list.dirs != (void *) -1)
|
|
|
446cf2 |
+ fd = open_path (name, namelen, mode, &__rtld_env_path_list,
|
|
|
446cf2 |
&realname, &fb,
|
|
|
446cf2 |
loader ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded,
|
|
|
446cf2 |
LA_SER_LIBPATH, &found_other_class);
|
|
|
446cf2 |
@@ -2186,8 +2187,8 @@ _dl_map_object (struct link_map *loader, const char *name,
|
|
|
446cf2 |
if (fd == -1
|
|
|
446cf2 |
&& ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
|
|
|
446cf2 |
|| __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB)))
|
|
|
446cf2 |
- && rtld_search_dirs.dirs != (void *) -1)
|
|
|
446cf2 |
- fd = open_path (name, namelen, mode, &rtld_search_dirs,
|
|
|
446cf2 |
+ && __rtld_search_dirs.dirs != (void *) -1)
|
|
|
446cf2 |
+ fd = open_path (name, namelen, mode, &__rtld_search_dirs,
|
|
|
446cf2 |
&realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Add another newline when we are tracing the library loading. */
|
|
|
446cf2 |
@@ -2355,7 +2356,7 @@ _dl_rtld_di_serinfo (struct link_map *loader, Dl_serinfo *si, bool counting)
|
|
|
446cf2 |
}
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Try the LD_LIBRARY_PATH environment variable. */
|
|
|
446cf2 |
- add_path (&p, &env_path_list, XXX_ENV);
|
|
|
446cf2 |
+ add_path (&p, &__rtld_env_path_list, XXX_ENV);
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Look at the RUNPATH information for this binary. */
|
|
|
446cf2 |
if (cache_rpath (loader, &loader->l_runpath_dirs, DT_RUNPATH, "RUNPATH"))
|
|
|
446cf2 |
@@ -2367,7 +2368,7 @@ _dl_rtld_di_serinfo (struct link_map *loader, Dl_serinfo *si, bool counting)
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Finally, try the default path. */
|
|
|
446cf2 |
if (!(loader->l_flags_1 & DF_1_NODEFLIB))
|
|
|
446cf2 |
- add_path (&p, &rtld_search_dirs, XXX_default);
|
|
|
446cf2 |
+ add_path (&p, &__rtld_search_dirs, XXX_default);
|
|
|
446cf2 |
|
|
|
446cf2 |
if (counting)
|
|
|
446cf2 |
/* Count the struct size before the string area, which we didn't
|
|
|
446cf2 |
diff --git a/include/link.h b/include/link.h
|
|
|
446cf2 |
index e90fa79a0b332087..cdd011f59445e490 100644
|
|
|
446cf2 |
--- a/include/link.h
|
|
|
446cf2 |
+++ b/include/link.h
|
|
|
446cf2 |
@@ -79,6 +79,10 @@ struct r_search_path_struct
|
|
|
446cf2 |
int malloced;
|
|
|
446cf2 |
};
|
|
|
446cf2 |
|
|
|
446cf2 |
+/* Search path information computed by _dl_init_paths. */
|
|
|
446cf2 |
+extern struct r_search_path_struct __rtld_search_dirs attribute_hidden;
|
|
|
446cf2 |
+extern struct r_search_path_struct __rtld_env_path_list attribute_hidden;
|
|
|
446cf2 |
+
|
|
|
446cf2 |
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
|
|
|
446cf2 |
members form a chain of all the shared objects loaded at startup.
|
|
|
446cf2 |
|