xref: /illumos-gate/usr/src/cmd/sgs/rtld/common/_rtld.h (revision cb511613a15cb3949eadffd67b37d3c665b4ef22)
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 /*
347c478bd9Sstevel@tonic-gate  * Common header for run-time linker.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/stat.h>
387c478bd9Sstevel@tonic-gate #include <sys/avl.h>
397c478bd9Sstevel@tonic-gate #include <stdarg.h>
407c478bd9Sstevel@tonic-gate #include <synch.h>
417c478bd9Sstevel@tonic-gate #include <signal.h>
427c478bd9Sstevel@tonic-gate #include <errno.h>
437c478bd9Sstevel@tonic-gate #include <unistd.h>
447c478bd9Sstevel@tonic-gate #include <link.h>
457c478bd9Sstevel@tonic-gate #include <rtld.h>
467c478bd9Sstevel@tonic-gate #include <sgs.h>
477c478bd9Sstevel@tonic-gate #include <machdep.h>
487c478bd9Sstevel@tonic-gate #include <rtc.h>
495aefb655Srie #include <debug.h>
507c478bd9Sstevel@tonic-gate #include <msg.h>
517c478bd9Sstevel@tonic-gate #include <libc_int.h>
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
547c478bd9Sstevel@tonic-gate extern "C" {
557c478bd9Sstevel@tonic-gate #endif
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * Dependency search rule order.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate #define	RPLENV		1		/* replaceable LD_LIBRARY_PATH */
617c478bd9Sstevel@tonic-gate #define	PRMENV		2		/* permanent LD_LIBRARY_PATH */
627c478bd9Sstevel@tonic-gate #define	RUNPATH		3		/* callers runpath */
637c478bd9Sstevel@tonic-gate #define	DEFAULT		4		/* default library path */
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * Data structure for file class specific functions and data.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate typedef struct fct {
707c478bd9Sstevel@tonic-gate 	int	(*fct_are_u_this)(Rej_desc *);	/* determine type of object */
717c478bd9Sstevel@tonic-gate 	ulong_t	(*fct_entry_pt)(void);		/* get entry point */
727c478bd9Sstevel@tonic-gate 	Rt_map	*(*fct_map_so)(Lm_list *, Aliste, const char *, const char *,
739aa23310Srie 		    int, int *);		/* map in a shared object */
747c478bd9Sstevel@tonic-gate 	void	(*fct_unmap_so)(Rt_map *);	/* unmap a shared object */
759aa23310Srie 	int	(*fct_needed)(Lm_list *, Aliste, Rt_map *, int *);
767c478bd9Sstevel@tonic-gate 						/* determine needed objects */
779aa23310Srie 	Sym	*(*fct_lookup_sym)(Slookup *, Rt_map **, uint_t *, int *);
787c478bd9Sstevel@tonic-gate 						/* initialize symbol lookup */
799aa23310Srie 	int	(*fct_reloc)(Rt_map *, uint_t, int *);
809aa23310Srie 						/* relocate shared object */
817c478bd9Sstevel@tonic-gate 	Pnode	*fct_dflt_dirs;			/* list of default dirs to */
827c478bd9Sstevel@tonic-gate 						/*	search */
837c478bd9Sstevel@tonic-gate 	Pnode	*fct_secure_dirs;		/* list of secure dirs to */
847c478bd9Sstevel@tonic-gate 						/*	search (set[ug]id) */
857c478bd9Sstevel@tonic-gate 	Pnode	*(*fct_fix_name)(const char *, Rt_map *, uint_t);
867c478bd9Sstevel@tonic-gate 						/* transpose name */
877c478bd9Sstevel@tonic-gate 	char	*(*fct_get_so)(const char *, const char *);
887c478bd9Sstevel@tonic-gate 						/* get shared object */
897c478bd9Sstevel@tonic-gate 	void	(*fct_dladdr)(ulong_t, Rt_map *, Dl_info *, void **, int);
907c478bd9Sstevel@tonic-gate 						/* get symbolic address */
919aa23310Srie 	Sym	*(*fct_dlsym)(Grp_hdl *, Slookup *, Rt_map **, uint_t *,
929aa23310Srie 		    int *);			/* process dlsym request */
937c478bd9Sstevel@tonic-gate 	int	(*fct_verify_vers)(const char *, Rt_map *, Rt_map *);
947c478bd9Sstevel@tonic-gate 						/* verify versioning (ELF) */
957c478bd9Sstevel@tonic-gate 	int	(*fct_set_prot)(Rt_map *, int);
967c478bd9Sstevel@tonic-gate 						/* set protection */
977c478bd9Sstevel@tonic-gate } Fct;
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Return codes for util::anon_map().
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate typedef enum {
1047c478bd9Sstevel@tonic-gate 	AM_OK,			/* mmap(MAP_ANON) succeeded */
1057c478bd9Sstevel@tonic-gate 	AM_NOSUP,		/* mmap(MAP_ANON) not supported (old OS) */
1067c478bd9Sstevel@tonic-gate 	AM_ERROR		/* mmap(MAP_ANON) failed */
1077c478bd9Sstevel@tonic-gate } Am_ret;
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Macros for getting to the file class table.
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate #define	LM_ENTRY_PT(X)		((X)->rt_fct->fct_entry_pt)
1147c478bd9Sstevel@tonic-gate #define	LM_UNMAP_SO(X)		((X)->rt_fct->fct_unmap_so)
1157c478bd9Sstevel@tonic-gate #define	LM_NEEDED(X)		((X)->rt_fct->fct_needed)
1167c478bd9Sstevel@tonic-gate #define	LM_LOOKUP_SYM(X)	((X)->rt_fct->fct_lookup_sym)
1177c478bd9Sstevel@tonic-gate #define	LM_RELOC(X)		((X)->rt_fct->fct_reloc)
1187c478bd9Sstevel@tonic-gate #define	LM_DFLT_DIRS(X)		((X)->rt_fct->fct_dflt_dirs)
1197c478bd9Sstevel@tonic-gate #define	LM_SECURE_DIRS(X)	((X)->rt_fct->fct_secure_dirs)
1207c478bd9Sstevel@tonic-gate #define	LM_FIX_NAME(X)		((X)->rt_fct->fct_fix_name)
1217c478bd9Sstevel@tonic-gate #define	LM_GET_SO(X)		((X)->rt_fct->fct_get_so)
1227c478bd9Sstevel@tonic-gate #define	LM_DLADDR(X)		((X)->rt_fct->fct_dladdr)
1237c478bd9Sstevel@tonic-gate #define	LM_DLSYM(X)		((X)->rt_fct->fct_dlsym)
1247c478bd9Sstevel@tonic-gate #define	LM_VERIFY_VERS(X)	((X)->rt_fct->fct_verify_vers)
1257c478bd9Sstevel@tonic-gate #define	LM_SET_PROT(X)		((X)->rt_fct->fct_set_prot)
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  * Define Alist initialization sizes.
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate #define	AL_CNT_ALIAS	2		/* ALIAS() initial alist count */
1327c478bd9Sstevel@tonic-gate #define	AL_CNT_DEPENDS	10		/* DEPENDS() initial alist count */
1337c478bd9Sstevel@tonic-gate #define	AL_CNT_CALLERS	10		/* CALLERS() initial alist count */
1348521e5e6Srie #define	AL_CNT_GROUPS	4		/* GROUPS() initial alist count */
1357c478bd9Sstevel@tonic-gate #define	AL_CNT_COPYREL	10		/* COPY() initial alist count */
1367c478bd9Sstevel@tonic-gate #define	AL_CNT_LAZYFIND	10		/* elf_lazy_find_sym() initial alist */
1377c478bd9Sstevel@tonic-gate 					/*	count */
1387c478bd9Sstevel@tonic-gate #define	AL_CNT_GRPCLCT	10		/* gdp_collect() initial alist count */
1397c478bd9Sstevel@tonic-gate #define	AL_CNT_DEPCLCT	10		/* load_so() initial alist count */
1407c478bd9Sstevel@tonic-gate #define	AL_CNT_RTLDINFO	1		/* RTLDINFO() initial alist count */
1417c478bd9Sstevel@tonic-gate #define	AL_CNT_FPNODE	2		/* FPNODE() initial alist count */
1427c478bd9Sstevel@tonic-gate #define	AL_CNT_LMLISTS	8		/* lm_lists initial alist count */
1437c478bd9Sstevel@tonic-gate #define	AL_CNT_LMNOW	8		/* lm_now initial alist count */
1447c478bd9Sstevel@tonic-gate #define	AL_CNT_RELBIND	20		/* relocation binding alist count */
1457247f888Srie #define	AL_CNT_ACTAUDIT	2		/* lm_actaudit alist count */
146466e2a62Srie #define	AL_CNT_MOVES	10		/* move_data alist count */
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * Size of buffer for building error messages.
1517c478bd9Sstevel@tonic-gate  */
1527c478bd9Sstevel@tonic-gate #define	ERRSIZE		2048		/* MAXPATHLEN * 2 */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate /*
1567c478bd9Sstevel@tonic-gate  * Configuration file information.
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate typedef struct config {
1597c478bd9Sstevel@tonic-gate 	const char	*c_name;
1607c478bd9Sstevel@tonic-gate 	Addr		c_bgn;
1617c478bd9Sstevel@tonic-gate 	Addr		c_end;
1627c478bd9Sstevel@tonic-gate 	Word		*c_hashtbl;
1637c478bd9Sstevel@tonic-gate 	Word		*c_hashchain;
1647c478bd9Sstevel@tonic-gate 	const char	*c_strtbl;
1657c478bd9Sstevel@tonic-gate 	Rtc_obj		*c_objtbl;
1667c478bd9Sstevel@tonic-gate 	Rtc_fltr	*c_fltr;
1677c478bd9Sstevel@tonic-gate 	Rtc_flte	*c_flte;
1687c478bd9Sstevel@tonic-gate } Config;
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate /*
1717c478bd9Sstevel@tonic-gate  * Register symbol list.
1727c478bd9Sstevel@tonic-gate  */
1737c478bd9Sstevel@tonic-gate typedef struct reglist {
1747c478bd9Sstevel@tonic-gate 	Rt_map		*rl_lmp;	/* defining object */
1757c478bd9Sstevel@tonic-gate 	Sym		*rl_sym;	/* regsym */
1767c478bd9Sstevel@tonic-gate 	struct reglist	*rl_next;	/* next entry */
1777c478bd9Sstevel@tonic-gate } Reglist;
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate  * Data structure to hold interpreter information.
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate typedef struct interp {
1837c478bd9Sstevel@tonic-gate 	char		*i_name;	/* interpreter name */
1847c478bd9Sstevel@tonic-gate 	caddr_t		i_faddr;	/* address interpreter is mapped at */
1857c478bd9Sstevel@tonic-gate } Interp;
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate  * Data structure used to keep track of copy relocations.  These relocations
1897c478bd9Sstevel@tonic-gate  * are collected during initial relocation processing and maintained on the
1907c478bd9Sstevel@tonic-gate  * COPY(lmp) list of the defining object.  Each copy list is also added to the
1917c478bd9Sstevel@tonic-gate  * COPY(lmp) of the head object (normally the application dynamic executable)
1927c478bd9Sstevel@tonic-gate  * from which they will be processed after all relocations are done.
1937c478bd9Sstevel@tonic-gate  *
1947c478bd9Sstevel@tonic-gate  * The use of RTLD_GROUP will also reference individual objects COPY(lmp) lists
1957c478bd9Sstevel@tonic-gate  * in case a bound symbol must be assigned to it actual copy relocation.
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate typedef struct {
1987c478bd9Sstevel@tonic-gate 	const char	*r_name;	/* symbol name */
1997c478bd9Sstevel@tonic-gate 	Sym		*r_rsym;	/* reference symbol table entry */
2007c478bd9Sstevel@tonic-gate 	Rt_map		*r_rlmp;	/* reference link map */
2017c478bd9Sstevel@tonic-gate 	Rt_map		*r_dlmp;	/* definition link map */
2027c478bd9Sstevel@tonic-gate 	Sym		*r_dsym;	/* definition symbol table entry */
2037c478bd9Sstevel@tonic-gate 	void		*r_radd;	/* copy to address */
2047c478bd9Sstevel@tonic-gate 	const void	*r_dadd;	/* copy from address */
2057c478bd9Sstevel@tonic-gate 	ulong_t		r_size;		/* copy size bytes */
2067c478bd9Sstevel@tonic-gate } Rel_copy;
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Data structure to hold initial file mapping information.  Used to
2107c478bd9Sstevel@tonic-gate  * communicate during initial object mapping and provide for error recovery.
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate typedef struct {
2137c478bd9Sstevel@tonic-gate 	char		*fm_maddr;	/* address of initial mapping */
2147c478bd9Sstevel@tonic-gate 	size_t		fm_msize;	/* size of initial mapping */
2157c478bd9Sstevel@tonic-gate 	size_t		fm_fsize;	/* actual file size */
2167c478bd9Sstevel@tonic-gate 	ulong_t		fm_etext;	/* end of text segment */
2177c478bd9Sstevel@tonic-gate 	int		fm_mflags;	/* mapping flags */
2187c478bd9Sstevel@tonic-gate 	ulong_t		fm_hwptr;	/* hardware capabilities pointer */
2197c478bd9Sstevel@tonic-gate } Fmap;
2207c478bd9Sstevel@tonic-gate 
221a953e2b1Srie #define	FMAP_SIZE	0x8000		/* initial size to map from a file */
222a953e2b1Srie 					/* big enough to capture standard */
223a953e2b1Srie 					/* filters */
2247c478bd9Sstevel@tonic-gate /*
2257c478bd9Sstevel@tonic-gate  * Define a file descriptor, which maintains information regarding a pathname
2267c478bd9Sstevel@tonic-gate  * that has been opened and minimally inspected.
2277c478bd9Sstevel@tonic-gate  */
2287c478bd9Sstevel@tonic-gate typedef struct {
2297c478bd9Sstevel@tonic-gate 	Rt_map		*fd_lmp;	/* existing link-map pointer */
2307c478bd9Sstevel@tonic-gate 	Fct		*fd_ftp;	/* file functions pointer */
2317c478bd9Sstevel@tonic-gate 	const char	*fd_oname;	/* original file name */
2327c478bd9Sstevel@tonic-gate 	const char	*fd_odir;	/* original directory name */
2337c478bd9Sstevel@tonic-gate 	const char	*fd_nname;	/* new file (expanded) name */
2347c478bd9Sstevel@tonic-gate 	const char	*fd_pname;	/* new path (resolved) name */
2357c478bd9Sstevel@tonic-gate 	dev_t		fd_dev;		/* file device number */
236*cb511613SAli Bahrami 	rtld_ino_t	fd_ino;		/* file inode number */
2377c478bd9Sstevel@tonic-gate 	int		fd_fd;		/* open file descriptor */
2387c478bd9Sstevel@tonic-gate 	uint_t		fd_flags;
2397c478bd9Sstevel@tonic-gate 	avl_index_t	fd_avlwhere;	/* avl tree insertion index */
2407c478bd9Sstevel@tonic-gate 	Fmap		fd_fmap;	/* file mapping information */
2417c478bd9Sstevel@tonic-gate } Fdesc;
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate #define	FLG_FD_ALTER	0x01		/* file is an alternate */
2447c478bd9Sstevel@tonic-gate #define	FLG_FD_SLASH	0x02		/* file contains a "/" */
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate /*
2477c478bd9Sstevel@tonic-gate  * File descriptor availability flag.
2487c478bd9Sstevel@tonic-gate  */
2497c478bd9Sstevel@tonic-gate #define	FD_UNAVAIL	-1
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate /*
2527c478bd9Sstevel@tonic-gate  * Disabled filter flag.  Filter objects are referenced using their .dynamic
2537c478bd9Sstevel@tonic-gate  * index (DT_FILTER or DT_AUXILIARY).  This index is saved and used to lookup
2547c478bd9Sstevel@tonic-gate  * the required filter.  Note that 0 is a valid .dynamic index.  The caller's
2557c478bd9Sstevel@tonic-gate  * OBJFLTRNDX() element is initialized using the following flag, and should
2567c478bd9Sstevel@tonic-gate  * the filter's initialization fail, is reset to this value to indicate the
2577c478bd9Sstevel@tonic-gate  * filter is disabled.  UINT_MAX provides a convenient invalid .dynamic index.
2587c478bd9Sstevel@tonic-gate  */
2597c478bd9Sstevel@tonic-gate #define	FLTR_DISABLED	UINT_MAX
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate /*
2627c478bd9Sstevel@tonic-gate  * Status flags for rtld_flags
2637c478bd9Sstevel@tonic-gate  */
2647c478bd9Sstevel@tonic-gate #define	RT_FL_THREADS	0x00000001	/* threads are enabled */
2657c478bd9Sstevel@tonic-gate #define	RT_FL_WARNFLTR	0x00000002	/* warn of missing filtees (ldd) */
2667c478bd9Sstevel@tonic-gate #define	RT_FL_DBNOTIF	0x00000004	/* binding activity going on */
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate #ifdef	SIEBEL_DISABLE
2697c478bd9Sstevel@tonic-gate #define	RT_FL_DISFIX_1	0x00000008	/* disable fix number 1 */
2707c478bd9Sstevel@tonic-gate #endif
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate #define	RT_FL_NOBIND	0x00000010	/* don't carry out plt binding */
2737c478bd9Sstevel@tonic-gate #define	RT_FL_NOVERSION	0x00000020	/* disable version checking */
2747c478bd9Sstevel@tonic-gate #define	RT_FL_SECURE	0x00000040	/* setuid/segid flag */
2757c478bd9Sstevel@tonic-gate #define	RT_FL_APPLIC	0x00000080	/* are we executing user code */
2767c478bd9Sstevel@tonic-gate #define	RT_FL_CONCUR	0x00000100	/* thread concurrency checks required */
2777c478bd9Sstevel@tonic-gate #define	RT_FL_CONFGEN	0x00000200	/* don't relocate initiating object */
2787c478bd9Sstevel@tonic-gate 					/*	set by crle(1). */
2797c478bd9Sstevel@tonic-gate #define	RT_FL_CONFAPP	0x00000400	/* application specific configuration */
2807c478bd9Sstevel@tonic-gate 					/*	cache required */
2817c478bd9Sstevel@tonic-gate #define	RT_FL_DEBUGGER	0x00000800	/* a debugger is monitoring us */
2829aa23310Srie #define	RT_FL_OPERATION	0x00001000	/* start recording operations */
2837c478bd9Sstevel@tonic-gate #define	RT_FL_NEWLOCALE	0x00002000	/* message locale has changed */
2847c478bd9Sstevel@tonic-gate #define	RT_FL_NOBAPLT	0x00004000	/* sparc: don't use ba plt's */
2857c478bd9Sstevel@tonic-gate #define	RT_FL_NOAUXFLTR	0x00008000	/* disable auxiliary filters */
2867c478bd9Sstevel@tonic-gate #define	RT_FL_NOCONCUR	0x00010000	/* disable thread concurrency checks */
2877c478bd9Sstevel@tonic-gate #define	RT_FL_NOAUDIT	0x00020000	/* disable auditing */
2887c478bd9Sstevel@tonic-gate #define	RT_FL_ATEXIT	0x00040000	/* we're shutting down */
2897c478bd9Sstevel@tonic-gate #define	RT_FL_SILENCERR	0x00080000	/* silence error messages */
2907c478bd9Sstevel@tonic-gate #define	RT_FL_BREADTH	0x00100000	/* use breadth-first for .init/.fini */
2917c478bd9Sstevel@tonic-gate #define	RT_FL_INITFIRST	0x00200000	/* processing a DT_INITFIRST object */
2927c478bd9Sstevel@tonic-gate #define	RT_FL_RELATIVE	0x00400000	/* relative path expansion required */
2937c478bd9Sstevel@tonic-gate #define	RT_FL_EXECNAME	0x00800000	/* AT_SUN_EXECNAME vector is avail */
2947c478bd9Sstevel@tonic-gate #define	RT_FL_DEMANGLE	0x01000000	/* demangle C++ symbol names */
2957c478bd9Sstevel@tonic-gate #define	RT_FL_NOCFG	0x02000000	/* disable config file use */
2967c478bd9Sstevel@tonic-gate #define	RT_FL_NODIRCFG	0x04000000	/* disable directory config use */
2977c478bd9Sstevel@tonic-gate #define	RT_FL_NOOBJALT	0x08000000	/* disable object alternative use */
2987c478bd9Sstevel@tonic-gate #define	RT_FL_NOENVCFG	0x10000000	/* disable config envars use */
2997c478bd9Sstevel@tonic-gate #define	RT_FL_DIRCFG	0x20000000	/* directory config info available */
3007c478bd9Sstevel@tonic-gate #define	RT_FL_OBJALT	0x40000000	/* object alternatives are available */
3017c478bd9Sstevel@tonic-gate #define	RT_FL_MEMRESV	0x80000000	/* memory reservation established */
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * Status flags for rtld_flags2
3057c478bd9Sstevel@tonic-gate  */
3065aefb655Srie #define	RT_FL2_HASAUDIT	0x00000001	/* auditing lm_list is present */
3077c478bd9Sstevel@tonic-gate #define	RT_FL2_RTLDSEEN	0x00000002	/* rtldinfo has been set */
3085aefb655Srie #define	RT_FL2_UNIFPROC	0x00000004	/* libc/libthread unified environment */
3097c478bd9Sstevel@tonic-gate #define	RT_FL2_NOMALIGN	0x00000008	/* mmap MAP_ALIGN isn't available */
3107c478bd9Sstevel@tonic-gate #define	RT_FL2_NOFLTCFG	0x00000010	/* disable config filter use */
3117c478bd9Sstevel@tonic-gate #define	RT_FL2_FLTCFG	0x00000020	/* filter config info available */
3127c478bd9Sstevel@tonic-gate #define	RT_FL2_HWCAP	0x00000040	/* hardware capabilities available */
3137c478bd9Sstevel@tonic-gate #define	RT_FL2_FTL2WARN	0x00000080	/* convert fatal to warning messages */
3147c478bd9Sstevel@tonic-gate #define	RT_FL2_BINDNOW	0x00000100	/* LD_BIND_NOW in effect */
315dffec89cSrie #define	RT_FL2_BINDLAZY	0x00000200	/* disable RTLD_NOW (and LD_BIND_NOW) */
31610a4fa49Srie #define	RT_FL2_PLMSETUP	0x00000400	/* primary link-map set up complete */
3179aa23310Srie #define	RT_FL2_BRANDED	0x00000800	/* process is branded */
3189aa23310Srie #define	RT_FL2_NOPLM	0x00001000	/* process has no primary link map */
3193dbfc803SRod Evans #define	RT_FL2_SETUID	0x00002000	/* ld.so.1 is setuid root */
320bebb829dSRod Evans #define	RT_FL2_ADDR32	0x00004000	/* 32-bit address space requirement */
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate  * Information flags for env_info.
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate #define	ENV_INF_PATHCFG	0x00000001	/* replaceable LD_LIBRARY_PATH */
3267c478bd9Sstevel@tonic-gate 					/*	originates from configuration */
3277c478bd9Sstevel@tonic-gate 					/*	file */
3287c478bd9Sstevel@tonic-gate #define	ENV_INF_FLAGCFG	0x00000002	/* replaceable LD_FLAGS originates */
3297c478bd9Sstevel@tonic-gate 					/*	from configuration file */
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate /*
33210a4fa49Srie  * RTLDINFO descriptor.
33310a4fa49Srie  */
33410a4fa49Srie typedef struct {
33510a4fa49Srie 	Rt_map		*rti_lmp;	/* RTLDINFO provider */
33610a4fa49Srie 	Lc_interface	*rti_info;	/* RTLDINFO data */
33710a4fa49Srie } Rti_desc;
33810a4fa49Srie 
33910a4fa49Srie /*
34010a4fa49Srie  * Binding flags for the bindguard routines.
3418cd45542Sraf  * These are defined in usr/src/lib/libc/inc/libc_int.h in the
3428cd45542Sraf  * latest version of the libc/rtld runtime interface (CI_V_FIVE).
3437c478bd9Sstevel@tonic-gate  */
3448cd45542Sraf #if !defined(CI_V_FIVE)
3457c478bd9Sstevel@tonic-gate #define	THR_FLG_RTLD	0x00000001	/* rtldlock bind_guard() flag */
3468cd45542Sraf #define	THR_FLG_NOLOCK	0x00000000	/* no-op before CI_V_FIVE */
3478cd45542Sraf #define	THR_FLG_REENTER	0x00000000	/* no-op before CI_V_FIVE */
3488cd45542Sraf #endif
3497c478bd9Sstevel@tonic-gate 
3509aa23310Srie #define	ROUND(x, a)	(((int)(x) + ((int)(a) - 1)) & ~((int)(a) - 1))
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate  * Print buffer.
3547c478bd9Sstevel@tonic-gate  */
3557c478bd9Sstevel@tonic-gate typedef struct {
3567c478bd9Sstevel@tonic-gate 	char	*pr_buf;	/* pointer to beginning of buffer */
3577c478bd9Sstevel@tonic-gate 	char	*pr_cur;	/* pointer to next free char in buffer */
3587c478bd9Sstevel@tonic-gate 	size_t	pr_len;		/* buffer size */
3597c478bd9Sstevel@tonic-gate 	int	pr_fd;		/* output fd */
3607c478bd9Sstevel@tonic-gate } Prfbuf;
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate /*
3637c478bd9Sstevel@tonic-gate  * dlopen() handle list size.
3647c478bd9Sstevel@tonic-gate  */
3657c478bd9Sstevel@tonic-gate #define	HDLIST_SZ	101	/* prime no. for hashing */
3667c478bd9Sstevel@tonic-gate #define	HDLIST_ORP	102	/* orphan handle list */
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /*
3697c478bd9Sstevel@tonic-gate  * Define expansion path information.  Search paths, i.e., LD_LIBRARY_PATH,
3707c478bd9Sstevel@tonic-gate  * RPATHS, etc. are defined using la_objsearch() information (see LA_SER flags
3717c478bd9Sstevel@tonic-gate  * in link.h).  Definitions here extend the path information to other uses of
3727c478bd9Sstevel@tonic-gate  * pathname expansion, and are or'd together with any LA_SER_* flags.
3737c478bd9Sstevel@tonic-gate  */
3749aa23310Srie #define	PN_FLG_EXTLOAD	0x00001000	/* path defines extra loaded objects */
3757c478bd9Sstevel@tonic-gate 					/*	(preload, audit etc.) */
3769aa23310Srie #define	PN_FLG_UNIQUE	0x00002000	/* ensure path is unique */
3779aa23310Srie #define	PN_FLG_USED	0x00004000	/* indicate that path is used */
3789aa23310Srie #define	PN_FLG_DUPLICAT	0x00008000	/* path is a duplicate */
379247b82a1SRod Evans #define	PN_FLG_FULLPATH	0x00010000	/* ensure path is a full path */
3807c478bd9Sstevel@tonic-gate 
3819aa23310Srie #define	PN_FLG_MASK	0x000ff000	/* mask for p_orig incorporation */
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate /*
3847c478bd9Sstevel@tonic-gate  * Define reserved path tokens.  These are used to prevent various expansions
3857c478bd9Sstevel@tonic-gate  * from occurring, and record those expansions that do.  Note that any expansion
3867c478bd9Sstevel@tonic-gate  * information is also recorded in the p_orig field of a Pnode, and thus is
3879aa23310Srie  * or'd together with any LA_SER, and PN_FLG flags.
3887c478bd9Sstevel@tonic-gate  */
3897c478bd9Sstevel@tonic-gate #define	PN_TKN_ORIGIN	0x00100000	/* $ORIGIN expansion has occurred */
3907c478bd9Sstevel@tonic-gate #define	PN_TKN_PLATFORM	0x00200000	/* $PLATFORM expansion has occurred */
3917c478bd9Sstevel@tonic-gate #define	PN_TKN_OSNAME	0x00400000	/* $OSNAME expansion has occurred */
3927c478bd9Sstevel@tonic-gate #define	PN_TKN_OSREL	0x00800000	/* $OSREL expansion has occurred */
3937c478bd9Sstevel@tonic-gate #define	PN_TKN_ISALIST	0x01000000	/* $ISALIST expansion has occurred */
3947c478bd9Sstevel@tonic-gate #define	PN_TKN_HWCAP	0x02000000	/* $HWCAP expansion has occurred */
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate #define	PN_TKN_MASK	0xfff00000	/* mask for p_orig incorporation */
3977c478bd9Sstevel@tonic-gate 
3989aa23310Srie /*
3999aa23310Srie  * Additional token expansion information.  Although these flags may be set
4009aa23310Srie  * within a token data item they are masked off with PN_TKN_MASK prior to any
4019aa23310Srie  * expansion information being recorded in a Pnode for later diagnostics.
4029aa23310Srie  */
4037c478bd9Sstevel@tonic-gate #define	TKN_NONE	0x00000001	/* no token expansion has occurred */
4047c478bd9Sstevel@tonic-gate #define	TKN_DOTSLASH	0x00000002	/* path contains a "./" */
4057c478bd9Sstevel@tonic-gate 
4067c478bd9Sstevel@tonic-gate /*
4077c478bd9Sstevel@tonic-gate  * Define _caller flags.
4087c478bd9Sstevel@tonic-gate  */
4097c478bd9Sstevel@tonic-gate #define	CL_NONE		0
4107c478bd9Sstevel@tonic-gate #define	CL_EXECDEF	1		/* supply the executable as a default */
4117c478bd9Sstevel@tonic-gate 					/* if the caller can't be determined */
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate /*
41437ffaf83SRod Evans  * Binding information flags.  These flags are passed up from low level binding
41537ffaf83SRod Evans  * routines to indicate "additional" information, such as why a binding has been
41637ffaf83SRod Evans  * rejected.  These flags use the same data element as is used to record any
41737ffaf83SRod Evans  * DBG_BINFO flags.  The DBG_BINFO flags are used to define the final bindings
41837ffaf83SRod Evans  * information and are used to provide better binding diagnostics.
4197c478bd9Sstevel@tonic-gate  */
42037ffaf83SRod Evans #define	BINFO_REJDIRECT		0x010000	/* reject a direct binding */
42137ffaf83SRod Evans #define	BINFO_REJSINGLE		0x100000	/* reject a singleton binding */
42237ffaf83SRod Evans #define	BINFO_REJGROUP		0x200000	/* reject a group binding */
42337ffaf83SRod Evans 
42437ffaf83SRod Evans #define	BINFO_MSK_TRYAGAIN	0xf00000	/* a mask of bindings that */
42537ffaf83SRod Evans 						/*    should be retried */
42637ffaf83SRod Evans #define	BINFO_MSK_REJECTED	0xff0000	/* a mask of bindings that */
42737ffaf83SRod Evans 						/*    have been rejected */
428*cb511613SAli Bahrami 
429*cb511613SAli Bahrami /*
430*cb511613SAli Bahrami  * The 32-bit version of rtld uses special stat() wrapper functions
431*cb511613SAli Bahrami  * that preserve the non-largefile semantics of stat()/fstat() while
432*cb511613SAli Bahrami  * allowing for large inode values. The 64-bit rtld uses stat() directly.
433*cb511613SAli Bahrami  */
434*cb511613SAli Bahrami #ifdef _LP64
435*cb511613SAli Bahrami #define	rtld_fstat	fstat
436*cb511613SAli Bahrami #define	rtld_stat	stat
437*cb511613SAli Bahrami typedef	struct stat	rtld_stat_t;
438*cb511613SAli Bahrami #else
439*cb511613SAli Bahrami typedef struct {
440*cb511613SAli Bahrami 	dev_t		st_dev;
441*cb511613SAli Bahrami 	rtld_ino_t	st_ino;
442*cb511613SAli Bahrami 	mode_t		st_mode;
443*cb511613SAli Bahrami 	uid_t		st_uid;
444*cb511613SAli Bahrami 	off_t		st_size;
445*cb511613SAli Bahrami 	timestruc_t	st_mtim;
446*cb511613SAli Bahrami #ifdef sparc
447*cb511613SAli Bahrami 	blksize_t	st_blksize;
448*cb511613SAli Bahrami #endif
449*cb511613SAli Bahrami } rtld_stat_t;
450*cb511613SAli Bahrami #endif
451*cb511613SAli Bahrami 
452*cb511613SAli Bahrami 
4537c478bd9Sstevel@tonic-gate /*
4547c478bd9Sstevel@tonic-gate  * Data declarations.
4557c478bd9Sstevel@tonic-gate  */
45610a4fa49Srie extern Lc_desc		glcs[];		/* global external interfaces */
45710a4fa49Srie 
4588cd45542Sraf extern	Rt_lock		rtldlock;	/* rtld lock */
4598cd45542Sraf extern	int		thr_flg_nolock;
4608cd45542Sraf extern	int		thr_flg_reenter;
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate extern List		dynlm_list;	/* dynamic list of link-maps */
4637c478bd9Sstevel@tonic-gate extern char		**environ;	/* environ pointer */
4647c478bd9Sstevel@tonic-gate 
4657c478bd9Sstevel@tonic-gate extern int		dyn_plt_ent_size; /* Size of dynamic plt's */
4667c478bd9Sstevel@tonic-gate extern ulong_t		at_flags;	/* machine specific file flags */
46741072f3cSrie extern const char	*procname;	/* file name of executing process */
4687c478bd9Sstevel@tonic-gate extern Rtld_db_priv	r_debug;	/* debugging information */
4697c478bd9Sstevel@tonic-gate extern char		*lasterr;	/* string describing last error */
4707c478bd9Sstevel@tonic-gate extern Interp		*interp;	/* ELF executable interpreter info */
47141072f3cSrie extern const char	*rtldname;	/* name of the dynamic linker */
4727c478bd9Sstevel@tonic-gate extern List		hdl_list[];	/* dlopen() handle list */
4737c478bd9Sstevel@tonic-gate extern size_t		syspagsz;	/* system page size */
4747c478bd9Sstevel@tonic-gate extern char		*platform; 	/* platform name */
4757c478bd9Sstevel@tonic-gate extern size_t		platform_sz; 	/* platform name string size */
4767c478bd9Sstevel@tonic-gate extern Isa_desc		*isa;		/* isalist descriptor */
4777c478bd9Sstevel@tonic-gate extern Uts_desc		*uts;		/* utsname descriptor */
4787c478bd9Sstevel@tonic-gate extern uint_t		rtld_flags;	/* status flags for RTLD */
4797c478bd9Sstevel@tonic-gate extern uint_t		rtld_flags2;	/* additional status flags for RTLD */
4807c478bd9Sstevel@tonic-gate extern Fmap		*fmap;		/* Initial file mapping info */
4817c478bd9Sstevel@tonic-gate extern uint32_t		pltcnt21d;	/* cnt of 21d PLTs */
4827c478bd9Sstevel@tonic-gate extern uint32_t		pltcnt24d;	/* cnt of 24d PLTs */
4837c478bd9Sstevel@tonic-gate extern uint32_t		pltcntu32;	/* cnt of u32 PLTs */
4847c478bd9Sstevel@tonic-gate extern uint32_t		pltcntu44;	/* cnt of u44 PLTs */
4857c478bd9Sstevel@tonic-gate extern uint32_t		pltcntfull;	/* cnt of full PLTs */
4867c478bd9Sstevel@tonic-gate extern uint32_t		pltcntfar;	/* cnt of far PLTs */
4877c478bd9Sstevel@tonic-gate extern uchar_t		search_rules[];	/* dependency search rules */
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate extern Fct		elf_fct;	/* ELF file class dependent data */
4907c478bd9Sstevel@tonic-gate 
49102ca3e02Srie #if	defined(__sparc) && !defined(__sparcv9)
4927c478bd9Sstevel@tonic-gate extern Fct		aout_fct;	/* a.out (4.x) file class dependent */
4937c478bd9Sstevel@tonic-gate 					/*	data */
4947c478bd9Sstevel@tonic-gate #endif
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate extern const char	*locale;		/* locale environment setting */
4977c478bd9Sstevel@tonic-gate 
4987c478bd9Sstevel@tonic-gate extern Config		*config;		/* configuration structure */
4997c478bd9Sstevel@tonic-gate extern const char	*locale;		/* locale environment setting */
5007c478bd9Sstevel@tonic-gate 
5017c478bd9Sstevel@tonic-gate extern const char	*rpl_audit;	/* replaceable LD_AUDIT string */
5027c478bd9Sstevel@tonic-gate extern const char	*rpl_debug;	/* replaceable LD_DEBUG string */
5037c478bd9Sstevel@tonic-gate extern const char	*rpl_ldflags;	/* replaceable LD_FLAGS string */
5047c478bd9Sstevel@tonic-gate extern const char	*rpl_libpath;	/* replaceable LD_LIBRARY string */
5057c478bd9Sstevel@tonic-gate extern Pnode		*rpl_libdirs;	/*	and its associated Pnode list */
5067c478bd9Sstevel@tonic-gate extern const char	*rpl_preload;	/* replaceable LD_PRELOAD string */
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate extern const char	*prm_audit;	/* permanent LD_AUDIT string */
5097c478bd9Sstevel@tonic-gate extern const char	*prm_debug;	/* permanent LD_DEBUG string */
5107c478bd9Sstevel@tonic-gate extern const char	*prm_ldflags;	/* permanent LD_FLAGS string */
5117c478bd9Sstevel@tonic-gate extern const char	*prm_libpath;	/* permanent LD_LIBRARY string */
5127c478bd9Sstevel@tonic-gate extern Pnode		*prm_libdirs;	/*	and its associated Pnode list */
5137c478bd9Sstevel@tonic-gate extern const char	*prm_preload;	/* permanent LD_PRELOAD string */
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate extern uint_t		env_info;	/* information regarding environment */
5167c478bd9Sstevel@tonic-gate 					/*	variables */
5177c478bd9Sstevel@tonic-gate extern int		killsig;	/* signal sent on fatal exit */
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate extern uint_t		audit_argcnt;	/* no. of stack args to copy */
5207c478bd9Sstevel@tonic-gate extern Audit_desc	*auditors;	/* global auditors */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate extern char		**_environ;
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate extern const char	*dbg_file;	/* debugging directed to a file */
5257c478bd9Sstevel@tonic-gate 
5267c478bd9Sstevel@tonic-gate extern Reglist		*reglist;	/* list of register symbols */
5277c478bd9Sstevel@tonic-gate 
5287c478bd9Sstevel@tonic-gate extern const Msg	err_reject[];	/* rejection error message tables */
5297c478bd9Sstevel@tonic-gate extern const Msg	ldd_reject[];
5307c478bd9Sstevel@tonic-gate 
5317c478bd9Sstevel@tonic-gate extern const char	*profile_name;	/* object being profiled */
5327c478bd9Sstevel@tonic-gate extern const char	*profile_out;	/* profile output file */
5337c478bd9Sstevel@tonic-gate extern const char	*profile_lib;	/* audit library to perform profile */
5347c478bd9Sstevel@tonic-gate 
53541072f3cSrie extern Dl_argsinfo	argsinfo;	/* process argument, environment and */
53641072f3cSrie 					/*	auxv information */
53741072f3cSrie 
5387c478bd9Sstevel@tonic-gate extern const char	*err_strs[];	/* diagnostic error string headers */
5397c478bd9Sstevel@tonic-gate extern const char	*nosym_str;	/* MSG_GEN_NOSYM message cache */
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate extern ulong_t		hwcap;		/* hardware capabilities */
5427c478bd9Sstevel@tonic-gate extern ulong_t		sfcap;		/* software capabilities */
5437c478bd9Sstevel@tonic-gate 
5449aa23310Srie extern avl_tree_t	*nfavl;		/* not-found AVL path name tree */
5459aa23310Srie 
5467c478bd9Sstevel@tonic-gate /*
5477c478bd9Sstevel@tonic-gate  * Function declarations.
5487c478bd9Sstevel@tonic-gate  */
5497c478bd9Sstevel@tonic-gate extern void		addfree(void *, size_t);
5507c478bd9Sstevel@tonic-gate extern int		append_alias(Rt_map *, const char *, int *);
5519aa23310Srie extern int		analyze_lmc(Lm_list *, Aliste, Rt_map *, int *);
5525aefb655Srie extern Am_ret		anon_map(Lm_list *, caddr_t *, size_t, int, int);
553*cb511613SAli Bahrami extern Fct		*are_u_this(Rej_desc *, int, rtld_stat_t *,
5547c478bd9Sstevel@tonic-gate 			    const char *);
5557c478bd9Sstevel@tonic-gate extern void		atexit_fini(void);
5567c478bd9Sstevel@tonic-gate extern int		bind_one(Rt_map *, Rt_map *, uint_t);
5577c478bd9Sstevel@tonic-gate extern int		bufprint(Prfbuf *, const char *, ...);
5585aefb655Srie extern void		call_array(Addr *, uint_t, Rt_map *, Word);
5597c478bd9Sstevel@tonic-gate extern void		call_fini(Lm_list *, Rt_map **);
5607c478bd9Sstevel@tonic-gate extern void		call_init(Rt_map **, int);
56160758829Srie extern int		callable(Rt_map *, Rt_map *, Grp_hdl *, uint_t);
5627c478bd9Sstevel@tonic-gate extern Rt_map		*_caller(caddr_t, int);
5637c478bd9Sstevel@tonic-gate extern caddr_t		caller(void);
5647c478bd9Sstevel@tonic-gate extern void		*calloc(size_t, size_t);
5657c478bd9Sstevel@tonic-gate extern void		cap_assign(Cap *, Rt_map *);
566bebb829dSRod Evans extern int		cap_check(Rej_desc *, Ehdr *);
5675aefb655Srie extern const char	*_conv_reloc_type(uint_t rel);
5685aefb655Srie extern uintptr_t	dbg_setup(const char *, Dbg_desc *);
5697c478bd9Sstevel@tonic-gate extern const char	*demangle(const char *);
5707c478bd9Sstevel@tonic-gate extern int		dlclose_intn(Grp_hdl *, Rt_map *);
57102ca3e02Srie extern int		dlclose_core(Grp_hdl *, Rt_map *, Lm_list *);
5727c478bd9Sstevel@tonic-gate extern Sym		*dlsym_handle(Grp_hdl *, Slookup *, Rt_map **,
5739aa23310Srie 			    uint_t *, int *);
5747c478bd9Sstevel@tonic-gate extern void		*dlsym_intn(void *, const char *, Rt_map *, Rt_map **);
5757c478bd9Sstevel@tonic-gate extern Grp_hdl		*dlmopen_intn(Lm_list *, const char *, int, Rt_map *,
5769aa23310Srie 			    uint_t, uint_t);
5777c478bd9Sstevel@tonic-gate extern size_t		doprf(const char *, va_list, Prfbuf *);
5787c478bd9Sstevel@tonic-gate extern int		dowrite(Prfbuf *);
5797c478bd9Sstevel@tonic-gate extern void		dz_init(int);
5805aefb655Srie extern caddr_t		dz_map(Lm_list *, caddr_t, size_t, int, int);
5817c478bd9Sstevel@tonic-gate extern int		elf_config(Rt_map *, int);
5827c478bd9Sstevel@tonic-gate extern int		elf_mach_flags_check(Rej_desc *, Ehdr *);
5837c478bd9Sstevel@tonic-gate extern Rtc_obj		*elf_config_ent(const char *, Word, int, const char **);
5845aefb655Srie extern Pnode		*elf_config_flt(Lm_list *, const char *, const char *);
5857c478bd9Sstevel@tonic-gate extern ulong_t		elf_hash(const char *);
5867c478bd9Sstevel@tonic-gate extern void 		elf_reloc_bad(Rt_map *, void *, uchar_t, ulong_t,
5877c478bd9Sstevel@tonic-gate 			    ulong_t);
5887c478bd9Sstevel@tonic-gate extern ulong_t		elf_reloc_relative(ulong_t, ulong_t, ulong_t,
5897c478bd9Sstevel@tonic-gate 			    ulong_t, ulong_t, ulong_t);
5907c478bd9Sstevel@tonic-gate extern ulong_t		elf_reloc_relacount(ulong_t, ulong_t,
5917c478bd9Sstevel@tonic-gate 			    ulong_t, ulong_t);
59202ca3e02Srie extern long		elf_static_tls(Rt_map *, Sym *, void *, uchar_t, char *,
593d326b23bSrie 			    ulong_t, long);
5948cd45542Sraf extern int		enter(int);
5957c478bd9Sstevel@tonic-gate extern uint_t		expand(char **, size_t *, char **, uint_t, uint_t,
5967c478bd9Sstevel@tonic-gate 			    Rt_map *);
5977c478bd9Sstevel@tonic-gate extern Pnode		*expand_paths(Rt_map *, const char *, uint_t, uint_t);
5988af2c5b9Srie extern void		free_hdl(Grp_hdl *, Rt_map *, uint_t);
5997c478bd9Sstevel@tonic-gate extern void		file_notfound(Lm_list *, const char *, Rt_map *,
6007c478bd9Sstevel@tonic-gate 			    uint_t, Rej_desc *);
6017c478bd9Sstevel@tonic-gate extern int		find_path(Lm_list *, const char *, Rt_map *, uint_t,
6029aa23310Srie 			    Fdesc *, Rej_desc *, int *);
6037c478bd9Sstevel@tonic-gate extern int		fpavl_insert(Lm_list *, Rt_map *, const char *,
6047c478bd9Sstevel@tonic-gate 			    avl_index_t);
6059aa23310Srie extern Rt_map		*fpavl_recorded(Lm_list *, const char *, avl_index_t *);
6067c478bd9Sstevel@tonic-gate extern void		fpavl_remove(Rt_map *);
6077c478bd9Sstevel@tonic-gate extern size_t		fullpath(Rt_map *, const char *);
6087c478bd9Sstevel@tonic-gate extern void		fmap_setup();
6097c478bd9Sstevel@tonic-gate extern void		get_lcinterface(Rt_map *, Lc_interface *);
6107c478bd9Sstevel@tonic-gate extern Lmid_t		get_linkmap_id(Lm_list *);
6117c478bd9Sstevel@tonic-gate extern Pnode		*get_next_dir(Pnode **, Rt_map *, uint_t);
6129a411307Srie extern int		hdl_add(Grp_hdl *, Rt_map *, uint_t);
6138af2c5b9Srie extern Grp_hdl		*hdl_create(Lm_list *, Rt_map *, Rt_map *, uint_t,
6148af2c5b9Srie 			    uint_t, uint_t);
61502ca3e02Srie extern int		hdl_initialize(Grp_hdl *, Rt_map *, int, int);
61602ca3e02Srie extern Pnode 		*hwcap_filtees(Pnode **, Aliste, Lm_cntl *, Dyninfo *,
6179aa23310Srie 			    Rt_map *, const char *, int, uint_t, int *);
6189a411307Srie extern void		is_dep_ready(Rt_map *, Rt_map *, int);
6199a411307Srie extern void		is_dep_init(Rt_map *, Rt_map *);
620466e2a62Srie extern int		is_move_data(caddr_t);
621247b82a1SRod Evans extern int		is_path_secure(char *, Rt_map *, uint_t, uint_t);
6223dbfc803SRod Evans extern int		is_rtld_setuid();
6239a411307Srie extern int		is_sym_interposer(Rt_map *, Sym *);
6249a411307Srie extern void		ldso_plt_init(Rt_map *);
6257c478bd9Sstevel@tonic-gate extern Listnode		*list_append(List *, const void *);
6267c478bd9Sstevel@tonic-gate extern Listnode		*list_insert(List *, const void *, Listnode *);
6277c478bd9Sstevel@tonic-gate extern Listnode		*list_prepend(List *, const void *);
6287c478bd9Sstevel@tonic-gate extern void		list_delete(List *, void *);
6298cd45542Sraf extern void		leave(Lm_list *, int);
6307c478bd9Sstevel@tonic-gate extern void		lm_append(Lm_list *, Aliste, Rt_map *);
6317c478bd9Sstevel@tonic-gate extern void		lm_delete(Lm_list *, Rt_map *);
6327c478bd9Sstevel@tonic-gate extern void		lm_move(Lm_list *, Aliste, Aliste, Lm_cntl *,
6337c478bd9Sstevel@tonic-gate 			    Lm_cntl *);
6347247f888Srie extern void		load_completion(Rt_map *);
6357c478bd9Sstevel@tonic-gate extern Rt_map 		*load_hwcap(Lm_list *, Aliste, const char *, Rt_map *,
6369aa23310Srie 			    uint_t, uint_t, Grp_hdl **, Rej_desc *, int *);
6377247f888Srie extern Rt_map		*load_path(Lm_list *, Aliste, const char **, Rt_map *,
6389aa23310Srie 			    int, uint_t, Grp_hdl **, Fdesc *, Rej_desc *,
6399aa23310Srie 			    int *);
6407c478bd9Sstevel@tonic-gate extern Rt_map		*load_one(Lm_list *, Aliste, Pnode *, Rt_map *, int,
6419aa23310Srie 			    uint_t, Grp_hdl **, int *);
6427247f888Srie extern int		load_trace(Lm_list *, const char **, Rt_map *);
6439aa23310Srie extern void		nfavl_insert(const char *, avl_index_t);
6449aa23310Srie extern int		nfavl_recorded(const char *, avl_index_t *);
6455aefb655Srie extern caddr_t		nu_map(Lm_list *, caddr_t, size_t, int, int);
6467c478bd9Sstevel@tonic-gate extern void		*malloc(size_t);
647466e2a62Srie extern int		move_data(Rt_map *);
6485aefb655Srie extern int		pr_open(Lm_list *);
6497c478bd9Sstevel@tonic-gate extern void		rd_event(Lm_list *, rd_event_e, r_state_e);
6507c478bd9Sstevel@tonic-gate extern int		readenv_user(const char **, Word *, Word *, int);
6517c478bd9Sstevel@tonic-gate extern int		readenv_config(Rtc_env *, Addr, int);
65231fdd7caSab extern void		rejection_inherit(Rej_desc *, Rej_desc *);
6539aa23310Srie extern int		relocate_lmc(Lm_list *, Aliste, Rt_map *, Rt_map *,
6549aa23310Srie 			    int *);
655cce0e03bSab extern int		relocate_finish(Rt_map *, APlist *, int, int);
6567c478bd9Sstevel@tonic-gate extern void		remove_cntl(Lm_list *, Aliste);
6577c478bd9Sstevel@tonic-gate extern int		remove_hdl(Grp_hdl *, Rt_map *, int *);
65802ca3e02Srie extern void		remove_lmc(Lm_list *, Rt_map *, Lm_cntl *, Aliste,
65902ca3e02Srie 			    const char *);
6607c478bd9Sstevel@tonic-gate extern void		remove_incomplete(Lm_list *, Aliste);
6617c478bd9Sstevel@tonic-gate extern void		remove_lists(Rt_map *, int);
6627c478bd9Sstevel@tonic-gate extern void		remove_lml(Lm_list *);
6637c478bd9Sstevel@tonic-gate extern void		remove_pnode(Pnode *);
6647c478bd9Sstevel@tonic-gate extern void		remove_rej(Rej_desc *);
6657c478bd9Sstevel@tonic-gate extern void		remove_so(Lm_list *, Rt_map *);
6667c478bd9Sstevel@tonic-gate extern int		rt_cond_broadcast(Rt_cond *);
6677c478bd9Sstevel@tonic-gate extern Rt_cond		*rt_cond_create(void);
6687c478bd9Sstevel@tonic-gate extern int		rt_cond_wait(Rt_cond *, Rt_lock *);
6697c478bd9Sstevel@tonic-gate extern int		rt_bind_guard(int);
6707c478bd9Sstevel@tonic-gate extern int		rt_bind_clear(int);
67110a4fa49Srie extern int		rt_get_extern(Lm_list *, Rt_map *);
6727c478bd9Sstevel@tonic-gate extern int		rt_mutex_lock(Rt_lock *);
6737c478bd9Sstevel@tonic-gate extern int		rt_mutex_unlock(Rt_lock *);
67410a4fa49Srie extern void		rt_thr_init(Lm_list *);
6757c478bd9Sstevel@tonic-gate extern thread_t		rt_thr_self(void);
6765aefb655Srie extern void		rtld_db_dlactivity(Lm_list *);
6775aefb655Srie extern void		rtld_db_preinit(Lm_list *);
6785aefb655Srie extern void		rtld_db_postinit(Lm_list *);
6797c478bd9Sstevel@tonic-gate extern void		rtldexit(Lm_list *, int);
680*cb511613SAli Bahrami #ifndef _LP64
681*cb511613SAli Bahrami extern int		rtld_fstat(int, rtld_stat_t *restrict);
682*cb511613SAli Bahrami extern int		rtld_stat(const char *restrict, rtld_stat_t *restrict);
683*cb511613SAli Bahrami #endif
68441072f3cSrie extern int		rtld_getopt(char **, char ***, auxv_t **, Word *,
68541072f3cSrie 			    Word *, int);
6867c478bd9Sstevel@tonic-gate extern void		security(uid_t, uid_t, gid_t, gid_t, int);
6877c478bd9Sstevel@tonic-gate extern void		set_environ(Lm_list *);
68841072f3cSrie extern Rt_map		*setup(char **, auxv_t *, Word, char *, int, char *,
6897c478bd9Sstevel@tonic-gate 			    Dyn *, ulong_t, ulong_t, int fd, Phdr *, char *,
6907c478bd9Sstevel@tonic-gate 			    char **, int, uid_t, uid_t, gid_t, gid_t, void *,
6917c478bd9Sstevel@tonic-gate 			    int, uint_t);
6923dbfc803SRod Evans extern void		spavl_insert(const char *);
6933dbfc803SRod Evans extern int		spavl_recorded(const char *, avl_index_t *);
694d326b23bSrie extern int		tls_assign(Lm_list *, Rt_map *, Phdr *);
69510a4fa49Srie extern void		tls_modaddrem(Rt_map *, uint_t);
69610a4fa49Srie extern int		tls_statmod(Lm_list *, Rt_map *);
6977c478bd9Sstevel@tonic-gate extern Rt_map		**tsort(Rt_map *, int, int);
6987c478bd9Sstevel@tonic-gate extern void		unused(Lm_list *);
6997c478bd9Sstevel@tonic-gate extern int		update_mode(Rt_map *, int, int);
7007c478bd9Sstevel@tonic-gate extern void		zero(caddr_t, size_t);
7017c478bd9Sstevel@tonic-gate 
70202ca3e02Srie #if	defined(__sparc)
7037c478bd9Sstevel@tonic-gate /*
7047c478bd9Sstevel@tonic-gate  * SPARC Register symbol support.
7057c478bd9Sstevel@tonic-gate  */
7067c478bd9Sstevel@tonic-gate extern int		elf_regsyms(Rt_map *);
7077c478bd9Sstevel@tonic-gate extern void		set_sparc_g1(ulong_t);
7087c478bd9Sstevel@tonic-gate extern void		set_sparc_g2(ulong_t);
7097c478bd9Sstevel@tonic-gate extern void		set_sparc_g3(ulong_t);
7107c478bd9Sstevel@tonic-gate extern void		set_sparc_g4(ulong_t);
7117c478bd9Sstevel@tonic-gate extern void		set_sparc_g5(ulong_t);
7127c478bd9Sstevel@tonic-gate extern void		set_sparc_g6(ulong_t);
7137c478bd9Sstevel@tonic-gate extern void		set_sparc_g7(ulong_t);
71402ca3e02Srie #endif
7157c478bd9Sstevel@tonic-gate 
7167c478bd9Sstevel@tonic-gate extern long		_sysconfig(int);
7177c478bd9Sstevel@tonic-gate 
7187c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7197c478bd9Sstevel@tonic-gate }
7207c478bd9Sstevel@tonic-gate #endif
7217c478bd9Sstevel@tonic-gate 
7227c478bd9Sstevel@tonic-gate #endif /* __RTLD_H */
723