1 /* Information collection during ld.so startup.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
26 /* Length limits for names and paths, to protect the dynamic linker,
27 particularly when __libc_enable_secure is active. */
29 # define SECURE_NAME_LIMIT NAME_MAX
31 # define SECURE_NAME_LIMIT 255
34 # define SECURE_PATH_LIMIT PATH_MAX
36 # define SECURE_PATH_LIMIT 1024
39 /* Strings containing colon-separated lists of audit modules. */
42 /* Array of strings containing colon-separated path lists. Each
43 audit module needs its own namespace, so pre-allocate the largest
45 const char *audit_strings
[DL_NNS
];
47 /* Number of entries added to audit_strings. */
50 /* Index into the audit_strings array (for the iteration phase). */
53 /* Tail of audit_strings[current_index] which still needs
55 const char *current_tail
;
57 /* Scratch buffer for returning a name which is part of the strings
59 char fname
[SECURE_NAME_LIMIT
];
62 /* This is a list of all the modes the dynamic loader can be in. */
65 rtld_mode_normal
, rtld_mode_list
, rtld_mode_verify
, rtld_mode_trace
,
66 rtld_mode_list_tunables
, rtld_mode_list_diagnostics
, rtld_mode_help
,
69 /* Aggregated state information extracted from environment variables
70 and the ld.so command line. */
73 struct audit_list audit_list
;
75 /* The library search path. */
76 const char *library_path
;
78 /* Where library_path comes from. LD_LIBRARY_PATH or --library-path. */
79 const char *library_path_source
;
81 /* The list preloaded objects from LD_PRELOAD. */
82 const char *preloadlist
;
84 /* The preload list passed as a command argument. */
85 const char *preloadarg
;
87 /* Additional glibc-hwcaps subdirectories to search first.
88 Colon-separated list. */
89 const char *glibc_hwcaps_prepend
;
91 /* Mask for the internal glibc-hwcaps subdirectories.
92 Colon-separated list. */
93 const char *glibc_hwcaps_mask
;
97 /* True if any of the debugging options is enabled. */
100 /* True if information about versions has to be printed. */
104 /* Helper function to invoke _dl_init_paths with the right arguments
107 call_init_paths (const struct dl_main_state
*state
)
109 _dl_init_paths (state
->library_path
, state
->library_path_source
,
110 state
->glibc_hwcaps_prepend
, state
->glibc_hwcaps_mask
);
113 /* Print ld.so usage information and exit. */
114 _Noreturn
void _dl_usage (const char *argv0
, const char *wrong_option
)
117 /* Print ld.so version information and exit. */
118 _Noreturn
void _dl_version (void) attribute_hidden
;
120 /* Print ld.so --help output and exit. */
121 _Noreturn
void _dl_help (const char *argv0
, struct dl_main_state
*state
)
124 /* Print a diagnostics dump. */
125 _Noreturn
void _dl_print_diagnostics (char **environ
) attribute_hidden
;
127 #endif /* _DL_MAIN */