aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-usage.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-12-04 09:13:43 +0100
committerFlorian Weimer <fweimer@redhat.com>2020-12-04 09:13:43 +0100
commitdad90d528259b669342757c37dedefa8577e2636 (patch)
treed0e8197ff0c886c869fa27a557cfbd4627431bf4 /elf/dl-usage.c
parentc41d197ec4a564a588e1cf3855d955297f2915c4 (diff)
downloadglibc-dad90d528259b669342757c37dedefa8577e2636.zip
glibc-dad90d528259b669342757c37dedefa8577e2636.tar.gz
glibc-dad90d528259b669342757c37dedefa8577e2636.tar.bz2
elf: Add glibc-hwcaps support for LD_LIBRARY_PATH
This hacks non-power-set processing into _dl_important_hwcaps. Once the legacy hwcaps handling goes away, the subdirectory handling needs to be reworked, but it is premature to do this while both approaches are still supported. ld.so supports two new arguments, --glibc-hwcaps-prepend and --glibc-hwcaps-mask. Each accepts a colon-separated list of glibc-hwcaps subdirectory names. The prepend option adds additional subdirectories that are searched first, in the specified order. The mask option restricts the automatically selected subdirectories to those listed in the option argument. For example, on systems where /usr/lib64 is on the library search path, --glibc-hwcaps-prepend=valgrind:debug causes the dynamic loader to search the directories /usr/lib64/glibc-hwcaps/valgrind and /usr/lib64/glibc-hwcaps/debug just before /usr/lib64 is searched. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/dl-usage.c')
-rw-r--r--elf/dl-usage.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
index 796ad38..e22a9c3 100644
--- a/elf/dl-usage.c
+++ b/elf/dl-usage.c
@@ -83,7 +83,7 @@ print_search_path_for_help (struct dl_main_state *state)
{
if (__rtld_search_dirs.dirs == NULL)
/* The run-time search paths have not yet been initialized. */
- _dl_init_paths (state->library_path, state->library_path_source);
+ call_init_paths (state);
_dl_printf ("\nShared library search path:\n");
@@ -132,6 +132,67 @@ print_hwcap_1_finish (bool *first)
_dl_printf (")\n");
}
+/* Print the header for print_hwcaps_subdirectories. */
+static void
+print_hwcaps_subdirectories_header (bool *nothing_printed)
+{
+ if (*nothing_printed)
+ {
+ _dl_printf ("\n\
+Subdirectories of glibc-hwcaps directories, in priority order:\n");
+ *nothing_printed = false;
+ }
+}
+
+/* Print the HWCAP name itself, indented. */
+static void
+print_hwcaps_subdirectories_name (const struct dl_hwcaps_split *split)
+{
+ _dl_write (STDOUT_FILENO, " ", 2);
+ _dl_write (STDOUT_FILENO, split->segment, split->length);
+}
+
+/* Print the list of recognized glibc-hwcaps subdirectories. */
+static void
+print_hwcaps_subdirectories (const struct dl_main_state *state)
+{
+ bool nothing_printed = true;
+ struct dl_hwcaps_split split;
+
+ /* The prepended glibc-hwcaps subdirectories. */
+ _dl_hwcaps_split_init (&split, state->glibc_hwcaps_prepend);
+ while (_dl_hwcaps_split (&split))
+ {
+ print_hwcaps_subdirectories_header (&nothing_printed);
+ print_hwcaps_subdirectories_name (&split);
+ bool first = true;
+ print_hwcap_1 (&first, true, "searched");
+ print_hwcap_1_finish (&first);
+ }
+
+ /* The built-in glibc-hwcaps subdirectories. Do the filtering
+ manually, so that more precise diagnostics are possible. */
+ uint32_t mask = _dl_hwcaps_subdirs_active ();
+ _dl_hwcaps_split_init (&split, _dl_hwcaps_subdirs);
+ while (_dl_hwcaps_split (&split))
+ {
+ print_hwcaps_subdirectories_header (&nothing_printed);
+ print_hwcaps_subdirectories_name (&split);
+ bool first = true;
+ print_hwcap_1 (&first, mask & 1, "supported");
+ bool listed = _dl_hwcaps_contains (state->glibc_hwcaps_mask,
+ split.segment, split.length);
+ print_hwcap_1 (&first, !listed, "masked");
+ print_hwcap_1 (&first, (mask & 1) && listed, "searched");
+ print_hwcap_1_finish (&first);
+ mask >>= 1;
+ }
+
+ if (nothing_printed)
+ _dl_printf ("\n\
+No subdirectories of glibc-hwcaps directories are searched.\n");
+}
+
/* Write a list of hwcap subdirectories to standard output. See
_dl_important_hwcaps in dl-hwcaps.c. */
static void
@@ -186,6 +247,10 @@ setting environment variables (which would be inherited by subprocesses).\n\
--inhibit-cache Do not use " LD_SO_CACHE "\n\
--library-path PATH use given PATH instead of content of the environment\n\
variable LD_LIBRARY_PATH\n\
+ --glibc-hwcaps-prepend LIST\n\
+ search glibc-hwcaps subdirectories in LIST\n\
+ --glibc-hwcaps-mask LIST\n\
+ only search built-in subdirectories if in LIST\n\
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
in LIST\n\
--audit LIST use objects named in LIST as auditors\n\
@@ -198,6 +263,7 @@ This program interpreter self-identifies as: " RTLD "\n\
",
argv0);
print_search_path_for_help (state);
+ print_hwcaps_subdirectories (state);
print_legacy_hwcap_directories ();
_exit (EXIT_SUCCESS);
}