|
Packit Bot |
4fdc41 |
/* Print usage information and help for ld.so.
|
|
Packit Bot |
4fdc41 |
Copyright (C) 1995-2020 Free Software Foundation, Inc.
|
|
Packit Bot |
4fdc41 |
This file is part of the GNU C Library.
|
|
Packit Bot |
4fdc41 |
|
|
Packit Bot |
4fdc41 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Bot |
4fdc41 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Bot |
4fdc41 |
License as published by the Free Software Foundation; either
|
|
Packit Bot |
4fdc41 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Bot |
4fdc41 |
|
|
Packit Bot |
4fdc41 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Bot |
4fdc41 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Bot |
4fdc41 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Bot |
4fdc41 |
Lesser General Public License for more details.
|
|
Packit Bot |
4fdc41 |
|
|
Packit Bot |
4fdc41 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Bot |
4fdc41 |
License along with the GNU C Library; if not, see
|
|
Packit Bot |
4fdc41 |
<https://www.gnu.org/licenses/>. */
|
|
Packit Bot |
4fdc41 |
|
|
Packit Bot |
4fdc41 |
#include <dl-cache.h>
|
|
Packit Bot |
4fdc41 |
#include <dl-main.h>
|
|
Packit Bot |
4fdc41 |
#include <ldsodefs.h>
|
|
Packit Bot |
ebaa5c |
#include <unistd.h>
|
|
Packit Bot |
79ca57 |
#include "version.h"
|
|
Packit Bot |
4fdc41 |
|
|
Packit Bot |
016b4e |
#include <dl-procinfo.h>
|
|
Packit Bot |
11350d |
#include <dl-hwcaps.h>
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
4fdc41 |
void
|
|
Packit Bot |
ebaa5c |
_dl_usage (const char *argv0, const char *wrong_option)
|
|
Packit Bot |
4fdc41 |
{
|
|
Packit Bot |
ebaa5c |
if (wrong_option != NULL)
|
|
Packit Bot |
ebaa5c |
_dl_error_printf ("%s: unrecognized option '%s'\n", argv0, wrong_option);
|
|
Packit Bot |
ebaa5c |
else
|
|
Packit Bot |
ebaa5c |
_dl_error_printf ("%s: missing program name\n", argv0);
|
|
Packit Bot |
ebaa5c |
_dl_error_printf ("Try '%s --help' for more information.\n", argv0);
|
|
Packit Bot |
ebaa5c |
_exit (EXIT_FAILURE);
|
|
Packit Bot |
ebaa5c |
}
|
|
Packit Bot |
ebaa5c |
|
|
Packit Bot |
ebaa5c |
void
|
|
Packit Bot |
79ca57 |
_dl_version (void)
|
|
Packit Bot |
79ca57 |
{
|
|
Packit Bot |
79ca57 |
_dl_printf ("\
|
|
Packit Bot |
79ca57 |
ld.so " PKGVERSION RELEASE " release version " VERSION ".\n\
|
|
Packit Bot |
79ca57 |
Copyright (C) 2020 Free Software Foundation, Inc.\n\
|
|
Packit Bot |
79ca57 |
This is free software; see the source for copying conditions.\n\
|
|
Packit Bot |
79ca57 |
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
|
|
Packit Bot |
79ca57 |
PARTICULAR PURPOSE.\n\
|
|
Packit Bot |
79ca57 |
");
|
|
Packit Bot |
79ca57 |
_exit (EXIT_SUCCESS);
|
|
Packit Bot |
79ca57 |
}
|
|
Packit Bot |
79ca57 |
|
|
Packit Bot |
68dac0 |
/* Print part of the library search path (from a single source). */
|
|
Packit Bot |
68dac0 |
static void
|
|
Packit Bot |
68dac0 |
print_search_path_for_help_1 (struct r_search_path_elem **list)
|
|
Packit Bot |
68dac0 |
{
|
|
Packit Bot |
68dac0 |
if (list == NULL || list == (void *) -1)
|
|
Packit Bot |
68dac0 |
/* Path is missing or marked as inactive. */
|
|
Packit Bot |
68dac0 |
return;
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
for (; *list != NULL; ++list)
|
|
Packit Bot |
68dac0 |
{
|
|
Packit Bot |
68dac0 |
_dl_write (STDOUT_FILENO, " ", 2);
|
|
Packit Bot |
68dac0 |
const char *name = (*list)->dirname;
|
|
Packit Bot |
68dac0 |
size_t namelen = (*list)->dirnamelen;
|
|
Packit Bot |
68dac0 |
if (namelen == 0)
|
|
Packit Bot |
68dac0 |
{
|
|
Packit Bot |
68dac0 |
/* The empty string denotes the current directory. */
|
|
Packit Bot |
68dac0 |
name = ".";
|
|
Packit Bot |
68dac0 |
namelen = 1;
|
|
Packit Bot |
68dac0 |
}
|
|
Packit Bot |
68dac0 |
else if (namelen > 1)
|
|
Packit Bot |
68dac0 |
/* Remove the trailing slash. */
|
|
Packit Bot |
68dac0 |
--namelen;
|
|
Packit Bot |
68dac0 |
_dl_write (STDOUT_FILENO, name, namelen);
|
|
Packit Bot |
68dac0 |
_dl_printf (" (%s)\n", (*list)->what);
|
|
Packit Bot |
68dac0 |
}
|
|
Packit Bot |
68dac0 |
}
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
/* Prints the library search path. See _dl_init_paths in dl-load.c
|
|
Packit Bot |
68dac0 |
how this information is populated. */
|
|
Packit Bot |
68dac0 |
static void
|
|
Packit Bot |
68dac0 |
print_search_path_for_help (struct dl_main_state *state)
|
|
Packit Bot |
68dac0 |
{
|
|
Packit Bot |
68dac0 |
if (__rtld_search_dirs.dirs == NULL)
|
|
Packit Bot |
68dac0 |
/* The run-time search paths have not yet been initialized. */
|
|
Packit Bot |
bcd2c7 |
call_init_paths (state);
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
_dl_printf ("\nShared library search path:\n");
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
/* The print order should reflect the processing in
|
|
Packit Bot |
68dac0 |
_dl_map_object. */
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
struct link_map *map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
|
|
Packit Bot |
68dac0 |
if (map != NULL)
|
|
Packit Bot |
68dac0 |
print_search_path_for_help_1 (map->l_rpath_dirs.dirs);
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
print_search_path_for_help_1 (__rtld_env_path_list.dirs);
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
if (map != NULL)
|
|
Packit Bot |
68dac0 |
print_search_path_for_help_1 (map->l_runpath_dirs.dirs);
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
_dl_printf (" (libraries located via %s)\n", LD_SO_CACHE);
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
68dac0 |
print_search_path_for_help_1 (__rtld_search_dirs.dirs);
|
|
Packit Bot |
68dac0 |
}
|
|
Packit Bot |
68dac0 |
|
|
Packit Bot |
11350d |
/* Helper function for printing flags associated with a HWCAP name. */
|
|
Packit Bot |
11350d |
static void
|
|
Packit Bot |
11350d |
print_hwcap_1 (bool *first, bool active, const char *label)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
if (active)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
if (*first)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
_dl_printf (" (");
|
|
Packit Bot |
11350d |
*first = false;
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
else
|
|
Packit Bot |
11350d |
_dl_printf (", ");
|
|
Packit Bot |
11350d |
_dl_printf ("%s", label);
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
11350d |
/* Called after a series of print_hwcap_1 calls to emit the line
|
|
Packit Bot |
11350d |
terminator. */
|
|
Packit Bot |
11350d |
static void
|
|
Packit Bot |
11350d |
print_hwcap_1_finish (bool *first)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
if (*first)
|
|
Packit Bot |
11350d |
_dl_printf ("\n");
|
|
Packit Bot |
11350d |
else
|
|
Packit Bot |
11350d |
_dl_printf (")\n");
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
bcd2c7 |
/* Print the header for print_hwcaps_subdirectories. */
|
|
Packit Bot |
bcd2c7 |
static void
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories_header (bool *nothing_printed)
|
|
Packit Bot |
bcd2c7 |
{
|
|
Packit Bot |
bcd2c7 |
if (*nothing_printed)
|
|
Packit Bot |
bcd2c7 |
{
|
|
Packit Bot |
bcd2c7 |
_dl_printf ("\n\
|
|
Packit Bot |
bcd2c7 |
Subdirectories of glibc-hwcaps directories, in priority order:\n");
|
|
Packit Bot |
bcd2c7 |
*nothing_printed = false;
|
|
Packit Bot |
bcd2c7 |
}
|
|
Packit Bot |
bcd2c7 |
}
|
|
Packit Bot |
bcd2c7 |
|
|
Packit Bot |
bcd2c7 |
/* Print the HWCAP name itself, indented. */
|
|
Packit Bot |
bcd2c7 |
static void
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories_name (const struct dl_hwcaps_split *split)
|
|
Packit Bot |
bcd2c7 |
{
|
|
Packit Bot |
bcd2c7 |
_dl_write (STDOUT_FILENO, " ", 2);
|
|
Packit Bot |
bcd2c7 |
_dl_write (STDOUT_FILENO, split->segment, split->length);
|
|
Packit Bot |
bcd2c7 |
}
|
|
Packit Bot |
bcd2c7 |
|
|
Packit Bot |
bcd2c7 |
/* Print the list of recognized glibc-hwcaps subdirectories. */
|
|
Packit Bot |
bcd2c7 |
static void
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories (const struct dl_main_state *state)
|
|
Packit Bot |
bcd2c7 |
{
|
|
Packit Bot |
bcd2c7 |
bool nothing_printed = true;
|
|
Packit Bot |
bcd2c7 |
struct dl_hwcaps_split split;
|
|
Packit Bot |
bcd2c7 |
|
|
Packit Bot |
bcd2c7 |
/* The prepended glibc-hwcaps subdirectories. */
|
|
Packit Bot |
bcd2c7 |
_dl_hwcaps_split_init (&split, state->glibc_hwcaps_prepend);
|
|
Packit Bot |
bcd2c7 |
while (_dl_hwcaps_split (&split))
|
|
Packit Bot |
bcd2c7 |
{
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories_header (¬hing_printed);
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories_name (&split);
|
|
Packit Bot |
bcd2c7 |
bool first = true;
|
|
Packit Bot |
bcd2c7 |
print_hwcap_1 (&first, true, "searched");
|
|
Packit Bot |
bcd2c7 |
print_hwcap_1_finish (&first);
|
|
Packit Bot |
bcd2c7 |
}
|
|
Packit Bot |
bcd2c7 |
|
|
Packit Bot |
bcd2c7 |
/* The built-in glibc-hwcaps subdirectories. Do the filtering
|
|
Packit Bot |
bcd2c7 |
manually, so that more precise diagnostics are possible. */
|
|
Packit Bot |
bcd2c7 |
uint32_t mask = _dl_hwcaps_subdirs_active ();
|
|
Packit Bot |
bcd2c7 |
_dl_hwcaps_split_init (&split, _dl_hwcaps_subdirs);
|
|
Packit Bot |
bcd2c7 |
while (_dl_hwcaps_split (&split))
|
|
Packit Bot |
bcd2c7 |
{
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories_header (¬hing_printed);
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories_name (&split);
|
|
Packit Bot |
bcd2c7 |
bool first = true;
|
|
Packit Bot |
bcd2c7 |
print_hwcap_1 (&first, mask & 1, "supported");
|
|
Packit Bot |
bcd2c7 |
bool listed = _dl_hwcaps_contains (state->glibc_hwcaps_mask,
|
|
Packit Bot |
bcd2c7 |
split.segment, split.length);
|
|
Packit Bot |
bcd2c7 |
print_hwcap_1 (&first, !listed, "masked");
|
|
Packit Bot |
bcd2c7 |
print_hwcap_1 (&first, (mask & 1) && listed, "searched");
|
|
Packit Bot |
bcd2c7 |
print_hwcap_1_finish (&first);
|
|
Packit Bot |
bcd2c7 |
mask >>= 1;
|
|
Packit Bot |
bcd2c7 |
}
|
|
Packit Bot |
bcd2c7 |
|
|
Packit Bot |
bcd2c7 |
if (nothing_printed)
|
|
Packit Bot |
bcd2c7 |
_dl_printf ("\n\
|
|
Packit Bot |
bcd2c7 |
No subdirectories of glibc-hwcaps directories are searched.\n");
|
|
Packit Bot |
bcd2c7 |
}
|
|
Packit Bot |
bcd2c7 |
|
|
Packit Bot |
11350d |
/* Write a list of hwcap subdirectories to standard output. See
|
|
Packit Bot |
11350d |
_dl_important_hwcaps in dl-hwcaps.c. */
|
|
Packit Bot |
11350d |
static void
|
|
Packit Bot |
11350d |
print_legacy_hwcap_directories (void)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
_dl_printf ("\n\
|
|
Packit Bot |
11350d |
Legacy HWCAP subdirectories under library search path directories:\n");
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
11350d |
const char *platform = GLRO (dl_platform);
|
|
Packit Bot |
11350d |
if (platform != NULL)
|
|
Packit Bot |
11350d |
_dl_printf (" %s (AT_PLATFORM; supported, searched)\n", platform);
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
11350d |
_dl_printf (" tls (supported, searched)\n");
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
11350d |
uint64_t hwcap_mask = GET_HWCAP_MASK();
|
|
Packit Bot |
11350d |
uint64_t searched = GLRO (dl_hwcap) & hwcap_mask;
|
|
Packit Bot |
11350d |
for (int n = 63; n >= 0; --n)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
uint64_t bit = 1ULL << n;
|
|
Packit Bot |
11350d |
if (HWCAP_IMPORTANT & bit)
|
|
Packit Bot |
11350d |
{
|
|
Packit Bot |
11350d |
_dl_printf (" %s", _dl_hwcap_string (n));
|
|
Packit Bot |
11350d |
bool first = true;
|
|
Packit Bot |
11350d |
print_hwcap_1 (&first, GLRO (dl_hwcap) & bit, "supported");
|
|
Packit Bot |
11350d |
print_hwcap_1 (&first, !(hwcap_mask & bit), "masked");
|
|
Packit Bot |
11350d |
print_hwcap_1 (&first, searched & bit, "searched");
|
|
Packit Bot |
11350d |
print_hwcap_1_finish (&first);
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
}
|
|
Packit Bot |
11350d |
|
|
Packit Bot |
79ca57 |
void
|
|
Packit Bot |
ebaa5c |
_dl_help (const char *argv0, struct dl_main_state *state)
|
|
Packit Bot |
ebaa5c |
{
|
|
Packit Bot |
ebaa5c |
_dl_printf ("\
|
|
Packit Bot |
ebaa5c |
Usage: %s [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\
|
|
Packit Bot |
a60e52 |
You have invoked 'ld.so', the program interpreter for dynamically-linked\n\
|
|
Packit Bot |
a60e52 |
ELF programs. Usually, the program interpreter is invoked automatically\n\
|
|
Packit Bot |
a60e52 |
when a dynamically-linked executable is started.\n\
|
|
Packit Bot |
a60e52 |
\n\
|
|
Packit Bot |
a60e52 |
You may invoke the program interpreter program directly from the command\n\
|
|
Packit Bot |
a60e52 |
line to load and run an ELF executable file; this is like executing that\n\
|
|
Packit Bot |
a60e52 |
file itself, but always uses the program interpreter you invoked,\n\
|
|
Packit Bot |
a60e52 |
instead of the program interpreter specified in the executable file you\n\
|
|
Packit Bot |
a60e52 |
run. Invoking the program interpreter directly provides access to\n\
|
|
Packit Bot |
a60e52 |
additional diagnostics, and changing the dynamic linker behavior without\n\
|
|
Packit Bot |
a60e52 |
setting environment variables (which would be inherited by subprocesses).\n\
|
|
Packit Bot |
4fdc41 |
\n\
|
|
Packit Bot |
4fdc41 |
--list list all dependencies and how they are resolved\n\
|
|
Packit Bot |
4fdc41 |
--verify verify that given object really is a dynamically linked\n\
|
|
Packit Bot |
4fdc41 |
object we can handle\n\
|
|
Packit Bot |
4fdc41 |
--inhibit-cache Do not use " LD_SO_CACHE "\n\
|
|
Packit Bot |
4fdc41 |
--library-path PATH use given PATH instead of content of the environment\n\
|
|
Packit Bot |
4fdc41 |
variable LD_LIBRARY_PATH\n\
|
|
Packit Bot |
bcd2c7 |
--glibc-hwcaps-prepend LIST\n\
|
|
Packit Bot |
bcd2c7 |
search glibc-hwcaps subdirectories in LIST\n\
|
|
Packit Bot |
bcd2c7 |
--glibc-hwcaps-mask LIST\n\
|
|
Packit Bot |
bcd2c7 |
only search built-in subdirectories if in LIST\n\
|
|
Packit Bot |
4fdc41 |
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
|
|
Packit Bot |
4fdc41 |
in LIST\n\
|
|
Packit Bot |
4fdc41 |
--audit LIST use objects named in LIST as auditors\n\
|
|
Packit Bot |
4fdc41 |
--preload LIST preload objects named in LIST\n\
|
|
Packit Bot |
ebaa5c |
--argv0 STRING set argv[0] to STRING before running\n\
|
|
Packit Bot |
ebaa5c |
--help display this help and exit\n\
|
|
Packit Bot |
79ca57 |
--version output version information and exit\n\
|
|
Packit Bot |
8369e7 |
\n\
|
|
Packit Bot |
8369e7 |
This program interpreter self-identifies as: " RTLD "\n\
|
|
Packit Bot |
ebaa5c |
",
|
|
Packit Bot |
ebaa5c |
argv0);
|
|
Packit Bot |
68dac0 |
print_search_path_for_help (state);
|
|
Packit Bot |
bcd2c7 |
print_hwcaps_subdirectories (state);
|
|
Packit Bot |
11350d |
print_legacy_hwcap_directories ();
|
|
Packit Bot |
ebaa5c |
_exit (EXIT_SUCCESS);
|
|
Packit Bot |
4fdc41 |
}
|