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