xref: /illumos-gate/usr/src/cmd/sgs/rtld/common/_rtld.h (revision 02ca3e029e37aa98ac6717698bfdac6afe960932)
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  *
269a411307Srie  * Copyright 2007 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 *,
757c478bd9Sstevel@tonic-gate 		    int);			/* map in a shared object */
767c478bd9Sstevel@tonic-gate 	void	(*fct_unmap_so)(Rt_map *);	/* unmap a shared object */
777c478bd9Sstevel@tonic-gate 	int	(*fct_needed)(Lm_list *, Aliste, Rt_map *);
787c478bd9Sstevel@tonic-gate 						/* determine needed objects */
797c478bd9Sstevel@tonic-gate 	Sym	*(*fct_lookup_sym)(Slookup *, Rt_map **, uint_t *);
807c478bd9Sstevel@tonic-gate 						/* initialize symbol lookup */
817c478bd9Sstevel@tonic-gate 	int	(*fct_reloc)(Rt_map *, uint_t);	/* relocate shared object */
827c478bd9Sstevel@tonic-gate 	Pnode	*fct_dflt_dirs;			/* list of default dirs to */
837c478bd9Sstevel@tonic-gate 						/*	search */
847c478bd9Sstevel@tonic-gate 	Pnode	*fct_secure_dirs;		/* list of secure dirs to */
857c478bd9Sstevel@tonic-gate 						/*	search (set[ug]id) */
867c478bd9Sstevel@tonic-gate 	Pnode	*(*fct_fix_name)(const char *, Rt_map *, uint_t);
877c478bd9Sstevel@tonic-gate 						/* transpose name */
887c478bd9Sstevel@tonic-gate 	char	*(*fct_get_so)(const char *, const char *);
897c478bd9Sstevel@tonic-gate 						/* get shared object */
907c478bd9Sstevel@tonic-gate 	void	(*fct_dladdr)(ulong_t, Rt_map *, Dl_info *, void **, int);
917c478bd9Sstevel@tonic-gate 						/* get symbolic address */
927c478bd9Sstevel@tonic-gate 	Sym	*(*fct_dlsym)(Grp_hdl *, Slookup *, Rt_map **, uint_t *);
937c478bd9Sstevel@tonic-gate 						/* process dlsym request */
947c478bd9Sstevel@tonic-gate 	int	(*fct_verify_vers)(const char *, Rt_map *, Rt_map *);
957c478bd9Sstevel@tonic-gate 						/* verify versioning (ELF) */
967c478bd9Sstevel@tonic-gate 	int	(*fct_set_prot)(Rt_map *, int);
977c478bd9Sstevel@tonic-gate 						/* set protection */
987c478bd9Sstevel@tonic-gate } Fct;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * Return codes for util::anon_map().
1037c478bd9Sstevel@tonic-gate  */
1047c478bd9Sstevel@tonic-gate typedef enum {
1057c478bd9Sstevel@tonic-gate 	AM_OK,			/* mmap(MAP_ANON) succeeded */
1067c478bd9Sstevel@tonic-gate 	AM_NOSUP,		/* mmap(MAP_ANON) not supported (old OS) */
1077c478bd9Sstevel@tonic-gate 	AM_ERROR		/* mmap(MAP_ANON) failed */
1087c478bd9Sstevel@tonic-gate } Am_ret;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate  * Macros for getting to the file class table.
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate #define	LM_ENTRY_PT(X)		((X)->rt_fct->fct_entry_pt)
1157c478bd9Sstevel@tonic-gate #define	LM_UNMAP_SO(X)		((X)->rt_fct->fct_unmap_so)
1167c478bd9Sstevel@tonic-gate #define	LM_NEEDED(X)		((X)->rt_fct->fct_needed)
1177c478bd9Sstevel@tonic-gate #define	LM_LOOKUP_SYM(X)	((X)->rt_fct->fct_lookup_sym)
1187c478bd9Sstevel@tonic-gate #define	LM_RELOC(X)		((X)->rt_fct->fct_reloc)
1197c478bd9Sstevel@tonic-gate #define	LM_DFLT_DIRS(X)		((X)->rt_fct->fct_dflt_dirs)
1207c478bd9Sstevel@tonic-gate #define	LM_SECURE_DIRS(X)	((X)->rt_fct->fct_secure_dirs)
1217c478bd9Sstevel@tonic-gate #define	LM_FIX_NAME(X)		((X)->rt_fct->fct_fix_name)
1227c478bd9Sstevel@tonic-gate #define	LM_GET_SO(X)		((X)->rt_fct->fct_get_so)
1237c478bd9Sstevel@tonic-gate #define	LM_DLADDR(X)		((X)->rt_fct->fct_dladdr)
1247c478bd9Sstevel@tonic-gate #define	LM_DLSYM(X)		((X)->rt_fct->fct_dlsym)
1257c478bd9Sstevel@tonic-gate #define	LM_VERIFY_VERS(X)	((X)->rt_fct->fct_verify_vers)
1267c478bd9Sstevel@tonic-gate #define	LM_SET_PROT(X)		((X)->rt_fct->fct_set_prot)
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * Define Alist initialization sizes.
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate #define	AL_CNT_ALIAS	2		/* ALIAS() initial alist count */
1337c478bd9Sstevel@tonic-gate #define	AL_CNT_DEPENDS	10		/* DEPENDS() initial alist count */
1347c478bd9Sstevel@tonic-gate #define	AL_CNT_CALLERS	10		/* CALLERS() initial alist count */
1357c478bd9Sstevel@tonic-gate #define	AL_CNT_GROUPS	1		/* GROUPS() initial alist count */
1367c478bd9Sstevel@tonic-gate #define	AL_CNT_COPYREL	10		/* COPY() initial alist count */
1377c478bd9Sstevel@tonic-gate #define	AL_CNT_LAZYFIND	10		/* elf_lazy_find_sym() initial alist */
1387c478bd9Sstevel@tonic-gate 					/*	count */
1397c478bd9Sstevel@tonic-gate #define	AL_CNT_GRPCLCT	10		/* gdp_collect() initial alist count */
1407c478bd9Sstevel@tonic-gate #define	AL_CNT_DEPCLCT	10		/* load_so() initial alist count */
1417c478bd9Sstevel@tonic-gate #define	AL_CNT_RTLDINFO	1		/* RTLDINFO() initial alist count */
1427c478bd9Sstevel@tonic-gate #define	AL_CNT_FPNODE	2		/* FPNODE() initial alist count */
1437c478bd9Sstevel@tonic-gate #define	AL_CNT_LMLISTS	8		/* lm_lists initial alist count */
1447c478bd9Sstevel@tonic-gate #define	AL_CNT_LMNOW	8		/* lm_now initial alist count */
1457c478bd9Sstevel@tonic-gate #define	AL_CNT_RELBIND	20		/* relocation binding alist count */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * Size of buffer for building error messages.
1507c478bd9Sstevel@tonic-gate  */
1517c478bd9Sstevel@tonic-gate #define	ERRSIZE		2048		/* MAXPATHLEN * 2 */
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * Configuration file information.
1567c478bd9Sstevel@tonic-gate  */
1577c478bd9Sstevel@tonic-gate typedef struct config {
1587c478bd9Sstevel@tonic-gate 	const char	*c_name;
1597c478bd9Sstevel@tonic-gate 	Addr		c_bgn;
1607c478bd9Sstevel@tonic-gate 	Addr		c_end;
1617c478bd9Sstevel@tonic-gate 	Word		*c_hashtbl;
1627c478bd9Sstevel@tonic-gate 	Word		*c_hashchain;
1637c478bd9Sstevel@tonic-gate 	const char	*c_strtbl;
1647c478bd9Sstevel@tonic-gate 	Rtc_obj		*c_objtbl;
1657c478bd9Sstevel@tonic-gate 	Rtc_fltr	*c_fltr;
1667c478bd9Sstevel@tonic-gate 	Rtc_flte	*c_flte;
1677c478bd9Sstevel@tonic-gate } Config;
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * Register symbol list.
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate typedef struct reglist {
1737c478bd9Sstevel@tonic-gate 	Rt_map		*rl_lmp;	/* defining object */
1747c478bd9Sstevel@tonic-gate 	Sym		*rl_sym;	/* regsym */
1757c478bd9Sstevel@tonic-gate 	struct reglist	*rl_next;	/* next entry */
1767c478bd9Sstevel@tonic-gate } Reglist;
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate /*
1797c478bd9Sstevel@tonic-gate  * Data structure to hold interpreter information.
1807c478bd9Sstevel@tonic-gate  */
1817c478bd9Sstevel@tonic-gate typedef struct interp {
1827c478bd9Sstevel@tonic-gate 	char		*i_name;	/* interpreter name */
1837c478bd9Sstevel@tonic-gate 	caddr_t		i_faddr;	/* address interpreter is mapped at */
1847c478bd9Sstevel@tonic-gate } Interp;
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate /*
1877c478bd9Sstevel@tonic-gate  * Data structure used to keep track of copy relocations.  These relocations
1887c478bd9Sstevel@tonic-gate  * are collected during initial relocation processing and maintained on the
1897c478bd9Sstevel@tonic-gate  * COPY(lmp) list of the defining object.  Each copy list is also added to the
1907c478bd9Sstevel@tonic-gate  * COPY(lmp) of the head object (normally the application dynamic executable)
1917c478bd9Sstevel@tonic-gate  * from which they will be processed after all relocations are done.
1927c478bd9Sstevel@tonic-gate  *
1937c478bd9Sstevel@tonic-gate  * The use of RTLD_GROUP will also reference individual objects COPY(lmp) lists
1947c478bd9Sstevel@tonic-gate  * in case a bound symbol must be assigned to it actual copy relocation.
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate typedef struct {
1977c478bd9Sstevel@tonic-gate 	const char	*r_name;	/* symbol name */
1987c478bd9Sstevel@tonic-gate 	Sym		*r_rsym;	/* reference symbol table entry */
1997c478bd9Sstevel@tonic-gate 	Rt_map		*r_rlmp;	/* reference link map */
2007c478bd9Sstevel@tonic-gate 	Rt_map		*r_dlmp;	/* definition link map */
2017c478bd9Sstevel@tonic-gate 	Sym		*r_dsym;	/* definition symbol table entry */
2027c478bd9Sstevel@tonic-gate 	void		*r_radd;	/* copy to address */
2037c478bd9Sstevel@tonic-gate 	const void	*r_dadd;	/* copy from address */
2047c478bd9Sstevel@tonic-gate 	ulong_t		r_size;		/* copy size bytes */
2057c478bd9Sstevel@tonic-gate } Rel_copy;
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate /*
2087c478bd9Sstevel@tonic-gate  * Data structure to hold initial file mapping information.  Used to
2097c478bd9Sstevel@tonic-gate  * communicate during initial object mapping and provide for error recovery.
2107c478bd9Sstevel@tonic-gate  */
2117c478bd9Sstevel@tonic-gate typedef struct {
2127c478bd9Sstevel@tonic-gate 	char		*fm_maddr;	/* address of initial mapping */
2137c478bd9Sstevel@tonic-gate 	size_t		fm_msize;	/* size of initial mapping */
2147c478bd9Sstevel@tonic-gate 	size_t		fm_fsize;	/* actual file size */
2157c478bd9Sstevel@tonic-gate 	ulong_t		fm_etext;	/* end of text segment */
2167c478bd9Sstevel@tonic-gate 	int		fm_mflags;	/* mapping flags */
2177c478bd9Sstevel@tonic-gate 	ulong_t		fm_hwptr;	/* hardware capabilities pointer */
2187c478bd9Sstevel@tonic-gate } Fmap;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /*
2217c478bd9Sstevel@tonic-gate  * Define a file descriptor, which maintains information regarding a pathname
2227c478bd9Sstevel@tonic-gate  * that has been opened and minimally inspected.
2237c478bd9Sstevel@tonic-gate  */
2247c478bd9Sstevel@tonic-gate typedef struct {
2257c478bd9Sstevel@tonic-gate 	Rt_map		*fd_lmp;	/* existing link-map pointer */
2267c478bd9Sstevel@tonic-gate 	Fct		*fd_ftp;	/* file functions pointer */
2277c478bd9Sstevel@tonic-gate 	const char	*fd_oname;	/* original file name */
2287c478bd9Sstevel@tonic-gate 	const char	*fd_odir;	/* original directory name */
2297c478bd9Sstevel@tonic-gate 	const char	*fd_nname;	/* new file (expanded) name */
2307c478bd9Sstevel@tonic-gate 	const char	*fd_pname;	/* new path (resolved) name */
2317c478bd9Sstevel@tonic-gate 	dev_t		fd_dev;		/* file device number */
2327c478bd9Sstevel@tonic-gate 	ino_t		fd_ino;		/* file inode number */
2337c478bd9Sstevel@tonic-gate 	int		fd_fd;		/* open file descriptor */
2347c478bd9Sstevel@tonic-gate 	uint_t		fd_flags;
2357c478bd9Sstevel@tonic-gate 	avl_index_t	fd_avlwhere;	/* avl tree insertion index */
2367c478bd9Sstevel@tonic-gate 	Fmap		fd_fmap;	/* file mapping information */
2377c478bd9Sstevel@tonic-gate } Fdesc;
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate #define	FLG_FD_ALTER	0x01		/* file is an alternate */
2407c478bd9Sstevel@tonic-gate #define	FLG_FD_SLASH	0x02		/* file contains a "/" */
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate  * File descriptor availability flag.
2447c478bd9Sstevel@tonic-gate  */
2457c478bd9Sstevel@tonic-gate #define	FD_UNAVAIL	-1
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * Disabled filter flag.  Filter objects are referenced using their .dynamic
2497c478bd9Sstevel@tonic-gate  * index (DT_FILTER or DT_AUXILIARY).  This index is saved and used to lookup
2507c478bd9Sstevel@tonic-gate  * the required filter.  Note that 0 is a valid .dynamic index.  The caller's
2517c478bd9Sstevel@tonic-gate  * OBJFLTRNDX() element is initialized using the following flag, and should
2527c478bd9Sstevel@tonic-gate  * the filter's initialization fail, is reset to this value to indicate the
2537c478bd9Sstevel@tonic-gate  * filter is disabled.  UINT_MAX provides a convenient invalid .dynamic index.
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate #define	FLTR_DISABLED	UINT_MAX
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /*
2587c478bd9Sstevel@tonic-gate  * Status flags for rtld_flags
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate #define	RT_FL_THREADS	0x00000001	/* threads are enabled */
2617c478bd9Sstevel@tonic-gate #define	RT_FL_WARNFLTR	0x00000002	/* warn of missing filtees (ldd) */
2627c478bd9Sstevel@tonic-gate #define	RT_FL_DBNOTIF	0x00000004	/* binding activity going on */
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate #ifdef	SIEBEL_DISABLE
2657c478bd9Sstevel@tonic-gate #define	RT_FL_DISFIX_1	0x00000008	/* disable fix number 1 */
2667c478bd9Sstevel@tonic-gate #endif
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate #define	RT_FL_NOBIND	0x00000010	/* don't carry out plt binding */
2697c478bd9Sstevel@tonic-gate #define	RT_FL_NOVERSION	0x00000020	/* disable version checking */
2707c478bd9Sstevel@tonic-gate #define	RT_FL_SECURE	0x00000040	/* setuid/segid flag */
2717c478bd9Sstevel@tonic-gate #define	RT_FL_APPLIC	0x00000080	/* are we executing user code */
2727c478bd9Sstevel@tonic-gate #define	RT_FL_CONCUR	0x00000100	/* thread concurrency checks required */
2737c478bd9Sstevel@tonic-gate #define	RT_FL_CONFGEN	0x00000200	/* don't relocate initiating object */
2747c478bd9Sstevel@tonic-gate 					/*	set by crle(1). */
2757c478bd9Sstevel@tonic-gate #define	RT_FL_CONFAPP	0x00000400	/* application specific configuration */
2767c478bd9Sstevel@tonic-gate 					/*	cache required */
2777c478bd9Sstevel@tonic-gate #define	RT_FL_DEBUGGER	0x00000800	/* a debugger is monitoring us */
2787c478bd9Sstevel@tonic-gate #define	RT_FL_AUNOTIF	0x00001000	/* audit activity going on */
2797c478bd9Sstevel@tonic-gate #define	RT_FL_NEWLOCALE	0x00002000	/* message locale has changed */
2807c478bd9Sstevel@tonic-gate #define	RT_FL_NOBAPLT	0x00004000	/* sparc: don't use ba plt's */
2817c478bd9Sstevel@tonic-gate #define	RT_FL_NOAUXFLTR	0x00008000	/* disable auxiliary filters */
2827c478bd9Sstevel@tonic-gate #define	RT_FL_NOCONCUR	0x00010000	/* disable thread concurrency checks */
2837c478bd9Sstevel@tonic-gate #define	RT_FL_NOAUDIT	0x00020000	/* disable auditing */
2847c478bd9Sstevel@tonic-gate #define	RT_FL_ATEXIT	0x00040000	/* we're shutting down */
2857c478bd9Sstevel@tonic-gate #define	RT_FL_SILENCERR	0x00080000	/* silence error messages */
2867c478bd9Sstevel@tonic-gate #define	RT_FL_BREADTH	0x00100000	/* use breadth-first for .init/.fini */
2877c478bd9Sstevel@tonic-gate #define	RT_FL_INITFIRST	0x00200000	/* processing a DT_INITFIRST object */
2887c478bd9Sstevel@tonic-gate #define	RT_FL_RELATIVE	0x00400000	/* relative path expansion required */
2897c478bd9Sstevel@tonic-gate #define	RT_FL_EXECNAME	0x00800000	/* AT_SUN_EXECNAME vector is avail */
2907c478bd9Sstevel@tonic-gate #define	RT_FL_DEMANGLE	0x01000000	/* demangle C++ symbol names */
2917c478bd9Sstevel@tonic-gate #define	RT_FL_NOCFG	0x02000000	/* disable config file use */
2927c478bd9Sstevel@tonic-gate #define	RT_FL_NODIRCFG	0x04000000	/* disable directory config use */
2937c478bd9Sstevel@tonic-gate #define	RT_FL_NOOBJALT	0x08000000	/* disable object alternative use */
2947c478bd9Sstevel@tonic-gate #define	RT_FL_NOENVCFG	0x10000000	/* disable config envars use */
2957c478bd9Sstevel@tonic-gate #define	RT_FL_DIRCFG	0x20000000	/* directory config info available */
2967c478bd9Sstevel@tonic-gate #define	RT_FL_OBJALT	0x40000000	/* object alternatives are available */
2977c478bd9Sstevel@tonic-gate #define	RT_FL_MEMRESV	0x80000000	/* memory reservation established */
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate /*
3007c478bd9Sstevel@tonic-gate  * Status flags for rtld_flags2
3017c478bd9Sstevel@tonic-gate  */
3025aefb655Srie #define	RT_FL2_HASAUDIT	0x00000001	/* auditing lm_list is present */
3037c478bd9Sstevel@tonic-gate #define	RT_FL2_RTLDSEEN	0x00000002	/* rtldinfo has been set */
3045aefb655Srie #define	RT_FL2_UNIFPROC	0x00000004	/* libc/libthread unified environment */
3057c478bd9Sstevel@tonic-gate #define	RT_FL2_NOMALIGN	0x00000008	/* mmap MAP_ALIGN isn't available */
3067c478bd9Sstevel@tonic-gate #define	RT_FL2_NOFLTCFG	0x00000010	/* disable config filter use */
3077c478bd9Sstevel@tonic-gate #define	RT_FL2_FLTCFG	0x00000020	/* filter config info available */
3087c478bd9Sstevel@tonic-gate #define	RT_FL2_HWCAP	0x00000040	/* hardware capabilities available */
3097c478bd9Sstevel@tonic-gate #define	RT_FL2_FTL2WARN	0x00000080	/* convert fatal to warning messages */
3107c478bd9Sstevel@tonic-gate #define	RT_FL2_BINDNOW	0x00000100	/* LD_BIND_NOW in effect */
311dffec89cSrie #define	RT_FL2_BINDLAZY	0x00000200	/* disable RTLD_NOW (and LD_BIND_NOW) */
31210a4fa49Srie #define	RT_FL2_PLMSETUP	0x00000400	/* primary link-map set up complete */
3139acbbeafSnn #define	RT_FL2_BRANDED	0x00000800	/* Process is branded */
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate /*
3167c478bd9Sstevel@tonic-gate  * Information flags for env_info.
3177c478bd9Sstevel@tonic-gate  */
3187c478bd9Sstevel@tonic-gate #define	ENV_INF_PATHCFG	0x00000001	/* replaceable LD_LIBRARY_PATH */
3197c478bd9Sstevel@tonic-gate 					/*	originates from configuration */
3207c478bd9Sstevel@tonic-gate 					/*	file */
3217c478bd9Sstevel@tonic-gate #define	ENV_INF_FLAGCFG	0x00000002	/* replaceable LD_FLAGS originates */
3227c478bd9Sstevel@tonic-gate 					/*	from configuration file */
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate /*
32510a4fa49Srie  * RTLDINFO descriptor.
32610a4fa49Srie  */
32710a4fa49Srie typedef struct {
32810a4fa49Srie 	Rt_map		*rti_lmp;	/* RTLDINFO provider */
32910a4fa49Srie 	Lc_interface	*rti_info;	/* RTLDINFO data */
33010a4fa49Srie } Rti_desc;
33110a4fa49Srie 
33210a4fa49Srie /*
33310a4fa49Srie  * Binding flags for the bindguard routines.
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate #define	THR_FLG_RTLD	0x00000001	/* rtldlock bind_guard() flag */
3367c478bd9Sstevel@tonic-gate #define	THR_FLG_MASK	THR_FLG_RTLD	/* mask for all THR_FLG flags */
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate #define	ROUND(x, a)	(((int)(x) + ((int)(a) - 1)) & \
3397c478bd9Sstevel@tonic-gate 				~((int)(a) - 1))
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate /*
3427c478bd9Sstevel@tonic-gate  * Print buffer.
3437c478bd9Sstevel@tonic-gate  */
3447c478bd9Sstevel@tonic-gate typedef struct {
3457c478bd9Sstevel@tonic-gate 	char	*pr_buf;	/* pointer to beginning of buffer */
3467c478bd9Sstevel@tonic-gate 	char	*pr_cur;	/* pointer to next free char in buffer */
3477c478bd9Sstevel@tonic-gate 	size_t	pr_len;		/* buffer size */
3487c478bd9Sstevel@tonic-gate 	int	pr_fd;		/* output fd */
3497c478bd9Sstevel@tonic-gate } Prfbuf;
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate /*
3527c478bd9Sstevel@tonic-gate  * dlopen() handle list size.
3537c478bd9Sstevel@tonic-gate  */
3547c478bd9Sstevel@tonic-gate #define	HDLIST_SZ	101	/* prime no. for hashing */
3557c478bd9Sstevel@tonic-gate #define	HDLIST_ORP	102	/* orphan handle list */
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate  * Define expansion path information.  Search paths, i.e., LD_LIBRARY_PATH,
3597c478bd9Sstevel@tonic-gate  * RPATHS, etc. are defined using la_objsearch() information (see LA_SER flags
3607c478bd9Sstevel@tonic-gate  * in link.h).  Definitions here extend the path information to other uses of
3617c478bd9Sstevel@tonic-gate  * pathname expansion, and are or'd together with any LA_SER_* flags.
3627c478bd9Sstevel@tonic-gate  */
3637c478bd9Sstevel@tonic-gate #define	PN_SER_NEEDED	0x00001000	/* paths define DT_NEEDED entry */
3647c478bd9Sstevel@tonic-gate #define	PN_SER_FILTEE	0x00002000	/* paths define filtees */
3657c478bd9Sstevel@tonic-gate #define	PN_SER_EXTLOAD	0x00004000	/* paths define extra loaded objects */
3667c478bd9Sstevel@tonic-gate 					/*	(preload, audit etc.) */
3677c478bd9Sstevel@tonic-gate #define	PN_SER_DLOPEN	0x00008000	/* paths define dlopen() request */
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate #define	PN_SER_MASK	0x000ff000	/* mask for p_orig incorporation */
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate /*
3727c478bd9Sstevel@tonic-gate  * Define reserved path tokens.  These are used to prevent various expansions
3737c478bd9Sstevel@tonic-gate  * from occurring, and record those expansions that do.  Note that any expansion
3747c478bd9Sstevel@tonic-gate  * information is also recorded in the p_orig field of a Pnode, and thus is
3757c478bd9Sstevel@tonic-gate  * or'd together with any LA_SER_* flags.
3767c478bd9Sstevel@tonic-gate  */
3777c478bd9Sstevel@tonic-gate #define	PN_TKN_ORIGIN	0x00100000	/* $ORIGIN expansion has occurred */
3787c478bd9Sstevel@tonic-gate #define	PN_TKN_PLATFORM	0x00200000	/* $PLATFORM expansion has occurred */
3797c478bd9Sstevel@tonic-gate #define	PN_TKN_OSNAME	0x00400000	/* $OSNAME expansion has occurred */
3807c478bd9Sstevel@tonic-gate #define	PN_TKN_OSREL	0x00800000	/* $OSREL expansion has occurred */
3817c478bd9Sstevel@tonic-gate #define	PN_TKN_ISALIST	0x01000000	/* $ISALIST expansion has occurred */
3827c478bd9Sstevel@tonic-gate #define	PN_TKN_HWCAP	0x02000000	/* $HWCAP expansion has occurred */
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate #define	PN_TKN_MASK	0xfff00000	/* mask for p_orig incorporation */
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate #define	TKN_NONE	0x00000001	/* no token expansion has occurred */
3877c478bd9Sstevel@tonic-gate #define	TKN_DOTSLASH	0x00000002	/* path contains a "./" */
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate /*
3907c478bd9Sstevel@tonic-gate  * Define alist descriptor addition return values (see hdl_add()).
3917c478bd9Sstevel@tonic-gate  */
3927c478bd9Sstevel@tonic-gate #define	ALE_EXISTS	1		/* alist entry already exists */
3937c478bd9Sstevel@tonic-gate #define	ALE_CREATE	2		/* alist entry created */
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate /*
3967c478bd9Sstevel@tonic-gate  * Define _caller flags.
3977c478bd9Sstevel@tonic-gate  */
3987c478bd9Sstevel@tonic-gate #define	CL_NONE		0
3997c478bd9Sstevel@tonic-gate #define	CL_EXECDEF	1		/* supply the executable as a default */
4007c478bd9Sstevel@tonic-gate 					/* if the caller can't be determined */
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate /*
4037c478bd9Sstevel@tonic-gate  * Binding information.  Note, this is or'ed in with the DBG_BINFO flags to
4047c478bd9Sstevel@tonic-gate  * convey information regarding symbol bindings.
4057c478bd9Sstevel@tonic-gate  */
4067c478bd9Sstevel@tonic-gate #define	BINFO_DIRECTDIS	0x10000		/* a direct binding has been disabled */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * Data declarations.
4107c478bd9Sstevel@tonic-gate  */
41110a4fa49Srie extern Lc_desc		glcs[];		/* global external interfaces */
41210a4fa49Srie 
4137c478bd9Sstevel@tonic-gate extern Rt_lock		rtldlock;	/* rtld lock */
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate extern List		dynlm_list;	/* dynamic list of link-maps */
4167c478bd9Sstevel@tonic-gate extern char		**environ;	/* environ pointer */
4177c478bd9Sstevel@tonic-gate 
4187c478bd9Sstevel@tonic-gate extern int		dyn_plt_ent_size; /* Size of dynamic plt's */
4197c478bd9Sstevel@tonic-gate extern ulong_t		at_flags;	/* machine specific file flags */
42041072f3cSrie extern const char	*procname;	/* file name of executing process */
4217c478bd9Sstevel@tonic-gate extern Rtld_db_priv	r_debug;	/* debugging information */
4227c478bd9Sstevel@tonic-gate extern char		*lasterr;	/* string describing last error */
4237c478bd9Sstevel@tonic-gate extern Interp		*interp;	/* ELF executable interpreter info */
42441072f3cSrie extern const char	*rtldname;	/* name of the dynamic linker */
4257c478bd9Sstevel@tonic-gate extern List		hdl_list[];	/* dlopen() handle list */
4267c478bd9Sstevel@tonic-gate extern size_t		syspagsz;	/* system page size */
4277c478bd9Sstevel@tonic-gate extern char		*platform; 	/* platform name */
4287c478bd9Sstevel@tonic-gate extern size_t		platform_sz; 	/* platform name string size */
4297c478bd9Sstevel@tonic-gate extern Isa_desc		*isa;		/* isalist descriptor */
4307c478bd9Sstevel@tonic-gate extern Uts_desc		*uts;		/* utsname descriptor */
4317c478bd9Sstevel@tonic-gate extern uint_t		rtld_flags;	/* status flags for RTLD */
4327c478bd9Sstevel@tonic-gate extern uint_t		rtld_flags2;	/* additional status flags for RTLD */
4337c478bd9Sstevel@tonic-gate extern Fmap		*fmap;		/* Initial file mapping info */
4347c478bd9Sstevel@tonic-gate extern uint32_t		pltcnt21d;	/* cnt of 21d PLTs */
4357c478bd9Sstevel@tonic-gate extern uint32_t		pltcnt24d;	/* cnt of 24d PLTs */
4367c478bd9Sstevel@tonic-gate extern uint32_t		pltcntu32;	/* cnt of u32 PLTs */
4377c478bd9Sstevel@tonic-gate extern uint32_t		pltcntu44;	/* cnt of u44 PLTs */
4387c478bd9Sstevel@tonic-gate extern uint32_t		pltcntfull;	/* cnt of full PLTs */
4397c478bd9Sstevel@tonic-gate extern uint32_t		pltcntfar;	/* cnt of far PLTs */
4407c478bd9Sstevel@tonic-gate extern uchar_t		search_rules[];	/* dependency search rules */
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate extern Fct		elf_fct;	/* ELF file class dependent data */
4437c478bd9Sstevel@tonic-gate 
444*02ca3e02Srie #if	defined(__sparc) && !defined(__sparcv9)
4457c478bd9Sstevel@tonic-gate extern Fct		aout_fct;	/* a.out (4.x) file class dependent */
4467c478bd9Sstevel@tonic-gate 					/*	data */
4477c478bd9Sstevel@tonic-gate #endif
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate extern const char	*locale;		/* locale environment setting */
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate extern Config		*config;		/* configuration structure */
4527c478bd9Sstevel@tonic-gate extern const char	*locale;		/* locale environment setting */
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate extern const char	*rpl_audit;	/* replaceable LD_AUDIT string */
4557c478bd9Sstevel@tonic-gate extern const char	*rpl_debug;	/* replaceable LD_DEBUG string */
4567c478bd9Sstevel@tonic-gate extern const char	*rpl_ldflags;	/* replaceable LD_FLAGS string */
4577c478bd9Sstevel@tonic-gate extern const char	*rpl_libpath;	/* replaceable LD_LIBRARY string */
4587c478bd9Sstevel@tonic-gate extern Pnode		*rpl_libdirs;	/*	and its associated Pnode list */
4597c478bd9Sstevel@tonic-gate extern const char	*rpl_preload;	/* replaceable LD_PRELOAD string */
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate extern const char	*prm_audit;	/* permanent LD_AUDIT string */
4627c478bd9Sstevel@tonic-gate extern const char	*prm_debug;	/* permanent LD_DEBUG string */
4637c478bd9Sstevel@tonic-gate extern const char	*prm_ldflags;	/* permanent LD_FLAGS string */
4647c478bd9Sstevel@tonic-gate extern const char	*prm_libpath;	/* permanent LD_LIBRARY string */
4657c478bd9Sstevel@tonic-gate extern Pnode		*prm_libdirs;	/*	and its associated Pnode list */
4667c478bd9Sstevel@tonic-gate extern const char	*prm_preload;	/* permanent LD_PRELOAD string */
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate extern uint_t		env_info;	/* information regarding environment */
4697c478bd9Sstevel@tonic-gate 					/*	variables */
4707c478bd9Sstevel@tonic-gate extern int		killsig;	/* signal sent on fatal exit */
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate extern uint_t		audit_argcnt;	/* no. of stack args to copy */
4737c478bd9Sstevel@tonic-gate extern Audit_desc	*auditors;	/* global auditors */
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate extern char		**_environ;
4767c478bd9Sstevel@tonic-gate 
4777c478bd9Sstevel@tonic-gate extern const char	*dbg_file;	/* debugging directed to a file */
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate extern Reglist		*reglist;	/* list of register symbols */
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate extern const Msg	err_reject[];	/* rejection error message tables */
4827c478bd9Sstevel@tonic-gate extern const Msg	ldd_reject[];
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate extern const char	*profile_name;	/* object being profiled */
4857c478bd9Sstevel@tonic-gate extern const char	*profile_out;	/* profile output file */
4867c478bd9Sstevel@tonic-gate extern const char	*profile_lib;	/* audit library to perform profile */
4877c478bd9Sstevel@tonic-gate 
48841072f3cSrie extern Dl_argsinfo	argsinfo;	/* process argument, environment and */
48941072f3cSrie 					/*	auxv information */
49041072f3cSrie 
4917c478bd9Sstevel@tonic-gate extern const char	*err_strs[];	/* diagnostic error string headers */
4927c478bd9Sstevel@tonic-gate extern const char	*nosym_str;	/* MSG_GEN_NOSYM message cache */
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate extern ulong_t		hwcap;		/* hardware capabilities */
4957c478bd9Sstevel@tonic-gate extern ulong_t		sfcap;		/* software capabilities */
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate /*
4987c478bd9Sstevel@tonic-gate  * Function declarations.
4997c478bd9Sstevel@tonic-gate  */
5007c478bd9Sstevel@tonic-gate extern void		addfree(void *, size_t);
5017c478bd9Sstevel@tonic-gate extern void *		alist_append(Alist **, const void *, size_t, int);
5027c478bd9Sstevel@tonic-gate extern int		alist_delete(Alist *, const void *, Aliste *);
5037c478bd9Sstevel@tonic-gate extern int		alist_test(Alist **, void *, size_t, int);
5047c478bd9Sstevel@tonic-gate extern int		append_alias(Rt_map *, const char *, int *);
5057c478bd9Sstevel@tonic-gate extern int		analyze_lmc(Lm_list *, Aliste, Rt_map *);
5065aefb655Srie extern Am_ret		anon_map(Lm_list *, caddr_t *, size_t, int, int);
5077c478bd9Sstevel@tonic-gate extern Fct		*are_u_this(Rej_desc *, int, struct stat *,
5087c478bd9Sstevel@tonic-gate 			    const char *);
5097c478bd9Sstevel@tonic-gate extern void		atexit_fini(void);
5107c478bd9Sstevel@tonic-gate extern int		bind_one(Rt_map *, Rt_map *, uint_t);
5117c478bd9Sstevel@tonic-gate extern int		bufprint(Prfbuf *, const char *, ...);
5125aefb655Srie extern void		call_array(Addr *, uint_t, Rt_map *, Word);
5137c478bd9Sstevel@tonic-gate extern void		call_fini(Lm_list *, Rt_map **);
5147c478bd9Sstevel@tonic-gate extern void		call_init(Rt_map **, int);
5157c478bd9Sstevel@tonic-gate extern int		callable(Rt_map *, Rt_map *, Grp_hdl *);
5167c478bd9Sstevel@tonic-gate extern Rt_map		*_caller(caddr_t, int);
5177c478bd9Sstevel@tonic-gate extern caddr_t		caller(void);
5187c478bd9Sstevel@tonic-gate extern void		*calloc(size_t, size_t);
5197c478bd9Sstevel@tonic-gate extern void		cap_assign(Cap *, Rt_map *);
5205aefb655Srie extern const char	*_conv_reloc_type(uint_t rel);
5215aefb655Srie extern uintptr_t	dbg_setup(const char *, Dbg_desc *);
5227c478bd9Sstevel@tonic-gate extern const char	*demangle(const char *);
5237c478bd9Sstevel@tonic-gate extern int		dlclose_intn(Grp_hdl *, Rt_map *);
524*02ca3e02Srie extern int		dlclose_core(Grp_hdl *, Rt_map *, Lm_list *);
5257c478bd9Sstevel@tonic-gate extern Sym		*dlsym_handle(Grp_hdl *, Slookup *, Rt_map **,
5267c478bd9Sstevel@tonic-gate 			    uint_t *);
5277c478bd9Sstevel@tonic-gate extern void		*dlsym_intn(void *, const char *, Rt_map *, Rt_map **);
5287c478bd9Sstevel@tonic-gate extern Grp_hdl		*dlmopen_intn(Lm_list *, const char *, int, Rt_map *,
52956d7adc6Srie 			    uint_t, uint_t, int *);
5307c478bd9Sstevel@tonic-gate extern size_t		doprf(const char *, va_list, Prfbuf *);
5317c478bd9Sstevel@tonic-gate extern int		dowrite(Prfbuf *);
5327c478bd9Sstevel@tonic-gate extern void		dz_init(int);
5335aefb655Srie extern caddr_t		dz_map(Lm_list *, caddr_t, size_t, int, int);
5347c478bd9Sstevel@tonic-gate extern int		elf_config(Rt_map *, int);
5357c478bd9Sstevel@tonic-gate extern int		elf_mach_flags_check(Rej_desc *, Ehdr *);
5367c478bd9Sstevel@tonic-gate extern Rtc_obj		*elf_config_ent(const char *, Word, int, const char **);
5375aefb655Srie extern Pnode		*elf_config_flt(Lm_list *, const char *, const char *);
5387c478bd9Sstevel@tonic-gate extern ulong_t		elf_hash(const char *);
5397c478bd9Sstevel@tonic-gate extern void 		elf_reloc_bad(Rt_map *, void *, uchar_t, ulong_t,
5407c478bd9Sstevel@tonic-gate 			    ulong_t);
5417c478bd9Sstevel@tonic-gate extern ulong_t		elf_reloc_relative(ulong_t, ulong_t, ulong_t,
5427c478bd9Sstevel@tonic-gate 			    ulong_t, ulong_t, ulong_t);
5437c478bd9Sstevel@tonic-gate extern ulong_t		elf_reloc_relacount(ulong_t, ulong_t,
5447c478bd9Sstevel@tonic-gate 			    ulong_t, ulong_t);
545*02ca3e02Srie extern long		elf_static_tls(Rt_map *, Sym *, void *, uchar_t, char *,
546d326b23bSrie 			    ulong_t, long);
5477c478bd9Sstevel@tonic-gate extern int		enter(void);
5487c478bd9Sstevel@tonic-gate extern uint_t		expand(char **, size_t *, char **, uint_t, uint_t,
5497c478bd9Sstevel@tonic-gate 			    Rt_map *);
5507c478bd9Sstevel@tonic-gate extern Pnode		*expand_paths(Rt_map *, const char *, uint_t, uint_t);
5517c478bd9Sstevel@tonic-gate extern void		free_hdl(Grp_hdl *);
5527c478bd9Sstevel@tonic-gate extern void		file_notfound(Lm_list *, const char *, Rt_map *,
5537c478bd9Sstevel@tonic-gate 			    uint_t, Rej_desc *);
5547c478bd9Sstevel@tonic-gate extern int		find_path(Lm_list *, const char *, Rt_map *, uint_t,
5557c478bd9Sstevel@tonic-gate 			    Fdesc *, Rej_desc *);
5567c478bd9Sstevel@tonic-gate extern int		fpavl_insert(Lm_list *, Rt_map *, const char *,
5577c478bd9Sstevel@tonic-gate 			    avl_index_t);
5587c478bd9Sstevel@tonic-gate extern Rt_map		*fpavl_loaded(Lm_list *, const char *, avl_index_t *);
5597c478bd9Sstevel@tonic-gate extern void		fpavl_remove(Rt_map *);
5607c478bd9Sstevel@tonic-gate extern size_t		fullpath(Rt_map *, const char *);
5617c478bd9Sstevel@tonic-gate extern void		fmap_setup();
5627c478bd9Sstevel@tonic-gate extern void		get_lcinterface(Rt_map *, Lc_interface *);
5637c478bd9Sstevel@tonic-gate extern Lmid_t		get_linkmap_id(Lm_list *);
5647c478bd9Sstevel@tonic-gate extern Pnode		*get_next_dir(Pnode **, Rt_map *, uint_t);
5659a411307Srie extern int		hdl_add(Grp_hdl *, Rt_map *, uint_t);
5669a411307Srie extern Grp_hdl		*hdl_create(Lm_list *, Rt_map *, Rt_map *, uint_t);
567*02ca3e02Srie extern int		hdl_initialize(Grp_hdl *, Rt_map *, int, int);
5687c478bd9Sstevel@tonic-gate extern int		hwcap_check(Rej_desc *, Ehdr *);
569*02ca3e02Srie extern Pnode 		*hwcap_filtees(Pnode **, Aliste, Lm_cntl *, Dyninfo *,
570*02ca3e02Srie 			    Rt_map *, const char *, int, uint_t);
5719a411307Srie extern void		is_dep_ready(Rt_map *, Rt_map *, int);
5729a411307Srie extern void		is_dep_init(Rt_map *, Rt_map *);
5739a411307Srie extern int		is_sym_interposer(Rt_map *, Sym *);
5749a411307Srie extern void		ldso_plt_init(Rt_map *);
5757c478bd9Sstevel@tonic-gate extern Listnode		*list_append(List *, const void *);
5767c478bd9Sstevel@tonic-gate extern Listnode		*list_insert(List *, const void *, Listnode *);
5777c478bd9Sstevel@tonic-gate extern Listnode		*list_prepend(List *, const void *);
5787c478bd9Sstevel@tonic-gate extern void		list_delete(List *, void *);
5797c478bd9Sstevel@tonic-gate extern void		leave(Lm_list *);
5807c478bd9Sstevel@tonic-gate extern void		lm_append(Lm_list *, Aliste, Rt_map *);
5817c478bd9Sstevel@tonic-gate extern void		lm_delete(Lm_list *, Rt_map *);
5827c478bd9Sstevel@tonic-gate extern void		lm_move(Lm_list *, Aliste, Aliste, Lm_cntl *,
5837c478bd9Sstevel@tonic-gate 			    Lm_cntl *);
5847c478bd9Sstevel@tonic-gate extern void		load_completion(Rt_map *, Rt_map *);
5857c478bd9Sstevel@tonic-gate extern Rt_map 		*load_hwcap(Lm_list *, Aliste, const char *, Rt_map *,
5867c478bd9Sstevel@tonic-gate 			    uint_t, uint_t, Grp_hdl **, Rej_desc *);
5877c478bd9Sstevel@tonic-gate extern Rt_map		*load_path(Lm_list *, Aliste, const char *, Rt_map *,
5887c478bd9Sstevel@tonic-gate 			    int, uint_t, Grp_hdl **, Fdesc *, Rej_desc *);
5897c478bd9Sstevel@tonic-gate extern Rt_map		*load_one(Lm_list *, Aliste, Pnode *, Rt_map *, int,
5907c478bd9Sstevel@tonic-gate 			    uint_t, Grp_hdl **);
5917c478bd9Sstevel@tonic-gate extern const char	*load_trace(Lm_list *, const char *, Rt_map *);
5925aefb655Srie extern caddr_t		nu_map(Lm_list *, caddr_t, size_t, int, int);
5937c478bd9Sstevel@tonic-gate extern void		*malloc(size_t);
5947c478bd9Sstevel@tonic-gate extern void		move_data(Rt_map *);
5955aefb655Srie extern int		pr_open(Lm_list *);
5967c478bd9Sstevel@tonic-gate extern void		rd_event(Lm_list *, rd_event_e, r_state_e);
5977c478bd9Sstevel@tonic-gate extern int		readenv_user(const char **, Word *, Word *, int);
5987c478bd9Sstevel@tonic-gate extern int		readenv_config(Rtc_env *, Addr, int);
5997c478bd9Sstevel@tonic-gate extern void		rejection_inherit(Rej_desc *, Rej_desc *, Fdesc *);
600*02ca3e02Srie extern int		relocate_lmc(Lm_list *, Aliste, Rt_map *, Rt_map *);
6017c478bd9Sstevel@tonic-gate extern int		relocate_finish(Rt_map *, Alist *, int, int);
6027c478bd9Sstevel@tonic-gate extern void		remove_cntl(Lm_list *, Aliste);
6037c478bd9Sstevel@tonic-gate extern int		remove_hdl(Grp_hdl *, Rt_map *, int *);
604*02ca3e02Srie extern void		remove_lmc(Lm_list *, Rt_map *, Lm_cntl *, Aliste,
605*02ca3e02Srie 			    const char *);
6067c478bd9Sstevel@tonic-gate extern void		remove_incomplete(Lm_list *, Aliste);
6077c478bd9Sstevel@tonic-gate extern void		remove_lists(Rt_map *, int);
6087c478bd9Sstevel@tonic-gate extern void		remove_lml(Lm_list *);
6097c478bd9Sstevel@tonic-gate extern void		remove_pnode(Pnode *);
6107c478bd9Sstevel@tonic-gate extern void		remove_rej(Rej_desc *);
6117c478bd9Sstevel@tonic-gate extern void		remove_so(Lm_list *, Rt_map *);
6127c478bd9Sstevel@tonic-gate extern int		rt_cond_broadcast(Rt_cond *);
6137c478bd9Sstevel@tonic-gate extern Rt_cond		*rt_cond_create(void);
6147c478bd9Sstevel@tonic-gate extern int		rt_cond_wait(Rt_cond *, Rt_lock *);
6157c478bd9Sstevel@tonic-gate extern int		rt_bind_guard(int);
6167c478bd9Sstevel@tonic-gate extern int		rt_bind_clear(int);
61710a4fa49Srie extern int		rt_get_extern(Lm_list *, Rt_map *);
6187c478bd9Sstevel@tonic-gate extern int		rt_mutex_lock(Rt_lock *);
6197c478bd9Sstevel@tonic-gate extern int		rt_mutex_unlock(Rt_lock *);
62010a4fa49Srie extern void		rt_thr_init(Lm_list *);
6217c478bd9Sstevel@tonic-gate extern thread_t		rt_thr_self(void);
6225aefb655Srie extern void		rtld_db_dlactivity(Lm_list *);
6235aefb655Srie extern void		rtld_db_preinit(Lm_list *);
6245aefb655Srie extern void		rtld_db_postinit(Lm_list *);
6257c478bd9Sstevel@tonic-gate extern void		rtldexit(Lm_list *, int);
62641072f3cSrie extern int		rtld_getopt(char **, char ***, auxv_t **, Word *,
62741072f3cSrie 			    Word *, int);
6287c478bd9Sstevel@tonic-gate extern void		security(uid_t, uid_t, gid_t, gid_t, int);
6297c478bd9Sstevel@tonic-gate extern void		set_environ(Lm_list *);
63041072f3cSrie extern Rt_map		*setup(char **, auxv_t *, Word, char *, int, char *,
6317c478bd9Sstevel@tonic-gate 			    Dyn *, ulong_t, ulong_t, int fd, Phdr *, char *,
6327c478bd9Sstevel@tonic-gate 			    char **, int, uid_t, uid_t, gid_t, gid_t, void *,
6337c478bd9Sstevel@tonic-gate 			    int, uint_t);
634d326b23bSrie extern int		tls_assign(Lm_list *, Rt_map *, Phdr *);
63510a4fa49Srie extern void		tls_modaddrem(Rt_map *, uint_t);
63610a4fa49Srie extern int		tls_statmod(Lm_list *, Rt_map *);
6377c478bd9Sstevel@tonic-gate extern Rt_map		**tsort(Rt_map *, int, int);
6387c478bd9Sstevel@tonic-gate extern void		unused(Lm_list *);
6397c478bd9Sstevel@tonic-gate extern int		update_mode(Rt_map *, int, int);
6407c478bd9Sstevel@tonic-gate extern void		zero(caddr_t, size_t);
6417c478bd9Sstevel@tonic-gate 
642*02ca3e02Srie #if	defined(__sparc)
6437c478bd9Sstevel@tonic-gate /*
6447c478bd9Sstevel@tonic-gate  * SPARC Register symbol support.
6457c478bd9Sstevel@tonic-gate  */
6467c478bd9Sstevel@tonic-gate extern int		elf_regsyms(Rt_map *);
6477c478bd9Sstevel@tonic-gate extern void		set_sparc_g1(ulong_t);
6487c478bd9Sstevel@tonic-gate extern void		set_sparc_g2(ulong_t);
6497c478bd9Sstevel@tonic-gate extern void		set_sparc_g3(ulong_t);
6507c478bd9Sstevel@tonic-gate extern void		set_sparc_g4(ulong_t);
6517c478bd9Sstevel@tonic-gate extern void		set_sparc_g5(ulong_t);
6527c478bd9Sstevel@tonic-gate extern void		set_sparc_g6(ulong_t);
6537c478bd9Sstevel@tonic-gate extern void		set_sparc_g7(ulong_t);
654*02ca3e02Srie #endif
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate extern long		_sysconfig(int);
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6597c478bd9Sstevel@tonic-gate }
6607c478bd9Sstevel@tonic-gate #endif
6617c478bd9Sstevel@tonic-gate 
6627c478bd9Sstevel@tonic-gate #endif /* __RTLD_H */
663