xref: /titanic_51/usr/src/cmd/sgs/rtld/common/_rtld.h (revision 1a7c1b724419d3cb5fa6eea75123c6b2060ba31b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	Copyright (c) 1988 AT&T
24  *	  All Rights Reserved
25  *
26  *
27  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef	__RTLD_H
32 #define	__RTLD_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 /*
37  * Common header for run-time linker.
38  */
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #include <sys/avl.h>
42 #include <stdarg.h>
43 #include <synch.h>
44 #include <signal.h>
45 #include <errno.h>
46 #include <unistd.h>
47 #include <link.h>
48 #include <rtld.h>
49 #include <sgs.h>
50 #include <machdep.h>
51 #include <rtc.h>
52 #include <msg.h>
53 #include <libc_int.h>
54 
55 #ifdef	__cplusplus
56 extern "C" {
57 #endif
58 
59 /*
60  * Dependency search rule order.
61  */
62 #define	RPLENV		1		/* replaceable LD_LIBRARY_PATH */
63 #define	PRMENV		2		/* permanent LD_LIBRARY_PATH */
64 #define	RUNPATH		3		/* callers runpath */
65 #define	DEFAULT		4		/* default library path */
66 
67 
68 /*
69  * Data structure for file class specific functions and data.
70  */
71 typedef struct fct {
72 	int	(*fct_are_u_this)(Rej_desc *);	/* determine type of object */
73 	ulong_t	(*fct_entry_pt)(void);		/* get entry point */
74 	Rt_map	*(*fct_map_so)(Lm_list *, Aliste, const char *, const char *,
75 		    int);			/* map in a shared object */
76 	void	(*fct_unmap_so)(Rt_map *);	/* unmap a shared object */
77 	int	(*fct_needed)(Lm_list *, Aliste, Rt_map *);
78 						/* determine needed objects */
79 	Sym	*(*fct_lookup_sym)(Slookup *, Rt_map **, uint_t *);
80 						/* initialize symbol lookup */
81 	int	(*fct_reloc)(Rt_map *, uint_t);	/* relocate shared object */
82 	Pnode	*fct_dflt_dirs;			/* list of default dirs to */
83 						/*	search */
84 	Pnode	*fct_secure_dirs;		/* list of secure dirs to */
85 						/*	search (set[ug]id) */
86 	Pnode	*(*fct_fix_name)(const char *, Rt_map *, uint_t);
87 						/* transpose name */
88 	char	*(*fct_get_so)(const char *, const char *);
89 						/* get shared object */
90 	void	(*fct_dladdr)(ulong_t, Rt_map *, Dl_info *, void **, int);
91 						/* get symbolic address */
92 	Sym	*(*fct_dlsym)(Grp_hdl *, Slookup *, Rt_map **, uint_t *);
93 						/* process dlsym request */
94 	int	(*fct_verify_vers)(const char *, Rt_map *, Rt_map *);
95 						/* verify versioning (ELF) */
96 	int	(*fct_set_prot)(Rt_map *, int);
97 						/* set protection */
98 } Fct;
99 
100 
101 /*
102  * Return codes for util::anon_map().
103  */
104 typedef enum {
105 	AM_OK,			/* mmap(MAP_ANON) succeeded */
106 	AM_NOSUP,		/* mmap(MAP_ANON) not supported (old OS) */
107 	AM_ERROR		/* mmap(MAP_ANON) failed */
108 } Am_ret;
109 
110 
111 /*
112  * Macros for getting to the file class table.
113  */
114 #define	LM_ENTRY_PT(X)		((X)->rt_fct->fct_entry_pt)
115 #define	LM_UNMAP_SO(X)		((X)->rt_fct->fct_unmap_so)
116 #define	LM_NEEDED(X)		((X)->rt_fct->fct_needed)
117 #define	LM_LOOKUP_SYM(X)	((X)->rt_fct->fct_lookup_sym)
118 #define	LM_RELOC(X)		((X)->rt_fct->fct_reloc)
119 #define	LM_DFLT_DIRS(X)		((X)->rt_fct->fct_dflt_dirs)
120 #define	LM_SECURE_DIRS(X)	((X)->rt_fct->fct_secure_dirs)
121 #define	LM_FIX_NAME(X)		((X)->rt_fct->fct_fix_name)
122 #define	LM_GET_SO(X)		((X)->rt_fct->fct_get_so)
123 #define	LM_DLADDR(X)		((X)->rt_fct->fct_dladdr)
124 #define	LM_DLSYM(X)		((X)->rt_fct->fct_dlsym)
125 #define	LM_VERIFY_VERS(X)	((X)->rt_fct->fct_verify_vers)
126 #define	LM_SET_PROT(X)		((X)->rt_fct->fct_set_prot)
127 
128 
129 /*
130  * Define Alist initialization sizes.
131  */
132 #define	AL_CNT_ALIAS	2		/* ALIAS() initial alist count */
133 #define	AL_CNT_DEPENDS	10		/* DEPENDS() initial alist count */
134 #define	AL_CNT_CALLERS	10		/* CALLERS() initial alist count */
135 #define	AL_CNT_GROUPS	1		/* GROUPS() initial alist count */
136 #define	AL_CNT_COPYREL	10		/* COPY() initial alist count */
137 #define	AL_CNT_LAZYFIND	10		/* elf_lazy_find_sym() initial alist */
138 					/*	count */
139 #define	AL_CNT_GRPCLCT	10		/* gdp_collect() initial alist count */
140 #define	AL_CNT_DEPCLCT	10		/* load_so() initial alist count */
141 #define	AL_CNT_RTLDINFO	1		/* RTLDINFO() initial alist count */
142 #define	AL_CNT_FPNODE	2		/* FPNODE() initial alist count */
143 #define	AL_CNT_LMLISTS	8		/* lm_lists initial alist count */
144 #define	AL_CNT_LMNOW	8		/* lm_now initial alist count */
145 #define	AL_CNT_RELBIND	20		/* relocation binding alist count */
146 
147 
148 /*
149  * Size of buffer for building error messages.
150  */
151 #define	ERRSIZE		2048		/* MAXPATHLEN * 2 */
152 
153 
154 /*
155  * Configuration file information.
156  */
157 typedef struct config {
158 	const char	*c_name;
159 	Addr		c_bgn;
160 	Addr		c_end;
161 	Word		*c_hashtbl;
162 	Word		*c_hashchain;
163 	const char	*c_strtbl;
164 	Rtc_obj		*c_objtbl;
165 	Rtc_fltr	*c_fltr;
166 	Rtc_flte	*c_flte;
167 } Config;
168 
169 /*
170  * Register symbol list.
171  */
172 typedef struct reglist {
173 	Rt_map		*rl_lmp;	/* defining object */
174 	Sym		*rl_sym;	/* regsym */
175 	struct reglist	*rl_next;	/* next entry */
176 } Reglist;
177 
178 /*
179  * Data structure to hold interpreter information.
180  */
181 typedef struct interp {
182 	char		*i_name;	/* interpreter name */
183 	caddr_t		i_faddr;	/* address interpreter is mapped at */
184 } Interp;
185 
186 /*
187  * Data structure used to keep track of copy relocations.  These relocations
188  * are collected during initial relocation processing and maintained on the
189  * COPY(lmp) list of the defining object.  Each copy list is also added to the
190  * COPY(lmp) of the head object (normally the application dynamic executable)
191  * from which they will be processed after all relocations are done.
192  *
193  * The use of RTLD_GROUP will also reference individual objects COPY(lmp) lists
194  * in case a bound symbol must be assigned to it actual copy relocation.
195  */
196 typedef struct {
197 	const char	*r_name;	/* symbol name */
198 	Sym		*r_rsym;	/* reference symbol table entry */
199 	Rt_map		*r_rlmp;	/* reference link map */
200 	Rt_map		*r_dlmp;	/* definition link map */
201 	Sym		*r_dsym;	/* definition symbol table entry */
202 	void		*r_radd;	/* copy to address */
203 	const void	*r_dadd;	/* copy from address */
204 	ulong_t		r_size;		/* copy size bytes */
205 } Rel_copy;
206 
207 /*
208  * Data structure to hold initial file mapping information.  Used to
209  * communicate during initial object mapping and provide for error recovery.
210  */
211 typedef struct {
212 	char		*fm_maddr;	/* address of initial mapping */
213 	size_t		fm_msize;	/* size of initial mapping */
214 	size_t		fm_fsize;	/* actual file size */
215 	ulong_t		fm_etext;	/* end of text segment */
216 	int		fm_mflags;	/* mapping flags */
217 	ulong_t		fm_hwptr;	/* hardware capabilities pointer */
218 } Fmap;
219 
220 /*
221  * Define a file descriptor, which maintains information regarding a pathname
222  * that has been opened and minimally inspected.
223  */
224 typedef struct {
225 	Rt_map		*fd_lmp;	/* existing link-map pointer */
226 	Fct		*fd_ftp;	/* file functions pointer */
227 	const char	*fd_oname;	/* original file name */
228 	const char	*fd_odir;	/* original directory name */
229 	const char	*fd_nname;	/* new file (expanded) name */
230 	const char	*fd_pname;	/* new path (resolved) name */
231 	dev_t		fd_dev;		/* file device number */
232 	ino_t		fd_ino;		/* file inode number */
233 	int		fd_fd;		/* open file descriptor */
234 	uint_t		fd_flags;
235 	avl_index_t	fd_avlwhere;	/* avl tree insertion index */
236 	Fmap		fd_fmap;	/* file mapping information */
237 } Fdesc;
238 
239 #define	FLG_FD_ALTER	0x01		/* file is an alternate */
240 #define	FLG_FD_SLASH	0x02		/* file contains a "/" */
241 
242 /*
243  * File descriptor availability flag.
244  */
245 #define	FD_UNAVAIL	-1
246 
247 /*
248  * Disabled filter flag.  Filter objects are referenced using their .dynamic
249  * index (DT_FILTER or DT_AUXILIARY).  This index is saved and used to lookup
250  * the required filter.  Note that 0 is a valid .dynamic index.  The caller's
251  * OBJFLTRNDX() element is initialized using the following flag, and should
252  * the filter's initialization fail, is reset to this value to indicate the
253  * filter is disabled.  UINT_MAX provides a convenient invalid .dynamic index.
254  */
255 #define	FLTR_DISABLED	UINT_MAX
256 
257 /*
258  * Status flags for rtld_flags
259  */
260 #define	RT_FL_THREADS	0x00000001	/* threads are enabled */
261 #define	RT_FL_WARNFLTR	0x00000002	/* warn of missing filtees (ldd) */
262 #define	RT_FL_DBNOTIF	0x00000004	/* binding activity going on */
263 
264 #ifdef	SIEBEL_DISABLE
265 #define	RT_FL_DISFIX_1	0x00000008	/* disable fix number 1 */
266 #endif
267 
268 #define	RT_FL_NOBIND	0x00000010	/* don't carry out plt binding */
269 #define	RT_FL_NOVERSION	0x00000020	/* disable version checking */
270 #define	RT_FL_SECURE	0x00000040	/* setuid/segid flag */
271 #define	RT_FL_APPLIC	0x00000080	/* are we executing user code */
272 #define	RT_FL_CONCUR	0x00000100	/* thread concurrency checks required */
273 #define	RT_FL_CONFGEN	0x00000200	/* don't relocate initiating object */
274 					/*	set by crle(1). */
275 #define	RT_FL_CONFAPP	0x00000400	/* application specific configuration */
276 					/*	cache required */
277 #define	RT_FL_DEBUGGER	0x00000800	/* a debugger is monitoring us */
278 #define	RT_FL_AUNOTIF	0x00001000	/* audit activity going on */
279 #define	RT_FL_NEWLOCALE	0x00002000	/* message locale has changed */
280 #define	RT_FL_NOBAPLT	0x00004000	/* sparc: don't use ba plt's */
281 #define	RT_FL_NOAUXFLTR	0x00008000	/* disable auxiliary filters */
282 #define	RT_FL_NOCONCUR	0x00010000	/* disable thread concurrency checks */
283 #define	RT_FL_NOAUDIT	0x00020000	/* disable auditing */
284 #define	RT_FL_ATEXIT	0x00040000	/* we're shutting down */
285 #define	RT_FL_SILENCERR	0x00080000	/* silence error messages */
286 #define	RT_FL_BREADTH	0x00100000	/* use breadth-first for .init/.fini */
287 #define	RT_FL_INITFIRST	0x00200000	/* processing a DT_INITFIRST object */
288 #define	RT_FL_RELATIVE	0x00400000	/* relative path expansion required */
289 #define	RT_FL_EXECNAME	0x00800000	/* AT_SUN_EXECNAME vector is avail */
290 #define	RT_FL_DEMANGLE	0x01000000	/* demangle C++ symbol names */
291 #define	RT_FL_NOCFG	0x02000000	/* disable config file use */
292 #define	RT_FL_NODIRCFG	0x04000000	/* disable directory config use */
293 #define	RT_FL_NOOBJALT	0x08000000	/* disable object alternative use */
294 #define	RT_FL_NOENVCFG	0x10000000	/* disable config envars use */
295 #define	RT_FL_DIRCFG	0x20000000	/* directory config info available */
296 #define	RT_FL_OBJALT	0x40000000	/* object alternatives are available */
297 #define	RT_FL_MEMRESV	0x80000000	/* memory reservation established */
298 
299 /*
300  * Status flags for rtld_flags2
301  */
302 #define	RT_FL2_HASAUDIT	0x00000001	/* We have auditing lm_list */
303 #define	RT_FL2_RTLDSEEN	0x00000002	/* rtldinfo has been set */
304 #define	RT_FL2_UNIFPROC	0x00000004	/* we're running in libc/libthread */
305 					/*	Unified environment */
306 #define	RT_FL2_NOMALIGN	0x00000008	/* mmap MAP_ALIGN isn't available */
307 #define	RT_FL2_NOFLTCFG	0x00000010	/* disable config filter use */
308 #define	RT_FL2_FLTCFG	0x00000020	/* filter config info available */
309 #define	RT_FL2_HWCAP	0x00000040	/* hardware capabilities available */
310 #define	RT_FL2_FTL2WARN	0x00000080	/* convert fatal to warning messages */
311 #define	RT_FL2_BINDNOW	0x00000100	/* LD_BIND_NOW in effect */
312 
313 /*
314  * Information flags for env_info.
315  */
316 #define	ENV_INF_PATHCFG	0x00000001	/* replaceable LD_LIBRARY_PATH */
317 					/*	originates from configuration */
318 					/*	file */
319 #define	ENV_INF_FLAGCFG	0x00000002	/* replaceable LD_FLAGS originates */
320 					/*	from configuration file */
321 
322 /*
323  * Binding flags for the bindguard routines
324  */
325 #define	THR_FLG_RTLD	0x00000001	/* rtldlock bind_guard() flag */
326 #define	THR_FLG_MASK	THR_FLG_RTLD	/* mask for all THR_FLG flags */
327 
328 #define	ROUND(x, a)	(((int)(x) + ((int)(a) - 1)) & \
329 				~((int)(a) - 1))
330 
331 #define	RT_SORT_FWD	0x01		/* topological sort (.fini) */
332 #define	RT_SORT_REV	0x02		/* reverse topological sort (.init) */
333 #define	RT_SORT_DELETE	0x10		/* process FLG_RT_DELNEED objects */
334 					/*	only (called via dlclose()) */
335 
336 /*
337  * Print buffer.
338  */
339 typedef struct {
340 	char	*pr_buf;	/* pointer to beginning of buffer */
341 	char	*pr_cur;	/* pointer to next free char in buffer */
342 	size_t	pr_len;		/* buffer size */
343 	int	pr_fd;		/* output fd */
344 } Prfbuf;
345 
346 /*
347  * dlopen() handle list size.
348  */
349 #define	HDLIST_SZ	101	/* prime no. for hashing */
350 #define	HDLIST_ORP	102	/* orphan handle list */
351 
352 /*
353  * Define expansion path information.  Search paths, i.e., LD_LIBRARY_PATH,
354  * RPATHS, etc. are defined using la_objsearch() information (see LA_SER flags
355  * in link.h).  Definitions here extend the path information to other uses of
356  * pathname expansion, and are or'd together with any LA_SER_* flags.
357  */
358 #define	PN_SER_NEEDED	0x00001000	/* paths define DT_NEEDED entry */
359 #define	PN_SER_FILTEE	0x00002000	/* paths define filtees */
360 #define	PN_SER_EXTLOAD	0x00004000	/* paths define extra loaded objects */
361 					/*	(preload, audit etc.) */
362 #define	PN_SER_DLOPEN	0x00008000	/* paths define dlopen() request */
363 
364 #define	PN_SER_MASK	0x000ff000	/* mask for p_orig incorporation */
365 
366 /*
367  * Define reserved path tokens.  These are used to prevent various expansions
368  * from occurring, and record those expansions that do.  Note that any expansion
369  * information is also recorded in the p_orig field of a Pnode, and thus is
370  * or'd together with any LA_SER_* flags.
371  */
372 #define	PN_TKN_ORIGIN	0x00100000	/* $ORIGIN expansion has occurred */
373 #define	PN_TKN_PLATFORM	0x00200000	/* $PLATFORM expansion has occurred */
374 #define	PN_TKN_OSNAME	0x00400000	/* $OSNAME expansion has occurred */
375 #define	PN_TKN_OSREL	0x00800000	/* $OSREL expansion has occurred */
376 #define	PN_TKN_ISALIST	0x01000000	/* $ISALIST expansion has occurred */
377 #define	PN_TKN_HWCAP	0x02000000	/* $HWCAP expansion has occurred */
378 
379 #define	PN_TKN_MASK	0xfff00000	/* mask for p_orig incorporation */
380 
381 #define	TKN_NONE	0x00000001	/* no token expansion has occurred */
382 #define	TKN_DOTSLASH	0x00000002	/* path contains a "./" */
383 
384 /*
385  * Define alist descriptor addition return values (see hdl_add()).
386  */
387 #define	ALE_EXISTS	1		/* alist entry already exists */
388 #define	ALE_CREATE	2		/* alist entry created */
389 
390 /*
391  * Define _caller flags.
392  */
393 #define	CL_NONE		0
394 #define	CL_EXECDEF	1		/* supply the executable as a default */
395 					/* if the caller can't be determined */
396 
397 /*
398  * Binding information.  Note, this is or'ed in with the DBG_BINFO flags to
399  * convey information regarding symbol bindings.
400  */
401 #define	BINFO_DIRECTDIS	0x10000		/* a direct binding has been disabled */
402 
403 /*
404  * Data declarations.
405  */
406 extern Rt_lock		rtldlock;	/* rtld lock */
407 
408 extern List		dynlm_list;	/* dynamic list of link-maps */
409 extern char		**environ;	/* environ pointer */
410 
411 extern int		dyn_plt_ent_size; /* Size of dynamic plt's */
412 extern ulong_t		at_flags;	/* machine specific file flags */
413 extern const char	*procname;	/* file name of executing process */
414 extern Rtld_db_priv	r_debug;	/* debugging information */
415 extern char		*lasterr;	/* string describing last error */
416 extern Interp		*interp;	/* ELF executable interpreter info */
417 extern const char	*rtldname;	/* name of the dynamic linker */
418 extern List		hdl_list[];	/* dlopen() handle list */
419 extern size_t		syspagsz;	/* system page size */
420 extern char		*platform; 	/* platform name */
421 extern size_t		platform_sz; 	/* platform name string size */
422 extern Isa_desc		*isa;		/* isalist descriptor */
423 extern Uts_desc		*uts;		/* utsname descriptor */
424 extern uint_t		rtld_flags;	/* status flags for RTLD */
425 extern uint_t		rtld_flags2;	/* additional status flags for RTLD */
426 extern Fmap		*fmap;		/* Initial file mapping info */
427 extern uint32_t		pltcnt21d;	/* cnt of 21d PLTs */
428 extern uint32_t		pltcnt24d;	/* cnt of 24d PLTs */
429 extern uint32_t		pltcntu32;	/* cnt of u32 PLTs */
430 extern uint32_t		pltcntu44;	/* cnt of u44 PLTs */
431 extern uint32_t		pltcntfull;	/* cnt of full PLTs */
432 extern uint32_t		pltcntfar;	/* cnt of far PLTs */
433 extern uchar_t		search_rules[];	/* dependency search rules */
434 
435 extern Fct		elf_fct;	/* ELF file class dependent data */
436 
437 #if	defined(sparc) && !defined(__sparcv9)
438 extern Fct		aout_fct;	/* a.out (4.x) file class dependent */
439 					/*	data */
440 #endif
441 
442 extern const char	*locale;		/* locale environment setting */
443 
444 extern Config		*config;		/* configuration structure */
445 extern const char	*locale;		/* locale environment setting */
446 
447 extern const char	*rpl_audit;	/* replaceable LD_AUDIT string */
448 extern const char	*rpl_debug;	/* replaceable LD_DEBUG string */
449 extern const char	*rpl_ldflags;	/* replaceable LD_FLAGS string */
450 extern const char	*rpl_libpath;	/* replaceable LD_LIBRARY string */
451 extern Pnode		*rpl_libdirs;	/*	and its associated Pnode list */
452 extern const char	*rpl_preload;	/* replaceable LD_PRELOAD string */
453 
454 extern const char	*prm_audit;	/* permanent LD_AUDIT string */
455 extern const char	*prm_debug;	/* permanent LD_DEBUG string */
456 extern const char	*prm_ldflags;	/* permanent LD_FLAGS string */
457 extern const char	*prm_libpath;	/* permanent LD_LIBRARY string */
458 extern Pnode		*prm_libdirs;	/*	and its associated Pnode list */
459 extern const char	*prm_preload;	/* permanent LD_PRELOAD string */
460 
461 extern uint_t		env_info;	/* information regarding environment */
462 					/*	variables */
463 extern int		killsig;	/* signal sent on fatal exit */
464 
465 extern uint_t		audit_argcnt;	/* no. of stack args to copy */
466 extern Audit_desc	*auditors;	/* global auditors */
467 
468 extern char		**_environ;
469 
470 extern const char	*dbg_file;	/* debugging directed to a file */
471 
472 extern Reglist		*reglist;	/* list of register symbols */
473 
474 extern const Msg	err_reject[];	/* rejection error message tables */
475 extern const Msg	ldd_reject[];
476 
477 extern const char	*profile_name;	/* object being profiled */
478 extern const char	*profile_out;	/* profile output file */
479 extern const char	*profile_lib;	/* audit library to perform profile */
480 
481 extern Dl_argsinfo	argsinfo;	/* process argument, environment and */
482 					/*	auxv information */
483 
484 extern const char	*err_strs[];	/* diagnostic error string headers */
485 extern const char	*nosym_str;	/* MSG_GEN_NOSYM message cache */
486 
487 extern void		(*thrinit)();	/* thread initialization */
488 
489 extern ulong_t		hwcap;		/* hardware capabilities */
490 extern ulong_t		sfcap;		/* software capabilities */
491 
492 /*
493  * Function declarations.
494  */
495 extern void		addfree(void *, size_t);
496 extern void *		alist_append(Alist **, const void *, size_t, int);
497 extern int		alist_delete(Alist *, const void *, Aliste *);
498 extern int		alist_test(Alist **, void *, size_t, int);
499 extern int		append_alias(Rt_map *, const char *, int *);
500 extern int		analyze_lmc(Lm_list *, Aliste, Rt_map *);
501 extern Am_ret		anon_map(caddr_t *, size_t, int, int);
502 extern Fct		*are_u_this(Rej_desc *, int, struct stat *,
503 			    const char *);
504 extern void		atexit_fini(void);
505 extern int		bind_one(Rt_map *, Rt_map *, uint_t);
506 extern int		bufprint(Prfbuf *, const char *, ...);
507 extern void		call_array(Addr *, uint_t, Rt_map *, uint_t);
508 extern void		call_fini(Lm_list *, Rt_map **);
509 extern void		call_init(Rt_map **, int);
510 extern int		callable(Rt_map *, Rt_map *, Grp_hdl *);
511 extern Rt_map		*_caller(caddr_t, int);
512 extern caddr_t		caller(void);
513 extern void		*calloc(size_t, size_t);
514 extern void		cap_assign(Cap *, Rt_map *);
515 extern const char	*_conv_reloc_type_str(uint_t rel);
516 extern uint_t		dbg_setup(const char *);
517 extern const char	*demangle(const char *);
518 extern int		dlclose_intn(Grp_hdl *, Rt_map *);
519 extern int		dlclose_core(Grp_hdl *, Rt_map *);
520 extern Sym		*dlsym_handle(Grp_hdl *, Slookup *, Rt_map **,
521 			    uint_t *);
522 extern void		*dlsym_intn(void *, const char *, Rt_map *, Rt_map **);
523 extern Grp_hdl		*dlmopen_intn(Lm_list *, const char *, int, Rt_map *,
524 			    uint_t, uint_t, int *);
525 extern size_t		doprf(const char *, va_list, Prfbuf *);
526 extern int		dowrite(Prfbuf *);
527 extern void		dz_init(int);
528 extern caddr_t		dz_map(caddr_t, size_t, int, int);
529 extern int		elf_config(Rt_map *, int);
530 extern int		elf_mach_flags_check(Rej_desc *, Ehdr *);
531 extern Rtc_obj		*elf_config_ent(const char *, Word, int, const char **);
532 extern Pnode		*elf_config_flt(const char *, const char *);
533 extern ulong_t		elf_hash(const char *);
534 extern void 		elf_reloc_bad(Rt_map *, void *, uchar_t, ulong_t,
535 			    ulong_t);
536 extern ulong_t		elf_reloc_relative(ulong_t, ulong_t, ulong_t,
537 			    ulong_t, ulong_t, ulong_t);
538 extern ulong_t		elf_reloc_relacount(ulong_t, ulong_t,
539 			    ulong_t, ulong_t);
540 extern int		enter(void);
541 extern void		eprintf(Error, const char *, ...);
542 extern uint_t		expand(char **, size_t *, char **, uint_t, uint_t,
543 			    Rt_map *);
544 extern Pnode		*expand_paths(Rt_map *, const char *, uint_t, uint_t);
545 extern void		free_hdl(Grp_hdl *);
546 extern void		file_notfound(Lm_list *, const char *, Rt_map *,
547 			    uint_t, Rej_desc *);
548 extern int		find_path(Lm_list *, const char *, Rt_map *, uint_t,
549 			    Fdesc *, Rej_desc *);
550 extern int		fpavl_insert(Lm_list *, Rt_map *, const char *,
551 			    avl_index_t);
552 extern Rt_map		*fpavl_loaded(Lm_list *, const char *, avl_index_t *);
553 extern void		fpavl_remove(Rt_map *);
554 extern size_t		fullpath(Rt_map *, const char *);
555 extern void		fmap_setup();
556 extern void		get_lcinterface(Rt_map *, Lc_interface *);
557 extern Lmid_t		get_linkmap_id(Lm_list *);
558 extern Pnode		*get_next_dir(Pnode **, Rt_map *, uint_t);
559 int			hdl_add(Grp_hdl *, Rt_map *, uint_t);
560 Grp_hdl			*hdl_create(Lm_list *, Rt_map *, Rt_map *, uint_t);
561 int			hdl_initialize(Grp_hdl *, Rt_map *, Rt_map *, int, int);
562 extern int		hwcap_check(Rej_desc *, Ehdr *);
563 extern Pnode 		*hwcap_filtees(Pnode **, Aliste, Dyninfo *, Rt_map *,
564 			    const char *, int, uint_t);
565 void			is_dep_ready(Rt_map *, Rt_map *, int);
566 void			is_dep_init(Rt_map *, Rt_map *);
567 void			ldso_plt_init(Rt_map *);
568 extern Listnode		*list_append(List *, const void *);
569 extern Listnode		*list_insert(List *, const void *, Listnode *);
570 extern Listnode		*list_prepend(List *, const void *);
571 extern void		list_delete(List *, void *);
572 extern void		leave(Lm_list *);
573 extern void		lm_append(Lm_list *, Aliste, Rt_map *);
574 extern void		lm_delete(Lm_list *, Rt_map *);
575 extern void		lm_move(Lm_list *, Aliste, Aliste, Lm_cntl *,
576 			    Lm_cntl *);
577 extern int		lm_salvage(Lm_list *, int, Aliste);
578 extern void		load_completion(Rt_map *, Rt_map *);
579 extern Rt_map 		*load_hwcap(Lm_list *, Aliste, const char *, Rt_map *,
580 			    uint_t, uint_t, Grp_hdl **, Rej_desc *);
581 extern Rt_map		*load_path(Lm_list *, Aliste, const char *, Rt_map *,
582 			    int, uint_t, Grp_hdl **, Fdesc *, Rej_desc *);
583 extern Rt_map		*load_one(Lm_list *, Aliste, Pnode *, Rt_map *, int,
584 			    uint_t, Grp_hdl **);
585 extern const char	*load_trace(Lm_list *, const char *, Rt_map *);
586 extern caddr_t		nu_map(caddr_t, size_t, int, int);
587 extern void		*malloc(size_t);
588 extern void		move_data(Rt_map *);
589 extern int		pr_open(void);
590 extern void		rd_event(Lm_list *, rd_event_e, r_state_e);
591 extern int		readenv_user(const char **, Word *, Word *, int);
592 extern int		readenv_config(Rtc_env *, Addr, int);
593 extern void		rejection_inherit(Rej_desc *, Rej_desc *, Fdesc *);
594 extern int		relocate_lmc(Lm_list *, Aliste, Rt_map *);
595 extern int		relocate_finish(Rt_map *, Alist *, int, int);
596 extern void		remove_caller(Grp_hdl *, Rt_map *);
597 extern void		remove_cntl(Lm_list *, Aliste);
598 extern int		remove_hdl(Grp_hdl *, Rt_map *, int *);
599 extern void		remove_incomplete(Lm_list *, Aliste);
600 extern void		remove_lists(Rt_map *, int);
601 extern void		remove_lml(Lm_list *);
602 extern void		remove_pnode(Pnode *);
603 extern void		remove_rej(Rej_desc *);
604 extern void		remove_so(Lm_list *, Rt_map *);
605 extern int		rt_cond_broadcast(Rt_cond *);
606 extern Rt_cond		*rt_cond_create(void);
607 extern int		rt_cond_wait(Rt_cond *, Rt_lock *);
608 extern int		rt_bind_guard(int);
609 extern int		rt_bind_clear(int);
610 extern int		rt_mutex_lock(Rt_lock *);
611 extern int		rt_mutex_unlock(Rt_lock *);
612 extern thread_t		rt_thr_self(void);
613 extern void		rtld_db_dlactivity(void);
614 extern void		rtld_db_preinit(void);
615 extern void		rtld_db_postinit(void);
616 extern void		rtldexit(Lm_list *, int);
617 extern int		rtld_getopt(char **, char ***, auxv_t **, Word *,
618 			    Word *, int);
619 extern void		security(uid_t, uid_t, gid_t, gid_t, int);
620 extern void		set_environ(Lm_list *);
621 extern Rt_map		*setup(char **, auxv_t *, Word, char *, int, char *,
622 			    Dyn *, ulong_t, ulong_t, int fd, Phdr *, char *,
623 			    char **, int, uid_t, uid_t, gid_t, gid_t, void *,
624 			    int, uint_t);
625 extern void		tls_assign_soffset(Rt_map *);
626 extern void		tls_setroutines(Lm_list *, void *, void *, void *);
627 extern void		tls_modactivity(Rt_map *, uint_t);
628 extern int		tls_report_modules();
629 extern Rt_map		**tsort(Rt_map *, int, int);
630 extern void		unused(Lm_list *);
631 extern int		update_mode(Rt_map *, int, int);
632 extern void		zero(caddr_t, size_t);
633 
634 #if	defined(sparc)
635 /*
636  * SPARC Register symbol support.
637  */
638 extern int		elf_regsyms(Rt_map *);
639 extern void		set_sparc_g1(ulong_t);
640 extern void		set_sparc_g2(ulong_t);
641 extern void		set_sparc_g3(ulong_t);
642 extern void		set_sparc_g4(ulong_t);
643 extern void		set_sparc_g5(ulong_t);
644 extern void		set_sparc_g6(ulong_t);
645 extern void		set_sparc_g7(ulong_t);
646 #endif /* defined(sparc) */
647 
648 extern long		_sysconfig(int);
649 
650 #ifdef	__cplusplus
651 }
652 #endif
653 
654 #endif /* __RTLD_H */
655