1 |
148 |
jeremybenn |
/* Run-time dynamic linker data structures for loaded ELF shared objects.
|
2 |
|
|
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
|
3 |
|
|
This file is part of the GNU C Library.
|
4 |
|
|
|
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.
|
9 |
|
|
|
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.
|
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU Lesser General Public
|
16 |
|
|
License along with the GNU C Library; if not, write to the Free
|
17 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
18 |
|
|
02111-1307 USA. */
|
19 |
|
|
|
20 |
|
|
#ifndef _LDSODEFS_H
|
21 |
|
|
#define _LDSODEFS_H 1
|
22 |
|
|
|
23 |
|
|
#include <features.h>
|
24 |
|
|
|
25 |
|
|
#define __need_size_t
|
26 |
|
|
#define __need_NULL
|
27 |
|
|
#include <stddef.h>
|
28 |
|
|
#include <string.h>
|
29 |
|
|
|
30 |
|
|
#include <elf.h>
|
31 |
|
|
#include <link.h>
|
32 |
|
|
#include <dl-lookupcfg.h>
|
33 |
|
|
#include <bits/libc-lock.h>
|
34 |
|
|
|
35 |
|
|
#include "dl-local.h"
|
36 |
|
|
|
37 |
|
|
__BEGIN_DECLS
|
38 |
|
|
|
39 |
|
|
/* We use this macro to refer to ELF types independent of the native wordsize.
|
40 |
|
|
`ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
|
41 |
|
|
#define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type)
|
42 |
|
|
|
43 |
|
|
#define internal_function
|
44 |
|
|
/* All references to the value of l_info[DT_PLTGOT],
|
45 |
|
|
l_info[DT_STRTAB], l_info[DT_SYMTAB], l_info[DT_RELA],
|
46 |
|
|
l_info[DT_REL], l_info[DT_JMPREL], and l_info[VERSYMIDX (DT_VERSYM)]
|
47 |
|
|
have to be accessed via the D_PTR macro. The macro is needed since for
|
48 |
|
|
most architectures the entry is already relocated - but for some not
|
49 |
|
|
and we need to relocate at access time. */
|
50 |
|
|
#ifdef DL_RO_DYN_SECTION
|
51 |
|
|
# define D_PTR(map,i) (map->i->d_un.d_ptr + map->l_addr)
|
52 |
|
|
#else
|
53 |
|
|
# define D_PTR(map,i) map->i->d_un.d_ptr
|
54 |
|
|
#endif
|
55 |
|
|
|
56 |
|
|
/* On some platforms more information than just the address of the symbol
|
57 |
|
|
is needed from the lookup functions. In this case we return the whole
|
58 |
|
|
link map. */
|
59 |
|
|
#ifdef DL_LOOKUP_RETURNS_MAP
|
60 |
|
|
typedef struct link_map *lookup_t;
|
61 |
|
|
# define LOOKUP_VALUE(map) map
|
62 |
|
|
# define LOOKUP_VALUE_ADDRESS(map) (map ? map->l_addr : 0)
|
63 |
|
|
#else
|
64 |
|
|
typedef ElfW(Addr) lookup_t;
|
65 |
|
|
# define LOOKUP_VALUE(map) map->l_addr
|
66 |
|
|
# define LOOKUP_VALUE_ADDRESS(address) address
|
67 |
|
|
#endif
|
68 |
|
|
|
69 |
|
|
/* on some architectures a pointer to a function is not just a pointer
|
70 |
|
|
to the actual code of the function but rather an architecture
|
71 |
|
|
specific descriptor. */
|
72 |
|
|
#ifndef ELF_FUNCTION_PTR_IS_SPECIAL
|
73 |
|
|
# define DL_SYMBOL_ADDRESS(map, ref) \
|
74 |
|
|
(void *) (LOOKUP_VALUE_ADDRESS (map) + ref->st_value)
|
75 |
|
|
# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
|
76 |
|
|
# define DL_DT_INIT_ADDRESS(map, start) (start)
|
77 |
|
|
# define DL_DT_FINI_ADDRESS(map, start) (start)
|
78 |
|
|
#endif
|
79 |
|
|
|
80 |
|
|
/* Unmap a loaded object, called by _dl_close (). */
|
81 |
|
|
#ifndef DL_UNMAP_IS_SPECIAL
|
82 |
|
|
# define DL_UNMAP(map) \
|
83 |
|
|
__munmap ((void *) (map)->l_map_start, \
|
84 |
|
|
(map)->l_map_end - (map)->l_map_start)
|
85 |
|
|
#endif
|
86 |
|
|
|
87 |
|
|
/* By default we do not need special support to initialize DSOs loaded
|
88 |
|
|
by statically linked binaries. */
|
89 |
|
|
#ifndef DL_STATIC_INIT
|
90 |
|
|
# define DL_STATIC_INIT(map)
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
/* Reloc type classes as returned by elf_machine_type_class().
|
94 |
|
|
ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by
|
95 |
|
|
some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be
|
96 |
|
|
satisfied by any symbol in the executable. */
|
97 |
|
|
#define ELF_RTYPE_CLASS_PLT 1
|
98 |
|
|
#define ELF_RTYPE_CLASS_COPY 2
|
99 |
|
|
|
100 |
|
|
/* ELF uses the PF_x macros to specify the segment permissions, mmap
|
101 |
|
|
uses PROT_xxx. In most cases the three macros have the values 1, 2,
|
102 |
|
|
and 3 but not in a matching order. The following macros allows
|
103 |
|
|
converting from the PF_x values to PROT_xxx values. */
|
104 |
|
|
#define PF_TO_PROT \
|
105 |
|
|
((PROT_READ << (PF_R * 4)) \
|
106 |
|
|
| (PROT_WRITE << (PF_W * 4)) \
|
107 |
|
|
| (PROT_EXEC << (PF_X * 4)) \
|
108 |
|
|
| ((PROT_READ | PROT_WRITE) << ((PF_R | PF_W) * 4)) \
|
109 |
|
|
| ((PROT_READ | PROT_EXEC) << ((PF_R | PF_X) * 4)) \
|
110 |
|
|
| ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4) \
|
111 |
|
|
| ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4)))
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
/* For the version handling we need an array with only names and their
|
115 |
|
|
hash values. */
|
116 |
|
|
struct r_found_version
|
117 |
|
|
{
|
118 |
|
|
const char *name;
|
119 |
|
|
ElfW(Word) hash;
|
120 |
|
|
|
121 |
|
|
int hidden;
|
122 |
|
|
const char *filename;
|
123 |
|
|
};
|
124 |
|
|
|
125 |
|
|
/* We want to cache information about the searches for shared objects. */
|
126 |
|
|
|
127 |
|
|
enum r_dir_status { unknown, nonexisting, existing };
|
128 |
|
|
|
129 |
|
|
struct r_search_path_elem
|
130 |
|
|
{
|
131 |
|
|
/* This link is only used in the `all_dirs' member of `r_search_path'. */
|
132 |
|
|
struct r_search_path_elem *next;
|
133 |
|
|
|
134 |
|
|
/* Strings saying where the definition came from. */
|
135 |
|
|
const char *what;
|
136 |
|
|
const char *where;
|
137 |
|
|
|
138 |
|
|
/* Basename for this search path element. The string must end with
|
139 |
|
|
a slash character. */
|
140 |
|
|
const char *dirname;
|
141 |
|
|
size_t dirnamelen;
|
142 |
|
|
|
143 |
|
|
enum r_dir_status status[0];
|
144 |
|
|
};
|
145 |
|
|
|
146 |
|
|
struct r_strlenpair
|
147 |
|
|
{
|
148 |
|
|
const char *str;
|
149 |
|
|
size_t len;
|
150 |
|
|
};
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
/* A data structure for a simple single linked list of strings. */
|
154 |
|
|
struct libname_list
|
155 |
|
|
{
|
156 |
|
|
const char *name; /* Name requested (before search). */
|
157 |
|
|
struct libname_list *next; /* Link to next name for this object. */
|
158 |
|
|
int dont_free; /* Flag whether this element should be freed
|
159 |
|
|
if the object is not entirely unloaded. */
|
160 |
|
|
};
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
/* Test whether given NAME matches any of the names of the given object. */
|
164 |
|
|
static __inline int
|
165 |
|
|
__attribute__ ((unused))
|
166 |
|
|
_dl_name_match_p (const char *__name, struct link_map *__map)
|
167 |
|
|
{
|
168 |
|
|
int __found = strcmp (__name, __map->l_name) == 0;
|
169 |
|
|
struct libname_list *__runp = __map->l_libname;
|
170 |
|
|
|
171 |
|
|
while (! __found && __runp != NULL)
|
172 |
|
|
if (strcmp (__name, __runp->name) == 0)
|
173 |
|
|
__found = 1;
|
174 |
|
|
else
|
175 |
|
|
__runp = __runp->next;
|
176 |
|
|
|
177 |
|
|
return __found;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
/* Function used as argument for `_dl_receive_error' function. The
|
181 |
|
|
arguments are the error code, error string, and the objname the
|
182 |
|
|
error occurred in. */
|
183 |
|
|
typedef void (*receiver_fct) (int, const char *, const char *);
|
184 |
|
|
|
185 |
|
|
/* Internal functions of the run-time dynamic linker.
|
186 |
|
|
These can be accessed if you link again the dynamic linker
|
187 |
|
|
as a shared library, as in `-lld' or `/lib/ld.so' explicitly;
|
188 |
|
|
but are not normally of interest to user programs.
|
189 |
|
|
|
190 |
|
|
The `-ldl' library functions in <dlfcn.h> provide a simple
|
191 |
|
|
user interface to run-time dynamic linking. */
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
/* Parameters passed to the dynamic linker. */
|
195 |
|
|
extern char **_dl_argv;
|
196 |
|
|
|
197 |
|
|
/* Cached value of `getpagesize ()'. */
|
198 |
|
|
extern size_t _dl_pagesize;
|
199 |
|
|
|
200 |
|
|
/* OS version. */
|
201 |
|
|
extern unsigned int _dl_osversion;
|
202 |
|
|
|
203 |
|
|
/* File descriptor referring to the zero-fill device. */
|
204 |
|
|
extern int _dl_zerofd;
|
205 |
|
|
|
206 |
|
|
/* Name of the shared object to be profiled (if any). */
|
207 |
|
|
extern const char *_dl_profile;
|
208 |
|
|
/* Map of shared object to be profiled. */
|
209 |
|
|
extern struct link_map *_dl_profile_map;
|
210 |
|
|
/* Filename of the output file. */
|
211 |
|
|
extern const char *_dl_profile_output;
|
212 |
|
|
|
213 |
|
|
/* If nonzero the appropriate debug information is printed. */
|
214 |
|
|
extern int _dl_debug_mask;
|
215 |
|
|
#define DL_DEBUG_LIBS (1 << 0)
|
216 |
|
|
#define DL_DEBUG_IMPCALLS (1 << 1)
|
217 |
|
|
#define DL_DEBUG_BINDINGS (1 << 2)
|
218 |
|
|
#define DL_DEBUG_SYMBOLS (1 << 3)
|
219 |
|
|
#define DL_DEBUG_VERSIONS (1 << 4)
|
220 |
|
|
#define DL_DEBUG_RELOC (1 << 5)
|
221 |
|
|
#define DL_DEBUG_FILES (1 << 6)
|
222 |
|
|
#define DL_DEBUG_STATISTICS (1 << 7)
|
223 |
|
|
/* This one is used only internally. */
|
224 |
|
|
#define DL_DEBUG_HELP (1 << 8)
|
225 |
|
|
|
226 |
|
|
/* Expect cache ID. */
|
227 |
|
|
extern int _dl_correct_cache_id;
|
228 |
|
|
|
229 |
|
|
/* Mask for hardware capabilities that are available. */
|
230 |
|
|
extern unsigned long int _dl_hwcap;
|
231 |
|
|
|
232 |
|
|
/* Mask for important hardware capabilities we honour. */
|
233 |
|
|
extern unsigned long int _dl_hwcap_mask;
|
234 |
|
|
|
235 |
|
|
/* File descriptor to write debug messages to. */
|
236 |
|
|
extern int _dl_debug_fd;
|
237 |
|
|
|
238 |
|
|
/* Names of shared object for which the RPATH should be ignored. */
|
239 |
|
|
extern const char *_dl_inhibit_rpath;
|
240 |
|
|
|
241 |
|
|
/* Nonzero if references should be treated as weak during runtime linking. */
|
242 |
|
|
extern int _dl_dynamic_weak;
|
243 |
|
|
|
244 |
|
|
/* The array with message we print as a last resort. */
|
245 |
|
|
extern const char _dl_out_of_memory[];
|
246 |
|
|
|
247 |
|
|
/* Nonzero if runtime lookups should not update the .got/.plt. */
|
248 |
|
|
extern int _dl_bind_not;
|
249 |
|
|
|
250 |
|
|
/* List of search directories. */
|
251 |
|
|
extern struct r_search_path_elem *_dl_all_dirs;
|
252 |
|
|
extern struct r_search_path_elem *_dl_init_all_dirs;
|
253 |
|
|
|
254 |
|
|
/* OS-dependent function to open the zero-fill device. */
|
255 |
|
|
extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
/* During the program run we must not modify the global data of
|
259 |
|
|
loaded shared object simultanously in two threads. Therefore we
|
260 |
|
|
protect `_dl_open' and `_dl_close' in dl-close.c.
|
261 |
|
|
|
262 |
|
|
This must be a recursive lock since the initializer function of
|
263 |
|
|
the loaded object might as well require a call to this function.
|
264 |
|
|
At this time it is not anymore a problem to modify the tables. */
|
265 |
|
|
__libc_lock_define_recursive (extern, _dl_load_lock)
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
/* Write message on the debug file descriptor. The parameters are
|
269 |
|
|
interpreted as for a `printf' call. All the lines start with a
|
270 |
|
|
tag showing the PID. */
|
271 |
|
|
extern void _dl_debug_printf (const char *fmt, ...)
|
272 |
|
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
273 |
|
|
|
274 |
|
|
/* Write message on the debug file descriptor. The parameters are
|
275 |
|
|
interpreted as for a `printf' call. All the lines buf the first
|
276 |
|
|
start with a tag showing the PID. */
|
277 |
|
|
extern void _dl_debug_printf_c (const char *fmt, ...)
|
278 |
|
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
/* Write a message on the specified descriptor FD. The parameters are
|
282 |
|
|
interpreted as for a `printf' call. */
|
283 |
|
|
extern void _dl_dprintf (int fd, const char *fmt, ...)
|
284 |
|
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
285 |
|
|
|
286 |
|
|
/* Write a message on the specified descriptor standard output. The
|
287 |
|
|
parameters are interpreted as for a `printf' call. */
|
288 |
|
|
#define _dl_printf(fmt, args...) \
|
289 |
|
|
_dl_dprintf (STDOUT_FILENO, fmt, ##args)
|
290 |
|
|
|
291 |
|
|
/* Write a message on the specified descriptor standard error. The
|
292 |
|
|
parameters are interpreted as for a `printf' call. */
|
293 |
|
|
#define _dl_error_printf(fmt, args...) \
|
294 |
|
|
_dl_dprintf (STDERR_FILENO, fmt, ##args)
|
295 |
|
|
|
296 |
|
|
/* Write a message on the specified descriptor standard error and exit
|
297 |
|
|
the program. The parameters are interpreted as for a `printf' call. */
|
298 |
|
|
#define _dl_fatal_printf(fmt, args...) \
|
299 |
|
|
do \
|
300 |
|
|
{ \
|
301 |
|
|
_dl_dprintf (STDERR_FILENO, fmt, ##args); \
|
302 |
|
|
_exit (127); \
|
303 |
|
|
} \
|
304 |
|
|
while (1)
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
/* This function is called by all the internal dynamic linker functions
|
308 |
|
|
when they encounter an error. ERRCODE is either an `errno' code or
|
309 |
|
|
zero; OBJECT is the name of the problematical shared object, or null if
|
310 |
|
|
it is a general problem; ERRSTRING is a string describing the specific
|
311 |
|
|
problem. */
|
312 |
|
|
extern void _dl_signal_error (int errcode, const char *object,
|
313 |
|
|
const char *occurred, const char *errstring)
|
314 |
|
|
internal_function
|
315 |
|
|
__attribute__ ((__noreturn__));
|
316 |
|
|
|
317 |
|
|
/* Like _dl_signal_error, but may return when called in the context of
|
318 |
|
|
_dl_receive_error. */
|
319 |
|
|
extern void _dl_signal_cerror (int errcode, const char *object,
|
320 |
|
|
const char *occation, const char *errstring)
|
321 |
|
|
internal_function;
|
322 |
|
|
|
323 |
|
|
/* Call OPERATE, receiving errors from `dl_signal_cerror'. Unlike
|
324 |
|
|
`_dl_catch_error' the operation is resumed after the OPERATE
|
325 |
|
|
function returns.
|
326 |
|
|
ARGS is passed as argument to OPERATE. */
|
327 |
|
|
extern void _dl_receive_error (receiver_fct fct, void (*operate) (void *),
|
328 |
|
|
void *args)
|
329 |
|
|
internal_function;
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
/* Open the shared object NAME and map in its segments.
|
333 |
|
|
LOADER's DT_RPATH is used in searching for NAME.
|
334 |
|
|
If the object is already opened, returns its existing map.
|
335 |
|
|
For preloaded shared objects PRELOADED is set to a non-zero
|
336 |
|
|
value to allow additional security checks. */
|
337 |
|
|
extern struct link_map *_dl_map_object (struct link_map *loader,
|
338 |
|
|
const char *name, int preloaded,
|
339 |
|
|
int type, int trace_mode, int mode)
|
340 |
|
|
internal_function;
|
341 |
|
|
|
342 |
|
|
/* Call _dl_map_object on the dependencies of MAP, and set up
|
343 |
|
|
MAP->l_searchlist. PRELOADS points to a vector of NPRELOADS previously
|
344 |
|
|
loaded objects that will be inserted into MAP->l_searchlist after MAP
|
345 |
|
|
but before its dependencies. */
|
346 |
|
|
extern void _dl_map_object_deps (struct link_map *map,
|
347 |
|
|
struct link_map **preloads,
|
348 |
|
|
unsigned int npreloads, int trace_mode)
|
349 |
|
|
internal_function;
|
350 |
|
|
|
351 |
|
|
/* Cache the locations of MAP's hash table. */
|
352 |
|
|
extern void _dl_setup_hash (struct link_map *map) internal_function;
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
/* Search loaded objects' symbol tables for a definition of the symbol
|
356 |
|
|
referred to by UNDEF. *SYM is the symbol table entry containing the
|
357 |
|
|
reference; it is replaced with the defining symbol, and the base load
|
358 |
|
|
address of the defining object is returned. SYMBOL_SCOPE is a
|
359 |
|
|
null-terminated list of object scopes to search; each object's
|
360 |
|
|
l_searchlist (i.e. the segment of the dependency tree starting at that
|
361 |
|
|
object) is searched in turn. REFERENCE_NAME should name the object
|
362 |
|
|
containing the reference; it is used in error messages.
|
363 |
|
|
TYPE_CLASS describes the type of symbol we are looking for. */
|
364 |
|
|
extern lookup_t _dl_lookup_symbol (const char *undef,
|
365 |
|
|
struct link_map *undef_map,
|
366 |
|
|
const ElfW(Sym) **sym,
|
367 |
|
|
struct r_scope_elem *symbol_scope[],
|
368 |
|
|
int type_class, int explicit)
|
369 |
|
|
internal_function;
|
370 |
|
|
|
371 |
|
|
/* Lookup versioned symbol. */
|
372 |
|
|
extern lookup_t _dl_lookup_versioned_symbol (const char *undef,
|
373 |
|
|
struct link_map *undef_map,
|
374 |
|
|
const ElfW(Sym) **sym,
|
375 |
|
|
struct r_scope_elem *symbol_scope[],
|
376 |
|
|
const struct r_found_version *version,
|
377 |
|
|
int type_class, int explicit)
|
378 |
|
|
internal_function;
|
379 |
|
|
|
380 |
|
|
/* For handling RTLD_NEXT we must be able to skip shared objects. */
|
381 |
|
|
extern lookup_t _dl_lookup_symbol_skip (const char *undef,
|
382 |
|
|
struct link_map *undef_map,
|
383 |
|
|
const ElfW(Sym) **sym,
|
384 |
|
|
struct r_scope_elem *symbol_scope[],
|
385 |
|
|
struct link_map *skip_this)
|
386 |
|
|
internal_function;
|
387 |
|
|
|
388 |
|
|
/* For handling RTLD_NEXT with versioned symbols we must be able to
|
389 |
|
|
skip shared objects. */
|
390 |
|
|
extern lookup_t _dl_lookup_versioned_symbol_skip (const char *undef,
|
391 |
|
|
struct link_map *undef_map,
|
392 |
|
|
const ElfW(Sym) **sym,
|
393 |
|
|
struct r_scope_elem *symbol_scope[],
|
394 |
|
|
const struct r_found_version *version,
|
395 |
|
|
struct link_map *skip_this)
|
396 |
|
|
internal_function;
|
397 |
|
|
|
398 |
|
|
/* Look up symbol NAME in MAP's scope and return its run-time address. */
|
399 |
|
|
extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name)
|
400 |
|
|
internal_function;
|
401 |
|
|
|
402 |
|
|
|
403 |
|
|
/* Structure describing the dynamic linker itself. */
|
404 |
|
|
extern struct link_map _dl_rtld_map;
|
405 |
|
|
/* And a pointer to the map for the main map. */
|
406 |
|
|
extern struct link_map *_dl_loaded;
|
407 |
|
|
/* Number of object in the _dl_loaded list. */
|
408 |
|
|
extern unsigned int _dl_nloaded;
|
409 |
|
|
/* Array representing global scope. */
|
410 |
|
|
extern struct r_scope_elem *_dl_global_scope[2];
|
411 |
|
|
/* Direct pointer to the searchlist of the main object. */
|
412 |
|
|
extern struct r_scope_elem *_dl_main_searchlist;
|
413 |
|
|
/* Copy of the content of `_dl_main_searchlist'. */
|
414 |
|
|
extern struct r_scope_elem _dl_initial_searchlist;
|
415 |
|
|
/* This is zero at program start to signal that the global scope map is
|
416 |
|
|
allocated by rtld. Later it keeps the size of the map. It might be
|
417 |
|
|
reset if in _dl_close if the last global object is removed. */
|
418 |
|
|
extern size_t _dl_global_scope_alloc;
|
419 |
|
|
|
420 |
|
|
/* Allocate a `struct link_map' for a new object being loaded,
|
421 |
|
|
and enter it into the _dl_main_map list. */
|
422 |
|
|
extern struct link_map *_dl_new_object (char *realname, const char *libname,
|
423 |
|
|
int type, struct link_map *loader)
|
424 |
|
|
internal_function;
|
425 |
|
|
|
426 |
|
|
/* Relocate the given object (if it hasn't already been).
|
427 |
|
|
SCOPE is passed to _dl_lookup_symbol in symbol lookups.
|
428 |
|
|
If LAZY is nonzero, don't relocate its PLT. */
|
429 |
|
|
extern void _dl_relocate_object (struct link_map *map,
|
430 |
|
|
struct r_scope_elem *scope[],
|
431 |
|
|
int lazy, int consider_profiling);
|
432 |
|
|
|
433 |
|
|
/* Call _dl_signal_error with a message about an unhandled reloc type.
|
434 |
|
|
TYPE is the result of ELFW(R_TYPE) (r_info), i.e. an R_<CPU>_* value.
|
435 |
|
|
PLT is nonzero if this was a PLT reloc; it just affects the message. */
|
436 |
|
|
extern void _dl_reloc_bad_type (struct link_map *map,
|
437 |
|
|
unsigned int type, int plt)
|
438 |
|
|
internal_function __attribute__ ((__noreturn__));
|
439 |
|
|
|
440 |
|
|
/* Check the version dependencies of all objects available through
|
441 |
|
|
MAP. If VERBOSE print some more diagnostics. */
|
442 |
|
|
extern int _dl_check_all_versions (struct link_map *map, int verbose,
|
443 |
|
|
int trace_mode)
|
444 |
|
|
internal_function;
|
445 |
|
|
|
446 |
|
|
/* Check the version dependencies for MAP. If VERBOSE print some more
|
447 |
|
|
diagnostics. */
|
448 |
|
|
extern int _dl_check_map_versions (struct link_map *map, int verbose,
|
449 |
|
|
int trace_mode)
|
450 |
|
|
internal_function;
|
451 |
|
|
|
452 |
|
|
/* Initialize the object in SCOPE by calling the constructors with
|
453 |
|
|
ARGC, ARGV, and ENV as the parameters. */
|
454 |
|
|
extern void _dl_init (struct link_map *main_map, int argc, char **argv,
|
455 |
|
|
char **env) internal_function;
|
456 |
|
|
|
457 |
|
|
/* Call the finalizer functions of all shared objects whose
|
458 |
|
|
initializer functions have completed. */
|
459 |
|
|
extern void _dl_fini (void) internal_function;
|
460 |
|
|
|
461 |
|
|
/* The dynamic linker calls this function before and having changing
|
462 |
|
|
any shared object mappings. The `r_state' member of `struct r_debug'
|
463 |
|
|
says what change is taking place. This function's address is
|
464 |
|
|
the value of the `r_brk' member. */
|
465 |
|
|
extern void _dl_debug_state (void);
|
466 |
|
|
|
467 |
|
|
/* Initialize `struct r_debug' if it has not already been done. The
|
468 |
|
|
argument is the run-time load address of the dynamic linker, to be put
|
469 |
|
|
in the `r_ldbase' member. Returns the address of the structure. */
|
470 |
|
|
extern struct r_debug *_dl_debug_initialize (ElfW(Addr) ldbase)
|
471 |
|
|
internal_function;
|
472 |
|
|
|
473 |
|
|
/* Initialize the basic data structure for the search paths. */
|
474 |
|
|
extern void _dl_init_paths (const char *library_path) internal_function;
|
475 |
|
|
|
476 |
|
|
/* Gather the information needed to install the profiling tables and start
|
477 |
|
|
the timers. */
|
478 |
|
|
extern void _dl_start_profile (struct link_map *map, const char *output_dir)
|
479 |
|
|
internal_function;
|
480 |
|
|
|
481 |
|
|
/* The actual functions used to keep book on the calls. */
|
482 |
|
|
extern void _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc);
|
483 |
|
|
|
484 |
|
|
/* This function is simply a wrapper around the _dl_mcount function
|
485 |
|
|
which does not require a FROMPC parameter since this is the
|
486 |
|
|
calling function. */
|
487 |
|
|
extern void _dl_mcount_wrapper (void *selfpc);
|
488 |
|
|
|
489 |
|
|
/* Show the members of the auxiliary array passed up from the kernel. */
|
490 |
|
|
extern void _dl_show_auxv (void) internal_function;
|
491 |
|
|
|
492 |
|
|
/* Return all environment variables starting with `LD_', one after the
|
493 |
|
|
other. */
|
494 |
|
|
extern char *_dl_next_ld_env_entry (char ***position) internal_function;
|
495 |
|
|
|
496 |
|
|
/* Return an array with the names of the important hardware capabilities. */
|
497 |
|
|
extern const struct r_strlenpair *_dl_important_hwcaps (const char *platform,
|
498 |
|
|
size_t paltform_len,
|
499 |
|
|
size_t *sz,
|
500 |
|
|
size_t *max_capstrlen)
|
501 |
|
|
internal_function;
|
502 |
|
|
|
503 |
|
|
/* Look up NAME in ld.so.cache and return the file name stored there,
|
504 |
|
|
or null if none is found. */
|
505 |
|
|
extern const char *_dl_load_cache_lookup (const char *name)
|
506 |
|
|
internal_function;
|
507 |
|
|
|
508 |
|
|
/* If the system does not support MAP_COPY we cannot leave the file open
|
509 |
|
|
all the time since this would create problems when the file is replaced.
|
510 |
|
|
Therefore we provide this function to close the file and open it again
|
511 |
|
|
once needed. */
|
512 |
|
|
extern void _dl_unload_cache (void);
|
513 |
|
|
|
514 |
|
|
/* System-dependent function to read a file's whole contents in the
|
515 |
|
|
most convenient manner available. *SIZEP gets the size of the
|
516 |
|
|
file. On error MAP_FAILED is returned. */
|
517 |
|
|
extern void *_dl_sysdep_read_whole_file (const char *file, size_t *sizep,
|
518 |
|
|
int prot)
|
519 |
|
|
internal_function;
|
520 |
|
|
|
521 |
|
|
/* System-specific function to do initial startup for the dynamic linker.
|
522 |
|
|
After this, file access calls and getenv must work. This is responsible
|
523 |
|
|
for setting __libc_enable_secure if we need to be secure (e.g. setuid),
|
524 |
|
|
and for setting _dl_argc and _dl_argv, and then calling _dl_main. */
|
525 |
|
|
extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
|
526 |
|
|
void (*dl_main) (const ElfW(Phdr) *phdr,
|
527 |
|
|
ElfW(Word) phnum,
|
528 |
|
|
ElfW(Addr) *user_entry));
|
529 |
|
|
|
530 |
|
|
extern void _dl_sysdep_start_cleanup (void)
|
531 |
|
|
internal_function;
|
532 |
|
|
|
533 |
|
|
|
534 |
|
|
__END_DECLS
|
535 |
|
|
|
536 |
|
|
#endif /* ldsodefs.h */
|