xref: /illumos-gate/usr/src/cmd/sgs/rtld/common/_rtld.h (revision 8cd45542f2a452ca0dab13d8b2d5cfa876ccbebc)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  *	Copyright (c) 1988 AT&T
237c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  *
26cce0e03bSab  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef	__RTLD_H
317c478bd9Sstevel@tonic-gate #define	__RTLD_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Common header for run-time linker.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <sys/stat.h>
407c478bd9Sstevel@tonic-gate #include <sys/avl.h>
417c478bd9Sstevel@tonic-gate #include <stdarg.h>
427c478bd9Sstevel@tonic-gate #include <synch.h>
437c478bd9Sstevel@tonic-gate #include <signal.h>
447c478bd9Sstevel@tonic-gate #include <errno.h>
457c478bd9Sstevel@tonic-gate #include <unistd.h>
467c478bd9Sstevel@tonic-gate #include <link.h>
477c478bd9Sstevel@tonic-gate #include <rtld.h>
487c478bd9Sstevel@tonic-gate #include <sgs.h>
497c478bd9Sstevel@tonic-gate #include <machdep.h>
507c478bd9Sstevel@tonic-gate #include <rtc.h>
515aefb655Srie #include <debug.h>
527c478bd9Sstevel@tonic-gate #include <msg.h>
537c478bd9Sstevel@tonic-gate #include <libc_int.h>
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
567c478bd9Sstevel@tonic-gate extern "C" {
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * Dependency search rule order.
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate #define	RPLENV		1		/* replaceable LD_LIBRARY_PATH */
637c478bd9Sstevel@tonic-gate #define	PRMENV		2		/* permanent LD_LIBRARY_PATH */
647c478bd9Sstevel@tonic-gate #define	RUNPATH		3		/* callers runpath */
657c478bd9Sstevel@tonic-gate #define	DEFAULT		4		/* default library path */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * Data structure for file class specific functions and data.
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate typedef struct fct {
727c478bd9Sstevel@tonic-gate 	int	(*fct_are_u_this)(Rej_desc *);	/* determine type of object */
737c478bd9Sstevel@tonic-gate 	ulong_t	(*fct_entry_pt)(void);		/* get entry point */
747c478bd9Sstevel@tonic-gate 	Rt_map	*(*fct_map_so)(Lm_list *, Aliste, const char *, const char *,
759aa23310Srie 		    int, int *);		/* map in a shared object */
767c478bd9Sstevel@tonic-gate 	void	(*fct_unmap_so)(Rt_map *);	/* unmap a shared object */
779aa23310Srie 	int	(*fct_needed)(Lm_list *, Aliste, Rt_map *, int *);
787c478bd9Sstevel@tonic-gate 						/* determine needed objects */
799aa23310Srie 	Sym	*(*fct_lookup_sym)(Slookup *, Rt_map **, uint_t *, int *);
807c478bd9Sstevel@tonic-gate 						/* initialize symbol lookup */
819aa23310Srie 	int	(*fct_reloc)(Rt_map *, uint_t, int *);
829aa23310Srie 						/* relocate shared object */
837c478bd9Sstevel@tonic-gate 	Pnode	*fct_dflt_dirs;			/* list of default dirs to */
847c478bd9Sstevel@tonic-gate 						/*	search */
857c478bd9Sstevel@tonic-gate 	Pnode	*fct_secure_dirs;		/* list of secure dirs to */
867c478bd9Sstevel@tonic-gate 						/*	search (set[ug]id) */
877c478bd9Sstevel@tonic-gate 	Pnode	*(*fct_fix_name)(const char *, Rt_map *, uint_t);
887c478bd9Sstevel@tonic-gate 						/* transpose name */
897c478bd9Sstevel@tonic-gate 	char	*(*fct_get_so)(const char *, const char *);
907c478bd9Sstevel@tonic-gate 						/* get shared object */
917c478bd9Sstevel@tonic-gate 	void	(*fct_dladdr)(ulong_t, Rt_map *, Dl_info *, void **, int);
927c478bd9Sstevel@tonic-gate 						/* get symbolic address */
939aa23310Srie 	Sym	*(*fct_dlsym)(Grp_hdl *, Slookup *, Rt_map **, uint_t *,
949aa23310Srie 		    int *);			/* process dlsym request */
957c478bd9Sstevel@tonic-gate 	int	(*fct_verify_vers)(const char *, Rt_map *, Rt_map *);
967c478bd9Sstevel@tonic-gate 						/* verify versioning (ELF) */
977c478bd9Sstevel@tonic-gate 	int	(*fct_set_prot)(Rt_map *, int);
987c478bd9Sstevel@tonic-gate 						/* set protection */
997c478bd9Sstevel@tonic-gate } Fct;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Return codes for util::anon_map().
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate typedef enum {
1067c478bd9Sstevel@tonic-gate 	AM_OK,			/* mmap(MAP_ANON) succeeded */
1077c478bd9Sstevel@tonic-gate 	AM_NOSUP,		/* mmap(MAP_ANON) not supported (old OS) */
1087c478bd9Sstevel@tonic-gate 	AM_ERROR		/* mmap(MAP_ANON) failed */
1097c478bd9Sstevel@tonic-gate } Am_ret;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * Macros for getting to the file class table.
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate #define	LM_ENTRY_PT(X)		((X)->rt_fct->fct_entry_pt)
1167c478bd9Sstevel@tonic-gate #define	LM_UNMAP_SO(X)		((X)->rt_fct->fct_unmap_so)
1177c478bd9Sstevel@tonic-gate #define	LM_NEEDED(X)		((X)->rt_fct->fct_needed)
1187c478bd9Sstevel@tonic-gate #define	LM_LOOKUP_SYM(X)	((X)->rt_fct->fct_lookup_sym)
1197c478bd9Sstevel@tonic-gate #define	LM_RELOC(X)		((X)->rt_fct->fct_reloc)
1207c478bd9Sstevel@tonic-gate #define	LM_DFLT_DIRS(X)		((X)->rt_fct->fct_dflt_dirs)
1217c478bd9Sstevel@tonic-gate #define	LM_SECURE_DIRS(X)	((X)->rt_fct->fct_secure_dirs)
1227c478bd9Sstevel@tonic-gate #define	LM_FIX_NAME(X)		((X)->rt_fct->fct_fix_name)
1237c478bd9Sstevel@tonic-gate #define	LM_GET_SO(X)		((X)->rt_fct->fct_get_so)
1247c478bd9Sstevel@tonic-gate #define	LM_DLADDR(X)		((X)->rt_fct->fct_dladdr)
1257c478bd9Sstevel@tonic-gate #define	LM_DLSYM(X)		((X)->rt_fct->fct_dlsym)
1267c478bd9Sstevel@tonic-gate #define	LM_VERIFY_VERS(X)	((X)->rt_fct->fct_verify_vers)
1277c478bd9Sstevel@tonic-gate #define	LM_SET_PROT(X)		((X)->rt_fct->fct_set_prot)
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * Define Alist initialization sizes.
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #define	AL_CNT_ALIAS	2		/* ALIAS() initial alist count */
1347c478bd9Sstevel@tonic-gate #define	AL_CNT_DEPENDS	10		/* DEPENDS() initial alist count */
1357c478bd9Sstevel@tonic-gate #define	AL_CNT_CALLERS	10		/* CALLERS() initial alist count */
1368521e5e6Srie #define	AL_CNT_GROUPS	4		/* GROUPS() initial alist count */
1377c478bd9Sstevel@tonic-gate #define	AL_CNT_COPYREL	10		/* COPY() initial alist count */
1387c478bd9Sstevel@tonic-gate #define	AL_CNT_LAZYFIND	10		/* elf_lazy_find_sym() initial alist */
1397c478bd9Sstevel@tonic-gate 					/*	count */
1407c478bd9Sstevel@tonic-gate #define	AL_CNT_GRPCLCT	10		/* gdp_collect() initial alist count */
1417c478bd9Sstevel@tonic-gate #define	AL_CNT_DEPCLCT	10		/* load_so() initial alist count */
1427c478bd9Sstevel@tonic-gate #define	AL_CNT_RTLDINFO	1		/* RTLDINFO() initial alist count */
1437c478bd9Sstevel@tonic-gate #define	AL_CNT_FPNODE	2		/* FPNODE() initial alist count */
1447c478bd9Sstevel@tonic-gate #define	AL_CNT_LMLISTS	8		/* lm_lists initial alist count */
1457c478bd9Sstevel@tonic-gate #define	AL_CNT_LMNOW	8		/* lm_now initial alist count */
1467c478bd9Sstevel@tonic-gate #define	AL_CNT_RELBIND	20		/* relocation binding alist count */
1477247f888Srie #define	AL_CNT_ACTAUDIT	2		/* lm_actaudit alist count */
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  * Size of buffer for building error messages.
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate #define	ERRSIZE		2048		/* MAXPATHLEN * 2 */
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate /*
1577c478bd9Sstevel@tonic-gate  * Configuration file information.
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate typedef struct config {
1607c478bd9Sstevel@tonic-gate 	const char	*c_name;
1617c478bd9Sstevel@tonic-gate 	Addr		c_bgn;
1627c478bd9Sstevel@tonic-gate 	Addr		c_end;
1637c478bd9Sstevel@tonic-gate 	Word		*c_hashtbl;
1647c478bd9Sstevel@tonic-gate 	Word		*c_hashchain;
1657c478bd9Sstevel@tonic-gate 	const char	*c_strtbl;
1667c478bd9Sstevel@tonic-gate 	Rtc_obj		*c_objtbl;
1677c478bd9Sstevel@tonic-gate 	Rtc_fltr	*c_fltr;
1687c478bd9Sstevel@tonic-gate 	Rtc_flte	*c_flte;
1697c478bd9Sstevel@tonic-gate } Config;
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * Register symbol list.
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate typedef struct reglist {
1757c478bd9Sstevel@tonic-gate 	Rt_map		*rl_lmp;	/* defining object */
1767c478bd9Sstevel@tonic-gate 	Sym		*rl_sym;	/* regsym */
1777c478bd9Sstevel@tonic-gate 	struct reglist	*rl_next;	/* next entry */
1787c478bd9Sstevel@tonic-gate } Reglist;
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * Data structure to hold interpreter information.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate typedef struct interp {
1847c478bd9Sstevel@tonic-gate 	char		*i_name;	/* interpreter name */
1857c478bd9Sstevel@tonic-gate 	caddr_t		i_faddr;	/* address interpreter is mapped at */
1867c478bd9Sstevel@tonic-gate } Interp;
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * Data structure used to keep track of copy relocations.  These relocations
1907c478bd9Sstevel@tonic-gate  * are collected during initial relocation processing and maintained on the
1917c478bd9Sstevel@tonic-gate  * COPY(lmp) list of the defining object.  Each copy list is also added to the
1927c478bd9Sstevel@tonic-gate  * COPY(lmp) of the head object (normally the application dynamic executable)
1937c478bd9Sstevel@tonic-gate  * from which they will be processed after all relocations are done.
1947c478bd9Sstevel@tonic-gate  *
1957c478bd9Sstevel@tonic-gate  * The use of RTLD_GROUP will also reference individual objects COPY(lmp) lists
1967c478bd9Sstevel@tonic-gate  * in case a bound symbol must be assigned to it actual copy relocation.
1977c478bd9Sstevel@tonic-gate  */
1987c478bd9Sstevel@tonic-gate typedef struct {
1997c478bd9Sstevel@tonic-gate 	const char	*r_name;	/* symbol name */
2007c478bd9Sstevel@tonic-gate 	Sym		*r_rsym;	/* reference symbol table entry */
2017c478bd9Sstevel@tonic-gate 	Rt_map		*r_rlmp;	/* reference link map */
2027c478bd9Sstevel@tonic-gate 	Rt_map		*r_dlmp;	/* definition link map */
2037c478bd9Sstevel@tonic-gate 	Sym		*r_dsym;	/* definition symbol table entry */
2047c478bd9Sstevel@tonic-gate 	void		*r_radd;	/* copy to address */
2057c478bd9Sstevel@tonic-gate 	const void	*r_dadd;	/* copy from address */
2067c478bd9Sstevel@tonic-gate 	ulong_t		r_size;		/* copy size bytes */
2077c478bd9Sstevel@tonic-gate } Rel_copy;
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate /*
2107c478bd9Sstevel@tonic-gate  * Data structure to hold initial file mapping information.  Used to
2117c478bd9Sstevel@tonic-gate  * communicate during initial object mapping and provide for error recovery.
2127c478bd9Sstevel@tonic-gate  */
2137c478bd9Sstevel@tonic-gate typedef struct {
2147c478bd9Sstevel@tonic-gate 	char		*fm_maddr;	/* address of initial mapping */
2157c478bd9Sstevel@tonic-gate 	size_t		fm_msize;	/* size of initial mapping */
2167c478bd9Sstevel@tonic-gate 	size_t		fm_fsize;	/* actual file size */
2177c478bd9Sstevel@tonic-gate 	ulong_t		fm_etext;	/* end of text segment */
2187c478bd9Sstevel@tonic-gate 	int		fm_mflags;	/* mapping flags */
2197c478bd9Sstevel@tonic-gate 	ulong_t		fm_hwptr;	/* hardware capabilities pointer */
2207c478bd9Sstevel@tonic-gate } Fmap;
2217c478bd9Sstevel@tonic-gate 
222a953e2b1Srie #define	FMAP_SIZE	0x8000		/* initial size to map from a file */
223a953e2b1Srie 					/* big enough to capture standard */
224a953e2b1Srie 					/* filters */
2257c478bd9Sstevel@tonic-gate /*
2267c478bd9Sstevel@tonic-gate  * Define a file descriptor, which maintains information regarding a pathname
2277c478bd9Sstevel@tonic-gate  * that has been opened and minimally inspected.
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate typedef struct {
2307c478bd9Sstevel@tonic-gate 	Rt_map		*fd_lmp;	/* existing link-map pointer */
2317c478bd9Sstevel@tonic-gate 	Fct		*fd_ftp;	/* file functions pointer */
2327c478bd9Sstevel@tonic-gate 	const char	*fd_oname;	/* original file name */
2337c478bd9Sstevel@tonic-gate 	const char	*fd_odir;	/* original directory name */
2347c478bd9Sstevel@tonic-gate 	const char	*fd_nname;	/* new file (expanded) name */
2357c478bd9Sstevel@tonic-gate 	const char	*fd_pname;	/* new path (resolved) name */
2367c478bd9Sstevel@tonic-gate 	dev_t		fd_dev;		/* file device number */
2377c478bd9Sstevel@tonic-gate 	ino_t		fd_ino;		/* file inode number */
2387c478bd9Sstevel@tonic-gate 	int		fd_fd;		/* open file descriptor */
2397c478bd9Sstevel@tonic-gate 	uint_t		fd_flags;
2407c478bd9Sstevel@tonic-gate 	avl_index_t	fd_avlwhere;	/* avl tree insertion index */
2417c478bd9Sstevel@tonic-gate 	Fmap		fd_fmap;	/* file mapping information */
2427c478bd9Sstevel@tonic-gate } Fdesc;
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate #define	FLG_FD_ALTER	0x01		/* file is an alternate */
2457c478bd9Sstevel@tonic-gate #define	FLG_FD_SLASH	0x02		/* file contains a "/" */
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * File descriptor availability flag.
2497c478bd9Sstevel@tonic-gate  */
2507c478bd9Sstevel@tonic-gate #define	FD_UNAVAIL	-1
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * Disabled filter flag.  Filter objects are referenced using their .dynamic
2547c478bd9Sstevel@tonic-gate  * index (DT_FILTER or DT_AUXILIARY).  This index is saved and used to lookup
2557c478bd9Sstevel@tonic-gate  * the required filter.  Note that 0 is a valid .dynamic index.  The caller's
2567c478bd9Sstevel@tonic-gate  * OBJFLTRNDX() element is initialized using the following flag, and should
2577c478bd9Sstevel@tonic-gate  * the filter's initialization fail, is reset to this value to indicate the
2587c478bd9Sstevel@tonic-gate  * filter is disabled.  UINT_MAX provides a convenient invalid .dynamic index.
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate #define	FLTR_DISABLED	UINT_MAX
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate /*
2637c478bd9Sstevel@tonic-gate  * Status flags for rtld_flags
2647c478bd9Sstevel@tonic-gate  */
2657c478bd9Sstevel@tonic-gate #define	RT_FL_THREADS	0x00000001	/* threads are enabled */
2667c478bd9Sstevel@tonic-gate #define	RT_FL_WARNFLTR	0x00000002	/* warn of missing filtees (ldd) */
2677c478bd9Sstevel@tonic-gate #define	RT_FL_DBNOTIF	0x00000004	/* binding activity going on */
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate #ifdef	SIEBEL_DISABLE
2707c478bd9Sstevel@tonic-gate #define	RT_FL_DISFIX_1	0x00000008	/* disable fix number 1 */
2717c478bd9Sstevel@tonic-gate #endif
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate #define	RT_FL_NOBIND	0x00000010	/* don't carry out plt binding */
2747c478bd9Sstevel@tonic-gate #define	RT_FL_NOVERSION	0x00000020	/* disable version checking */
2757c478bd9Sstevel@tonic-gate #define	RT_FL_SECURE	0x00000040	/* setuid/segid flag */
2767c478bd9Sstevel@tonic-gate #define	RT_FL_APPLIC	0x00000080	/* are we executing user code */
2777c478bd9Sstevel@tonic-gate #define	RT_FL_CONCUR	0x00000100	/* thread concurrency checks required */
2787c478bd9Sstevel@tonic-gate #define	RT_FL_CONFGEN	0x00000200	/* don't relocate initiating object */
2797c478bd9Sstevel@tonic-gate 					/*	set by crle(1). */
2807c478bd9Sstevel@tonic-gate #define	RT_FL_CONFAPP	0x00000400	/* application specific configuration */
2817c478bd9Sstevel@tonic-gate 					/*	cache required */
2827c478bd9Sstevel@tonic-gate #define	RT_FL_DEBUGGER	0x00000800	/* a debugger is monitoring us */
2839aa23310Srie #define	RT_FL_OPERATION	0x00001000	/* start recording operations */
2847c478bd9Sstevel@tonic-gate #define	RT_FL_NEWLOCALE	0x00002000	/* message locale has changed */
2857c478bd9Sstevel@tonic-gate #define	RT_FL_NOBAPLT	0x00004000	/* sparc: don't use ba plt's */
2867c478bd9Sstevel@tonic-gate #define	RT_FL_NOAUXFLTR	0x00008000	/* disable auxiliary filters */
2877c478bd9Sstevel@tonic-gate #define	RT_FL_NOCONCUR	0x00010000	/* disable thread concurrency checks */
2887c478bd9Sstevel@tonic-gate #define	RT_FL_NOAUDIT	0x00020000	/* disable auditing */
2897c478bd9Sstevel@tonic-gate #define	RT_FL_ATEXIT	0x00040000	/* we're shutting down */
2907c478bd9Sstevel@tonic-gate #define	RT_FL_SILENCERR	0x00080000	/* silence error messages */
2917c478bd9Sstevel@tonic-gate #define	RT_FL_BREADTH	0x00100000	/* use breadth-first for .init/.fini */
2927c478bd9Sstevel@tonic-gate #define	RT_FL_INITFIRST	0x00200000	/* processing a DT_INITFIRST object */
2937c478bd9Sstevel@tonic-gate #define	RT_FL_RELATIVE	0x00400000	/* relative path expansion required */
2947c478bd9Sstevel@tonic-gate #define	RT_FL_EXECNAME	0x00800000	/* AT_SUN_EXECNAME vector is avail */
2957c478bd9Sstevel@tonic-gate #define	RT_FL_DEMANGLE	0x01000000	/* demangle C++ symbol names */
2967c478bd9Sstevel@tonic-gate #define	RT_FL_NOCFG	0x02000000	/* disable config file use */
2977c478bd9Sstevel@tonic-gate #define	RT_FL_NODIRCFG	0x04000000	/* disable directory config use */
2987c478bd9Sstevel@tonic-gate #define	RT_FL_NOOBJALT	0x08000000	/* disable object alternative use */
2997c478bd9Sstevel@tonic-gate #define	RT_FL_NOENVCFG	0x10000000	/* disable config envars use */
3007c478bd9Sstevel@tonic-gate #define	RT_FL_DIRCFG	0x20000000	/* directory config info available */
3017c478bd9Sstevel@tonic-gate #define	RT_FL_OBJALT	0x40000000	/* object alternatives are available */
3027c478bd9Sstevel@tonic-gate #define	RT_FL_MEMRESV	0x80000000	/* memory reservation established */
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate /*
3057c478bd9Sstevel@tonic-gate  * Status flags for rtld_flags2
3067c478bd9Sstevel@tonic-gate  */
3075aefb655Srie #define	RT_FL2_HASAUDIT	0x00000001	/* auditing lm_list is present */
3087c478bd9Sstevel@tonic-gate #define	RT_FL2_RTLDSEEN	0x00000002	/* rtldinfo has been set */
3095aefb655Srie #define	RT_FL2_UNIFPROC	0x00000004	/* libc/libthread unified environment */
3107c478bd9Sstevel@tonic-gate #define	RT_FL2_NOMALIGN	0x00000008	/* mmap MAP_ALIGN isn't available */
3117c478bd9Sstevel@tonic-gate #define	RT_FL2_NOFLTCFG	0x00000010	/* disable config filter use */
3127c478bd9Sstevel@tonic-gate #define	RT_FL2_FLTCFG	0x00000020	/* filter config info available */
3137c478bd9Sstevel@tonic-gate #define	RT_FL2_HWCAP	0x00000040	/* hardware capabilities available */
3147c478bd9Sstevel@tonic-gate #define	RT_FL2_FTL2WARN	0x00000080	/* convert fatal to warning messages */
3157c478bd9Sstevel@tonic-gate #define	RT_FL2_BINDNOW	0x00000100	/* LD_BIND_NOW in effect */
316dffec89cSrie #define	RT_FL2_BINDLAZY	0x00000200	/* disable RTLD_NOW (and LD_BIND_NOW) */
31710a4fa49Srie #define	RT_FL2_PLMSETUP	0x00000400	/* primary link-map set up complete */
3189aa23310Srie #define	RT_FL2_BRANDED	0x00000800	/* process is branded */
3199aa23310Srie #define	RT_FL2_NOPLM	0x00001000	/* process has no primary link map */
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate /*
3227c478bd9Sstevel@tonic-gate  * Information flags for env_info.
3237c478bd9Sstevel@tonic-gate  */
3247c478bd9Sstevel@tonic-gate #define	ENV_INF_PATHCFG	0x00000001	/* replaceable LD_LIBRARY_PATH */
3257c478bd9Sstevel@tonic-gate 					/*	originates from configuration */
3267c478bd9Sstevel@tonic-gate 					/*	file */
3277c478bd9Sstevel@tonic-gate #define	ENV_INF_FLAGCFG	0x00000002	/* replaceable LD_FLAGS originates */
3287c478bd9Sstevel@tonic-gate 					/*	from configuration file */
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate /*
33110a4fa49Srie  * RTLDINFO descriptor.
33210a4fa49Srie  */
33310a4fa49Srie typedef struct {
33410a4fa49Srie 	Rt_map		*rti_lmp;	/* RTLDINFO provider */
33510a4fa49Srie 	Lc_interface	*rti_info;	/* RTLDINFO data */
33610a4fa49Srie } Rti_desc;
33710a4fa49Srie 
33810a4fa49Srie /*
33910a4fa49Srie  * Binding flags for the bindguard routines.
340*8cd45542Sraf  * These are defined in usr/src/lib/libc/inc/libc_int.h in the
341*8cd45542Sraf  * latest version of the libc/rtld runtime interface (CI_V_FIVE).
3427c478bd9Sstevel@tonic-gate  */
343*8cd45542Sraf #if !defined(CI_V_FIVE)
3447c478bd9Sstevel@tonic-gate #define	THR_FLG_RTLD	0x00000001	/* rtldlock bind_guard() flag */
345*8cd45542Sraf #define	THR_FLG_NOLOCK	0x00000000	/* no-op before CI_V_FIVE */
346*8cd45542Sraf #define	THR_FLG_REENTER	0x00000000	/* no-op before CI_V_FIVE */
347*8cd45542Sraf #endif
3487c478bd9Sstevel@tonic-gate 
3499aa23310Srie #define	ROUND(x, a)	(((int)(x) + ((int)(a) - 1)) & ~((int)(a) - 1))
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate /*
3527c478bd9Sstevel@tonic-gate  * Print buffer.
3537c478bd9Sstevel@tonic-gate  */
3547c478bd9Sstevel@tonic-gate typedef struct {
3557c478bd9Sstevel@tonic-gate 	char	*pr_buf;	/* pointer to beginning of buffer */
3567c478bd9Sstevel@tonic-gate 	char	*pr_cur;	/* pointer to next free char in buffer */
3577c478bd9Sstevel@tonic-gate 	size_t	pr_len;		/* buffer size */
3587c478bd9Sstevel@tonic-gate 	int	pr_fd;		/* output fd */
3597c478bd9Sstevel@tonic-gate } Prfbuf;
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate /*
3627c478bd9Sstevel@tonic-gate  * dlopen() handle list size.
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate #define	HDLIST_SZ	101	/* prime no. for hashing */
3657c478bd9Sstevel@tonic-gate #define	HDLIST_ORP	102	/* orphan handle list */
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate /*
3687c478bd9Sstevel@tonic-gate  * Define expansion path information.  Search paths, i.e., LD_LIBRARY_PATH,
3697c478bd9Sstevel@tonic-gate  * RPATHS, etc. are defined using la_objsearch() information (see LA_SER flags
3707c478bd9Sstevel@tonic-gate  * in link.h).  Definitions here extend the path information to other uses of
3717c478bd9Sstevel@tonic-gate  * pathname expansion, and are or'd together with any LA_SER_* flags.
3727c478bd9Sstevel@tonic-gate  */
3739aa23310Srie #define	PN_FLG_EXTLOAD	0x00001000	/* path defines extra loaded objects */
3747c478bd9Sstevel@tonic-gate 					/*	(preload, audit etc.) */
3759aa23310Srie #define	PN_FLG_UNIQUE	0x00002000	/* ensure path is unique */
3769aa23310Srie #define	PN_FLG_USED	0x00004000	/* indicate that path is used */
3779aa23310Srie #define	PN_FLG_DUPLICAT	0x00008000	/* path is a duplicate */
3787c478bd9Sstevel@tonic-gate 
3799aa23310Srie #define	PN_FLG_MASK	0x000ff000	/* mask for p_orig incorporation */
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate /*
3827c478bd9Sstevel@tonic-gate  * Define reserved path tokens.  These are used to prevent various expansions
3837c478bd9Sstevel@tonic-gate  * from occurring, and record those expansions that do.  Note that any expansion
3847c478bd9Sstevel@tonic-gate  * information is also recorded in the p_orig field of a Pnode, and thus is
3859aa23310Srie  * or'd together with any LA_SER, and PN_FLG flags.
3867c478bd9Sstevel@tonic-gate  */
3877c478bd9Sstevel@tonic-gate #define	PN_TKN_ORIGIN	0x00100000	/* $ORIGIN expansion has occurred */
3887c478bd9Sstevel@tonic-gate #define	PN_TKN_PLATFORM	0x00200000	/* $PLATFORM expansion has occurred */
3897c478bd9Sstevel@tonic-gate #define	PN_TKN_OSNAME	0x00400000	/* $OSNAME expansion has occurred */
3907c478bd9Sstevel@tonic-gate #define	PN_TKN_OSREL	0x00800000	/* $OSREL expansion has occurred */
3917c478bd9Sstevel@tonic-gate #define	PN_TKN_ISALIST	0x01000000	/* $ISALIST expansion has occurred */
3927c478bd9Sstevel@tonic-gate #define	PN_TKN_HWCAP	0x02000000	/* $HWCAP expansion has occurred */
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate #define	PN_TKN_MASK	0xfff00000	/* mask for p_orig incorporation */
3957c478bd9Sstevel@tonic-gate 
3969aa23310Srie /*
3979aa23310Srie  * Additional token expansion information.  Although these flags may be set
3989aa23310Srie  * within a token data item they are masked off with PN_TKN_MASK prior to any
3999aa23310Srie  * expansion information being recorded in a Pnode for later diagnostics.
4009aa23310Srie  */
4017c478bd9Sstevel@tonic-gate #define	TKN_NONE	0x00000001	/* no token expansion has occurred */
4027c478bd9Sstevel@tonic-gate #define	TKN_DOTSLASH	0x00000002	/* path contains a "./" */
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate  * Define _caller flags.
4067c478bd9Sstevel@tonic-gate  */
4077c478bd9Sstevel@tonic-gate #define	CL_NONE		0
4087c478bd9Sstevel@tonic-gate #define	CL_EXECDEF	1		/* supply the executable as a default */
4097c478bd9Sstevel@tonic-gate 					/* if the caller can't be determined */
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate /*
4127c478bd9Sstevel@tonic-gate  * Binding information.  Note, this is or'ed in with the DBG_BINFO flags to
4137c478bd9Sstevel@tonic-gate  * convey information regarding symbol bindings.
4147c478bd9Sstevel@tonic-gate  */
41560758829Srie #define	BINFO_REJDIRECT	0x10000		/* reject a direct binding */
41660758829Srie #define	BINFO_REJSINGLE	0x20000		/* reject a singleton binding */
41760758829Srie #define	BINFO_REJECTED	0xf0000		/* a binding has been rejected */
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate /*
4207c478bd9Sstevel@tonic-gate  * Data declarations.
4217c478bd9Sstevel@tonic-gate  */
42210a4fa49Srie extern Lc_desc		glcs[];		/* global external interfaces */
42310a4fa49Srie 
424*8cd45542Sraf extern	Rt_lock		rtldlock;	/* rtld lock */
425*8cd45542Sraf extern	int		thr_flg_nolock;
426*8cd45542Sraf extern	int		thr_flg_reenter;
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate extern List		dynlm_list;	/* dynamic list of link-maps */
4297c478bd9Sstevel@tonic-gate extern char		**environ;	/* environ pointer */
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate extern int		dyn_plt_ent_size; /* Size of dynamic plt's */
4327c478bd9Sstevel@tonic-gate extern ulong_t		at_flags;	/* machine specific file flags */
43341072f3cSrie extern const char	*procname;	/* file name of executing process */
4347c478bd9Sstevel@tonic-gate extern Rtld_db_priv	r_debug;	/* debugging information */
4357c478bd9Sstevel@tonic-gate extern char		*lasterr;	/* string describing last error */
4367c478bd9Sstevel@tonic-gate extern Interp		*interp;	/* ELF executable interpreter info */
43741072f3cSrie extern const char	*rtldname;	/* name of the dynamic linker */
4387c478bd9Sstevel@tonic-gate extern List		hdl_list[];	/* dlopen() handle list */
4397c478bd9Sstevel@tonic-gate extern size_t		syspagsz;	/* system page size */
4407c478bd9Sstevel@tonic-gate extern char		*platform; 	/* platform name */
4417c478bd9Sstevel@tonic-gate extern size_t		platform_sz; 	/* platform name string size */
4427c478bd9Sstevel@tonic-gate extern Isa_desc		*isa;		/* isalist descriptor */
4437c478bd9Sstevel@tonic-gate extern Uts_desc		*uts;		/* utsname descriptor */
4447c478bd9Sstevel@tonic-gate extern uint_t		rtld_flags;	/* status flags for RTLD */
4457c478bd9Sstevel@tonic-gate extern uint_t		rtld_flags2;	/* additional status flags for RTLD */
4467c478bd9Sstevel@tonic-gate extern Fmap		*fmap;		/* Initial file mapping info */
4477c478bd9Sstevel@tonic-gate extern uint32_t		pltcnt21d;	/* cnt of 21d PLTs */
4487c478bd9Sstevel@tonic-gate extern uint32_t		pltcnt24d;	/* cnt of 24d PLTs */
4497c478bd9Sstevel@tonic-gate extern uint32_t		pltcntu32;	/* cnt of u32 PLTs */
4507c478bd9Sstevel@tonic-gate extern uint32_t		pltcntu44;	/* cnt of u44 PLTs */
4517c478bd9Sstevel@tonic-gate extern uint32_t		pltcntfull;	/* cnt of full PLTs */
4527c478bd9Sstevel@tonic-gate extern uint32_t		pltcntfar;	/* cnt of far PLTs */
4537c478bd9Sstevel@tonic-gate extern uchar_t		search_rules[];	/* dependency search rules */
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate extern Fct		elf_fct;	/* ELF file class dependent data */
4567c478bd9Sstevel@tonic-gate 
45702ca3e02Srie #if	defined(__sparc) && !defined(__sparcv9)
4587c478bd9Sstevel@tonic-gate extern Fct		aout_fct;	/* a.out (4.x) file class dependent */
4597c478bd9Sstevel@tonic-gate 					/*	data */
4607c478bd9Sstevel@tonic-gate #endif
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate extern const char	*locale;		/* locale environment setting */
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate extern Config		*config;		/* configuration structure */
4657c478bd9Sstevel@tonic-gate extern const char	*locale;		/* locale environment setting */
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate extern const char	*rpl_audit;	/* replaceable LD_AUDIT string */
4687c478bd9Sstevel@tonic-gate extern const char	*rpl_debug;	/* replaceable LD_DEBUG string */
4697c478bd9Sstevel@tonic-gate extern const char	*rpl_ldflags;	/* replaceable LD_FLAGS string */
4707c478bd9Sstevel@tonic-gate extern const char	*rpl_libpath;	/* replaceable LD_LIBRARY string */
4717c478bd9Sstevel@tonic-gate extern Pnode		*rpl_libdirs;	/*	and its associated Pnode list */
4727c478bd9Sstevel@tonic-gate extern const char	*rpl_preload;	/* replaceable LD_PRELOAD string */
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate extern const char	*prm_audit;	/* permanent LD_AUDIT string */
4757c478bd9Sstevel@tonic-gate extern const char	*prm_debug;	/* permanent LD_DEBUG string */
4767c478bd9Sstevel@tonic-gate extern const char	*prm_ldflags;	/* permanent LD_FLAGS string */
4777c478bd9Sstevel@tonic-gate extern const char	*prm_libpath;	/* permanent LD_LIBRARY string */
4787c478bd9Sstevel@tonic-gate extern Pnode		*prm_libdirs;	/*	and its associated Pnode list */
4797c478bd9Sstevel@tonic-gate extern const char	*prm_preload;	/* permanent LD_PRELOAD string */
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate extern uint_t		env_info;	/* information regarding environment */
4827c478bd9Sstevel@tonic-gate 					/*	variables */
4837c478bd9Sstevel@tonic-gate extern int		killsig;	/* signal sent on fatal exit */
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate extern uint_t		audit_argcnt;	/* no. of stack args to copy */
4867c478bd9Sstevel@tonic-gate extern Audit_desc	*auditors;	/* global auditors */
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate extern char		**_environ;
4897c478bd9Sstevel@tonic-gate 
4907c478bd9Sstevel@tonic-gate extern const char	*dbg_file;	/* debugging directed to a file */
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate extern Reglist		*reglist;	/* list of register symbols */
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate extern const Msg	err_reject[];	/* rejection error message tables */
4957c478bd9Sstevel@tonic-gate extern const Msg	ldd_reject[];
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate extern const char	*profile_name;	/* object being profiled */
4987c478bd9Sstevel@tonic-gate extern const char	*profile_out;	/* profile output file */
4997c478bd9Sstevel@tonic-gate extern const char	*profile_lib;	/* audit library to perform profile */
5007c478bd9Sstevel@tonic-gate 
50141072f3cSrie extern Dl_argsinfo	argsinfo;	/* process argument, environment and */
50241072f3cSrie 					/*	auxv information */
50341072f3cSrie 
5047c478bd9Sstevel@tonic-gate extern const char	*err_strs[];	/* diagnostic error string headers */
5057c478bd9Sstevel@tonic-gate extern const char	*nosym_str;	/* MSG_GEN_NOSYM message cache */
5067c478bd9Sstevel@tonic-gate 
5077c478bd9Sstevel@tonic-gate extern ulong_t		hwcap;		/* hardware capabilities */
5087c478bd9Sstevel@tonic-gate extern ulong_t		sfcap;		/* software capabilities */
5097c478bd9Sstevel@tonic-gate 
5109aa23310Srie extern avl_tree_t	*nfavl;		/* not-found AVL path name tree */
5119aa23310Srie 
5127c478bd9Sstevel@tonic-gate /*
5137c478bd9Sstevel@tonic-gate  * Function declarations.
5147c478bd9Sstevel@tonic-gate  */
5157c478bd9Sstevel@tonic-gate extern void		addfree(void *, size_t);
5167c478bd9Sstevel@tonic-gate extern int		append_alias(Rt_map *, const char *, int *);
5179aa23310Srie extern int		analyze_lmc(Lm_list *, Aliste, Rt_map *, int *);
5185aefb655Srie extern Am_ret		anon_map(Lm_list *, caddr_t *, size_t, int, int);
5197c478bd9Sstevel@tonic-gate extern Fct		*are_u_this(Rej_desc *, int, struct stat *,
5207c478bd9Sstevel@tonic-gate 			    const char *);
5217c478bd9Sstevel@tonic-gate extern void		atexit_fini(void);
5227c478bd9Sstevel@tonic-gate extern int		bind_one(Rt_map *, Rt_map *, uint_t);
5237c478bd9Sstevel@tonic-gate extern int		bufprint(Prfbuf *, const char *, ...);
5245aefb655Srie extern void		call_array(Addr *, uint_t, Rt_map *, Word);
5257c478bd9Sstevel@tonic-gate extern void		call_fini(Lm_list *, Rt_map **);
5267c478bd9Sstevel@tonic-gate extern void		call_init(Rt_map **, int);
52760758829Srie extern int		callable(Rt_map *, Rt_map *, Grp_hdl *, uint_t);
5287c478bd9Sstevel@tonic-gate extern Rt_map		*_caller(caddr_t, int);
5297c478bd9Sstevel@tonic-gate extern caddr_t		caller(void);
5307c478bd9Sstevel@tonic-gate extern void		*calloc(size_t, size_t);
5317c478bd9Sstevel@tonic-gate extern void		cap_assign(Cap *, Rt_map *);
5325aefb655Srie extern const char	*_conv_reloc_type(uint_t rel);
5335aefb655Srie extern uintptr_t	dbg_setup(const char *, Dbg_desc *);
5347c478bd9Sstevel@tonic-gate extern const char	*demangle(const char *);
5357c478bd9Sstevel@tonic-gate extern int		dlclose_intn(Grp_hdl *, Rt_map *);
53602ca3e02Srie extern int		dlclose_core(Grp_hdl *, Rt_map *, Lm_list *);
5377c478bd9Sstevel@tonic-gate extern Sym		*dlsym_handle(Grp_hdl *, Slookup *, Rt_map **,
5389aa23310Srie 			    uint_t *, int *);
5397c478bd9Sstevel@tonic-gate extern void		*dlsym_intn(void *, const char *, Rt_map *, Rt_map **);
5407c478bd9Sstevel@tonic-gate extern Grp_hdl		*dlmopen_intn(Lm_list *, const char *, int, Rt_map *,
5419aa23310Srie 			    uint_t, uint_t);
5427c478bd9Sstevel@tonic-gate extern size_t		doprf(const char *, va_list, Prfbuf *);
5437c478bd9Sstevel@tonic-gate extern int		dowrite(Prfbuf *);
5447c478bd9Sstevel@tonic-gate extern void		dz_init(int);
5455aefb655Srie extern caddr_t		dz_map(Lm_list *, caddr_t, size_t, int, int);
5467c478bd9Sstevel@tonic-gate extern int		elf_config(Rt_map *, int);
5477c478bd9Sstevel@tonic-gate extern int		elf_mach_flags_check(Rej_desc *, Ehdr *);
5487c478bd9Sstevel@tonic-gate extern Rtc_obj		*elf_config_ent(const char *, Word, int, const char **);
5495aefb655Srie extern Pnode		*elf_config_flt(Lm_list *, const char *, const char *);
5507c478bd9Sstevel@tonic-gate extern ulong_t		elf_hash(const char *);
5517c478bd9Sstevel@tonic-gate extern void 		elf_reloc_bad(Rt_map *, void *, uchar_t, ulong_t,
5527c478bd9Sstevel@tonic-gate 			    ulong_t);
5537c478bd9Sstevel@tonic-gate extern ulong_t		elf_reloc_relative(ulong_t, ulong_t, ulong_t,
5547c478bd9Sstevel@tonic-gate 			    ulong_t, ulong_t, ulong_t);
5557c478bd9Sstevel@tonic-gate extern ulong_t		elf_reloc_relacount(ulong_t, ulong_t,
5567c478bd9Sstevel@tonic-gate 			    ulong_t, ulong_t);
55702ca3e02Srie extern long		elf_static_tls(Rt_map *, Sym *, void *, uchar_t, char *,
558d326b23bSrie 			    ulong_t, long);
559*8cd45542Sraf extern int		enter(int);
5607c478bd9Sstevel@tonic-gate extern uint_t		expand(char **, size_t *, char **, uint_t, uint_t,
5617c478bd9Sstevel@tonic-gate 			    Rt_map *);
5627c478bd9Sstevel@tonic-gate extern Pnode		*expand_paths(Rt_map *, const char *, uint_t, uint_t);
5638af2c5b9Srie extern void		free_hdl(Grp_hdl *, Rt_map *, uint_t);
5647c478bd9Sstevel@tonic-gate extern void		file_notfound(Lm_list *, const char *, Rt_map *,
5657c478bd9Sstevel@tonic-gate 			    uint_t, Rej_desc *);
5667c478bd9Sstevel@tonic-gate extern int		find_path(Lm_list *, const char *, Rt_map *, uint_t,
5679aa23310Srie 			    Fdesc *, Rej_desc *, int *);
5687c478bd9Sstevel@tonic-gate extern int		fpavl_insert(Lm_list *, Rt_map *, const char *,
5697c478bd9Sstevel@tonic-gate 			    avl_index_t);
5709aa23310Srie extern Rt_map		*fpavl_recorded(Lm_list *, const char *, avl_index_t *);
5717c478bd9Sstevel@tonic-gate extern void		fpavl_remove(Rt_map *);
5727c478bd9Sstevel@tonic-gate extern size_t		fullpath(Rt_map *, const char *);
5737c478bd9Sstevel@tonic-gate extern void		fmap_setup();
5747c478bd9Sstevel@tonic-gate extern void		get_lcinterface(Rt_map *, Lc_interface *);
5757c478bd9Sstevel@tonic-gate extern Lmid_t		get_linkmap_id(Lm_list *);
5767c478bd9Sstevel@tonic-gate extern Pnode		*get_next_dir(Pnode **, Rt_map *, uint_t);
5779a411307Srie extern int		hdl_add(Grp_hdl *, Rt_map *, uint_t);
5788af2c5b9Srie extern Grp_hdl		*hdl_create(Lm_list *, Rt_map *, Rt_map *, uint_t,
5798af2c5b9Srie 			    uint_t, uint_t);
58002ca3e02Srie extern int		hdl_initialize(Grp_hdl *, Rt_map *, int, int);
5817c478bd9Sstevel@tonic-gate extern int		hwcap_check(Rej_desc *, Ehdr *);
58202ca3e02Srie extern Pnode 		*hwcap_filtees(Pnode **, Aliste, Lm_cntl *, Dyninfo *,
5839aa23310Srie 			    Rt_map *, const char *, int, uint_t, int *);
5849a411307Srie extern void		is_dep_ready(Rt_map *, Rt_map *, int);
5859a411307Srie extern void		is_dep_init(Rt_map *, Rt_map *);
5869a411307Srie extern int		is_sym_interposer(Rt_map *, Sym *);
5879a411307Srie extern void		ldso_plt_init(Rt_map *);
5887c478bd9Sstevel@tonic-gate extern Listnode		*list_append(List *, const void *);
5897c478bd9Sstevel@tonic-gate extern Listnode		*list_insert(List *, const void *, Listnode *);
5907c478bd9Sstevel@tonic-gate extern Listnode		*list_prepend(List *, const void *);
5917c478bd9Sstevel@tonic-gate extern void		list_delete(List *, void *);
592*8cd45542Sraf extern void		leave(Lm_list *, int);
5937c478bd9Sstevel@tonic-gate extern void		lm_append(Lm_list *, Aliste, Rt_map *);
5947c478bd9Sstevel@tonic-gate extern void		lm_delete(Lm_list *, Rt_map *);
5957c478bd9Sstevel@tonic-gate extern void		lm_move(Lm_list *, Aliste, Aliste, Lm_cntl *,
5967c478bd9Sstevel@tonic-gate 			    Lm_cntl *);
5977247f888Srie extern void		load_completion(Rt_map *);
5987c478bd9Sstevel@tonic-gate extern Rt_map 		*load_hwcap(Lm_list *, Aliste, const char *, Rt_map *,
5999aa23310Srie 			    uint_t, uint_t, Grp_hdl **, Rej_desc *, int *);
6007247f888Srie extern Rt_map		*load_path(Lm_list *, Aliste, const char **, Rt_map *,
6019aa23310Srie 			    int, uint_t, Grp_hdl **, Fdesc *, Rej_desc *,
6029aa23310Srie 			    int *);
6037c478bd9Sstevel@tonic-gate extern Rt_map		*load_one(Lm_list *, Aliste, Pnode *, Rt_map *, int,
6049aa23310Srie 			    uint_t, Grp_hdl **, int *);
6057247f888Srie extern int		load_trace(Lm_list *, const char **, Rt_map *);
6069aa23310Srie extern void		nfavl_insert(const char *, avl_index_t);
6079aa23310Srie extern int		nfavl_recorded(const char *, avl_index_t *);
6085aefb655Srie extern caddr_t		nu_map(Lm_list *, caddr_t, size_t, int, int);
6097c478bd9Sstevel@tonic-gate extern void		*malloc(size_t);
6107c478bd9Sstevel@tonic-gate extern void		move_data(Rt_map *);
6115aefb655Srie extern int		pr_open(Lm_list *);
6127c478bd9Sstevel@tonic-gate extern void		rd_event(Lm_list *, rd_event_e, r_state_e);
6137c478bd9Sstevel@tonic-gate extern int		readenv_user(const char **, Word *, Word *, int);
6147c478bd9Sstevel@tonic-gate extern int		readenv_config(Rtc_env *, Addr, int);
61531fdd7caSab extern void		rejection_inherit(Rej_desc *, Rej_desc *);
6169aa23310Srie extern int		relocate_lmc(Lm_list *, Aliste, Rt_map *, Rt_map *,
6179aa23310Srie 			    int *);
618cce0e03bSab extern int		relocate_finish(Rt_map *, APlist *, int, int);
6197c478bd9Sstevel@tonic-gate extern void		remove_cntl(Lm_list *, Aliste);
6207c478bd9Sstevel@tonic-gate extern int		remove_hdl(Grp_hdl *, Rt_map *, int *);
62102ca3e02Srie extern void		remove_lmc(Lm_list *, Rt_map *, Lm_cntl *, Aliste,
62202ca3e02Srie 			    const char *);
6237c478bd9Sstevel@tonic-gate extern void		remove_incomplete(Lm_list *, Aliste);
6247c478bd9Sstevel@tonic-gate extern void		remove_lists(Rt_map *, int);
6257c478bd9Sstevel@tonic-gate extern void		remove_lml(Lm_list *);
6267c478bd9Sstevel@tonic-gate extern void		remove_pnode(Pnode *);
6277c478bd9Sstevel@tonic-gate extern void		remove_rej(Rej_desc *);
6287c478bd9Sstevel@tonic-gate extern void		remove_so(Lm_list *, Rt_map *);
6297c478bd9Sstevel@tonic-gate extern int		rt_cond_broadcast(Rt_cond *);
6307c478bd9Sstevel@tonic-gate extern Rt_cond		*rt_cond_create(void);
6317c478bd9Sstevel@tonic-gate extern int		rt_cond_wait(Rt_cond *, Rt_lock *);
6327c478bd9Sstevel@tonic-gate extern int		rt_bind_guard(int);
6337c478bd9Sstevel@tonic-gate extern int		rt_bind_clear(int);
63410a4fa49Srie extern int		rt_get_extern(Lm_list *, Rt_map *);
6357c478bd9Sstevel@tonic-gate extern int		rt_mutex_lock(Rt_lock *);
6367c478bd9Sstevel@tonic-gate extern int		rt_mutex_unlock(Rt_lock *);
63710a4fa49Srie extern void		rt_thr_init(Lm_list *);
6387c478bd9Sstevel@tonic-gate extern thread_t		rt_thr_self(void);
6395aefb655Srie extern void		rtld_db_dlactivity(Lm_list *);
6405aefb655Srie extern void		rtld_db_preinit(Lm_list *);
6415aefb655Srie extern void		rtld_db_postinit(Lm_list *);
6427c478bd9Sstevel@tonic-gate extern void		rtldexit(Lm_list *, int);
64341072f3cSrie extern int		rtld_getopt(char **, char ***, auxv_t **, Word *,
64441072f3cSrie 			    Word *, int);
6457c478bd9Sstevel@tonic-gate extern void		security(uid_t, uid_t, gid_t, gid_t, int);
6467c478bd9Sstevel@tonic-gate extern void		set_environ(Lm_list *);
64741072f3cSrie extern Rt_map		*setup(char **, auxv_t *, Word, char *, int, char *,
6487c478bd9Sstevel@tonic-gate 			    Dyn *, ulong_t, ulong_t, int fd, Phdr *, char *,
6497c478bd9Sstevel@tonic-gate 			    char **, int, uid_t, uid_t, gid_t, gid_t, void *,
6507c478bd9Sstevel@tonic-gate 			    int, uint_t);
651d326b23bSrie extern int		tls_assign(Lm_list *, Rt_map *, Phdr *);
65210a4fa49Srie extern void		tls_modaddrem(Rt_map *, uint_t);
65310a4fa49Srie extern int		tls_statmod(Lm_list *, Rt_map *);
6547c478bd9Sstevel@tonic-gate extern Rt_map		**tsort(Rt_map *, int, int);
6557c478bd9Sstevel@tonic-gate extern void		unused(Lm_list *);
6567c478bd9Sstevel@tonic-gate extern int		update_mode(Rt_map *, int, int);
6577c478bd9Sstevel@tonic-gate extern void		zero(caddr_t, size_t);
6587c478bd9Sstevel@tonic-gate 
65902ca3e02Srie #if	defined(__sparc)
6607c478bd9Sstevel@tonic-gate /*
6617c478bd9Sstevel@tonic-gate  * SPARC Register symbol support.
6627c478bd9Sstevel@tonic-gate  */
6637c478bd9Sstevel@tonic-gate extern int		elf_regsyms(Rt_map *);
6647c478bd9Sstevel@tonic-gate extern void		set_sparc_g1(ulong_t);
6657c478bd9Sstevel@tonic-gate extern void		set_sparc_g2(ulong_t);
6667c478bd9Sstevel@tonic-gate extern void		set_sparc_g3(ulong_t);
6677c478bd9Sstevel@tonic-gate extern void		set_sparc_g4(ulong_t);
6687c478bd9Sstevel@tonic-gate extern void		set_sparc_g5(ulong_t);
6697c478bd9Sstevel@tonic-gate extern void		set_sparc_g6(ulong_t);
6707c478bd9Sstevel@tonic-gate extern void		set_sparc_g7(ulong_t);
67102ca3e02Srie #endif
6727c478bd9Sstevel@tonic-gate 
6737c478bd9Sstevel@tonic-gate extern long		_sysconfig(int);
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6767c478bd9Sstevel@tonic-gate }
6777c478bd9Sstevel@tonic-gate #endif
6787c478bd9Sstevel@tonic-gate 
6797c478bd9Sstevel@tonic-gate #endif /* __RTLD_H */
680