|
Packit Service |
95e609 |
/* Information collection during ld.so startup.
|
|
Packit Service |
95e609 |
Copyright (C) 1995-2020 Free Software Foundation, Inc.
|
|
Packit Service |
95e609 |
This file is part of the GNU C Library.
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
95e609 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
95e609 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
95e609 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
95e609 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
95e609 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
95e609 |
Lesser General Public License for more details.
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
95e609 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
95e609 |
<https://www.gnu.org/licenses/>. */
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
#ifndef _DL_MAIN
|
|
Packit Service |
95e609 |
#define _DL_MAIN
|
|
Packit Service |
95e609 |
|
|
Packit Service |
235a9c |
#include <ldsodefs.h>
|
|
Packit Service |
95e609 |
#include <limits.h>
|
|
Packit Service |
235a9c |
#include <stdlib.h>
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Length limits for names and paths, to protect the dynamic linker,
|
|
Packit Service |
95e609 |
particularly when __libc_enable_secure is active. */
|
|
Packit Service |
95e609 |
#ifdef NAME_MAX
|
|
Packit Service |
95e609 |
# define SECURE_NAME_LIMIT NAME_MAX
|
|
Packit Service |
95e609 |
#else
|
|
Packit Service |
95e609 |
# define SECURE_NAME_LIMIT 255
|
|
Packit Service |
95e609 |
#endif
|
|
Packit Service |
95e609 |
#ifdef PATH_MAX
|
|
Packit Service |
95e609 |
# define SECURE_PATH_LIMIT PATH_MAX
|
|
Packit Service |
95e609 |
#else
|
|
Packit Service |
95e609 |
# define SECURE_PATH_LIMIT 1024
|
|
Packit Service |
95e609 |
#endif
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Strings containing colon-separated lists of audit modules. */
|
|
Packit Service |
95e609 |
struct audit_list
|
|
Packit Service |
95e609 |
{
|
|
Packit Service |
95e609 |
/* Array of strings containing colon-separated path lists. Each
|
|
Packit Service |
95e609 |
audit module needs its own namespace, so pre-allocate the largest
|
|
Packit Service |
95e609 |
possible list. */
|
|
Packit Service |
95e609 |
const char *audit_strings[DL_NNS];
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Number of entries added to audit_strings. */
|
|
Packit Service |
95e609 |
size_t length;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Index into the audit_strings array (for the iteration phase). */
|
|
Packit Service |
95e609 |
size_t current_index;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Tail of audit_strings[current_index] which still needs
|
|
Packit Service |
95e609 |
processing. */
|
|
Packit Service |
95e609 |
const char *current_tail;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Scratch buffer for returning a name which is part of the strings
|
|
Packit Service |
95e609 |
in audit_strings. */
|
|
Packit Service |
95e609 |
char fname[SECURE_NAME_LIMIT];
|
|
Packit Service |
95e609 |
};
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* This is a list of all the modes the dynamic loader can be in. */
|
|
Packit Service |
95e609 |
enum rtld_mode
|
|
Packit Service |
95e609 |
{
|
|
Packit Service |
95e609 |
rtld_mode_normal, rtld_mode_list, rtld_mode_verify, rtld_mode_trace,
|
|
Packit Service |
5f150c |
rtld_mode_help,
|
|
Packit Service |
95e609 |
};
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Aggregated state information extracted from environment variables
|
|
Packit Service |
95e609 |
and the ld.so command line. */
|
|
Packit Service |
95e609 |
struct dl_main_state
|
|
Packit Service |
95e609 |
{
|
|
Packit Service |
95e609 |
struct audit_list audit_list;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* The library search path. */
|
|
Packit Service |
95e609 |
const char *library_path;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
b0cbe9 |
/* Where library_path comes from. LD_LIBRARY_PATH or --library-path. */
|
|
Packit Service |
b0cbe9 |
const char *library_path_source;
|
|
Packit Service |
b0cbe9 |
|
|
Packit Service |
95e609 |
/* The list preloaded objects from LD_PRELOAD. */
|
|
Packit Service |
95e609 |
const char *preloadlist;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* The preload list passed as a command argument. */
|
|
Packit Service |
95e609 |
const char *preloadarg;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
enum rtld_mode mode;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* True if any of the debugging options is enabled. */
|
|
Packit Service |
95e609 |
bool any_debug;
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* True if information about versions has to be printed. */
|
|
Packit Service |
95e609 |
bool version_info;
|
|
Packit Service |
95e609 |
};
|
|
Packit Service |
95e609 |
|
|
Packit Service |
95e609 |
/* Helper function to invoke _dl_init_paths with the right arguments
|
|
Packit Service |
95e609 |
from *STATE. */
|
|
Packit Service |
95e609 |
static inline void
|
|
Packit Service |
95e609 |
call_init_paths (const struct dl_main_state *state)
|
|
Packit Service |
95e609 |
{
|
|
Packit Service |
b0cbe9 |
_dl_init_paths (state->library_path, state->library_path_source);
|
|
Packit Service |
95e609 |
}
|
|
Packit Service |
95e609 |
|
|
Packit Service |
235a9c |
/* Print ld.so usage information and exit. */
|
|
Packit Service |
5f150c |
_Noreturn void _dl_usage (const char *argv0, const char *wrong_option)
|
|
Packit Service |
5f150c |
attribute_hidden;
|
|
Packit Service |
5f150c |
|
|
Packit Service |
5f150c |
/* Print ld.so --help output and exit. */
|
|
Packit Service |
5f150c |
_Noreturn void _dl_help (const char *argv0, struct dl_main_state *state)
|
|
Packit Service |
5f150c |
attribute_hidden;
|
|
Packit Service |
235a9c |
|
|
Packit Service |
95e609 |
#endif /* _DL_MAIN */
|