|
|
e354a5 |
commit 27316f4a23efdc90bdfe4569a6c4b7e27941606e
|
|
|
e354a5 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
e354a5 |
Date: Thu Oct 8 10:57:10 2020 +0200
|
|
|
e354a5 |
|
|
|
e354a5 |
elf: Record whether paths come from LD_LIBRARY_PATH or --library-path
|
|
|
e354a5 |
|
|
|
e354a5 |
This allows more precise LD_DEBUG diagnostics.
|
|
|
e354a5 |
|
|
|
e354a5 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
|
|
e354a5 |
index 2b4dd9a0f3e27b70..1403a2e9c04e9a16 100644
|
|
|
e354a5 |
--- a/elf/dl-load.c
|
|
|
e354a5 |
+++ b/elf/dl-load.c
|
|
|
e354a5 |
@@ -682,7 +682,7 @@ cache_rpath (struct link_map *l,
|
|
|
e354a5 |
|
|
|
e354a5 |
|
|
|
e354a5 |
void
|
|
|
e354a5 |
-_dl_init_paths (const char *llp)
|
|
|
e354a5 |
+_dl_init_paths (const char *llp, const char *source)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
size_t idx;
|
|
|
e354a5 |
const char *strp;
|
|
|
e354a5 |
@@ -820,7 +820,7 @@ _dl_init_paths (const char *llp)
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
(void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
|
|
|
e354a5 |
- "LD_LIBRARY_PATH", NULL, l);
|
|
|
e354a5 |
+ source, NULL, l);
|
|
|
e354a5 |
|
|
|
e354a5 |
if (env_path_list.dirs[0] == NULL)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
diff --git a/elf/dl-main.h b/elf/dl-main.h
|
|
|
e354a5 |
index b01f433f9c8d9e1a..79c9c40056504f80 100644
|
|
|
e354a5 |
--- a/elf/dl-main.h
|
|
|
e354a5 |
+++ b/elf/dl-main.h
|
|
|
e354a5 |
@@ -74,6 +74,9 @@ struct dl_main_state
|
|
|
e354a5 |
/* The library search path. */
|
|
|
e354a5 |
const char *library_path;
|
|
|
e354a5 |
|
|
|
e354a5 |
+ /* Where library_path comes from. LD_LIBRARY_PATH or --library-path. */
|
|
|
e354a5 |
+ const char *library_path_source;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
/* The list preloaded objects from LD_PRELOAD. */
|
|
|
e354a5 |
const char *preloadlist;
|
|
|
e354a5 |
|
|
|
e354a5 |
@@ -94,7 +97,7 @@ struct dl_main_state
|
|
|
e354a5 |
static inline void
|
|
|
e354a5 |
call_init_paths (const struct dl_main_state *state)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
- _dl_init_paths (state->library_path);
|
|
|
e354a5 |
+ _dl_init_paths (state->library_path, state->library_path_source);
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Print ld.so usage information and exit. */
|
|
|
e354a5 |
diff --git a/elf/dl-support.c b/elf/dl-support.c
|
|
|
e354a5 |
index ef5455b91c17ca30..fb9672367f8d6abd 100644
|
|
|
e354a5 |
--- a/elf/dl-support.c
|
|
|
e354a5 |
+++ b/elf/dl-support.c
|
|
|
e354a5 |
@@ -315,7 +315,7 @@ _dl_non_dynamic_init (void)
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Initialize the data structures for the search paths for shared
|
|
|
e354a5 |
objects. */
|
|
|
e354a5 |
- _dl_init_paths (getenv ("LD_LIBRARY_PATH"));
|
|
|
e354a5 |
+ _dl_init_paths (getenv ("LD_LIBRARY_PATH"), "LD_LIBRARY_PATH");
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Remember the last search directory added at startup. */
|
|
|
e354a5 |
_dl_init_all_dirs = GL(dl_all_dirs);
|
|
|
e354a5 |
diff --git a/elf/rtld.c b/elf/rtld.c
|
|
|
e354a5 |
index a12a56b550bbc837..8e91cee41b62b894 100644
|
|
|
e354a5 |
--- a/elf/rtld.c
|
|
|
e354a5 |
+++ b/elf/rtld.c
|
|
|
e354a5 |
@@ -284,6 +284,7 @@ dl_main_state_init (struct dl_main_state *state)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
audit_list_init (&state->audit_list);
|
|
|
e354a5 |
state->library_path = NULL;
|
|
|
e354a5 |
+ state->library_path_source = NULL;
|
|
|
e354a5 |
state->preloadlist = NULL;
|
|
|
e354a5 |
state->preloadarg = NULL;
|
|
|
e354a5 |
state->mode = rtld_mode_normal;
|
|
|
e354a5 |
@@ -1197,6 +1198,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
|
|
e354a5 |
&& _dl_argc > 2)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
state.library_path = _dl_argv[2];
|
|
|
e354a5 |
+ state.library_path_source = "--library-path";
|
|
|
e354a5 |
|
|
|
e354a5 |
_dl_skip_args += 2;
|
|
|
e354a5 |
_dl_argc -= 2;
|
|
|
e354a5 |
@@ -2640,6 +2642,7 @@ process_envvars (struct dl_main_state *state)
|
|
|
e354a5 |
&& memcmp (envline, "LIBRARY_PATH", 12) == 0)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
state->library_path = &envline[13];
|
|
|
e354a5 |
+ state->library_path_source = "LD_LIBRARY_PATH";
|
|
|
e354a5 |
break;
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
|
|
e354a5 |
index 4aa28b0229e0b339..aa006afafaf46dee 100644
|
|
|
e354a5 |
--- a/sysdeps/generic/ldsodefs.h
|
|
|
e354a5 |
+++ b/sysdeps/generic/ldsodefs.h
|
|
|
e354a5 |
@@ -1044,8 +1044,10 @@ rtld_hidden_proto (_dl_debug_state)
|
|
|
e354a5 |
extern struct r_debug *_dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
|
|
|
e354a5 |
attribute_hidden;
|
|
|
e354a5 |
|
|
|
e354a5 |
-/* Initialize the basic data structure for the search paths. */
|
|
|
e354a5 |
-extern void _dl_init_paths (const char *library_path) attribute_hidden;
|
|
|
e354a5 |
+/* Initialize the basic data structure for the search paths. SOURCE
|
|
|
e354a5 |
+ is either "LD_LIBRARY_PATH" or "--library-path". */
|
|
|
e354a5 |
+extern void _dl_init_paths (const char *library_path, const char *source)
|
|
|
e354a5 |
+ attribute_hidden;
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Gather the information needed to install the profiling tables and start
|
|
|
e354a5 |
the timers. */
|