xref: /onnv-gate/usr/src/cmd/sgs/include/rtld.h (revision 8598:0867fc633d66)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211618Srie 
220Sstevel@tonic-gate /*
23*8598SRod.Evans@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate #ifndef	_RTLD_H
270Sstevel@tonic-gate #define	_RTLD_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
301824Srie  * Global include file for the runtime linker.
310Sstevel@tonic-gate  */
32*8598SRod.Evans@Sun.COM #include <sys/mman.h>
330Sstevel@tonic-gate #include <time.h>
340Sstevel@tonic-gate #include <sgs.h>
350Sstevel@tonic-gate #include <thread.h>
360Sstevel@tonic-gate #include <synch.h>
376206Sab196087 #include <link.h>
380Sstevel@tonic-gate #include <sys/avl.h>
390Sstevel@tonic-gate #include <alist.h>
401824Srie #include <libc_int.h>
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifdef	_SYSCALL32
430Sstevel@tonic-gate #include <inttypes.h>
440Sstevel@tonic-gate #endif
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #ifdef	__cplusplus
470Sstevel@tonic-gate extern "C" {
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /*
518394SAli.Bahrami@Sun.COM  * We use rtld_ino_t instead of ino_t so that we can get
528394SAli.Bahrami@Sun.COM  * access to large inode values from 32-bit code.
538394SAli.Bahrami@Sun.COM  */
548394SAli.Bahrami@Sun.COM #ifdef _LP64
558394SAli.Bahrami@Sun.COM typedef ino_t		rtld_ino_t;
568394SAli.Bahrami@Sun.COM #else
578394SAli.Bahrami@Sun.COM typedef ino64_t		rtld_ino_t;
588394SAli.Bahrami@Sun.COM #endif
598394SAli.Bahrami@Sun.COM 
600Sstevel@tonic-gate typedef struct rt_map	Rt_map;
61*8598SRod.Evans@Sun.COM typedef struct slookup	Slookup;
620Sstevel@tonic-gate 
630Sstevel@tonic-gate /*
640Sstevel@tonic-gate  * A binding descriptor.  Establishes the binding relationship between two
651618Srie  * objects, the caller (originator) and the dependency (destination).
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate typedef struct {
680Sstevel@tonic-gate 	Rt_map		*b_caller;	/* caller (originator) of a binding */
690Sstevel@tonic-gate 	Rt_map		*b_depend;	/* dependency (destination) of a */
700Sstevel@tonic-gate 					/*	binding */
710Sstevel@tonic-gate 	uint_t		b_flags;	/* relationship of caller to the */
720Sstevel@tonic-gate 					/*	dependency */
730Sstevel@tonic-gate } Bnd_desc;
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #define	BND_NEEDED	0x0001		/* caller NEEDED the dependency */
760Sstevel@tonic-gate #define	BND_REFER	0x0002		/* caller relocation references the */
770Sstevel@tonic-gate 					/*	dependency */
78280Srie #define	BND_FILTER	0x0004		/* pseudo binding to identify filter */
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * Private structure for communication between rtld_db and rtld.
820Sstevel@tonic-gate  *
831824Srie  * We must bump the version number when ever an update in one of the
841824Srie  * structures/fields that rtld_db reads is updated.  This hopefully permits
851824Srie  * rtld_db implementations of the future to recognize core files produced on
861824Srie  * older systems and deal with these core files accordingly.
870Sstevel@tonic-gate  *
88*8598SRod.Evans@Sun.COM  * As of version 'R_RTLDDB_VERSION <= 2' the following fields were valid for
89*8598SRod.Evans@Sun.COM  * core file examination (basically the public Link_map):
900Sstevel@tonic-gate  *
910Sstevel@tonic-gate  *		ADDR()
920Sstevel@tonic-gate  *		NAME()
930Sstevel@tonic-gate  *		DYN()
940Sstevel@tonic-gate  *		NEXT()
950Sstevel@tonic-gate  *		PREV()
960Sstevel@tonic-gate  *
97*8598SRod.Evans@Sun.COM  * Valid fields for R_RTLDDB_VERSION3
980Sstevel@tonic-gate  *
990Sstevel@tonic-gate  *		PATHNAME()
1000Sstevel@tonic-gate  *		PADSTART()
1010Sstevel@tonic-gate  *		PADIMLEN()
1020Sstevel@tonic-gate  *		MSIZE()
1030Sstevel@tonic-gate  *		FLAGS()
1040Sstevel@tonic-gate  *		FLAGS1()
1050Sstevel@tonic-gate  *
106*8598SRod.Evans@Sun.COM  * Valid fields for R_RTLDDB_VERSION4
1070Sstevel@tonic-gate  *
1080Sstevel@tonic-gate  *		TLSMODID()
1090Sstevel@tonic-gate  *
110*8598SRod.Evans@Sun.COM  * Valid fields for R_RTLDDB_VERSION5
1110Sstevel@tonic-gate  *
1120Sstevel@tonic-gate  *		Added rtld_flags & FLG_RT_RELOCED to stable flags range
1130Sstevel@tonic-gate  *
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate #define	R_RTLDDB_VERSION1	1	/* base version level - used for core */
1160Sstevel@tonic-gate 					/*	file examination */
1171824Srie #define	R_RTLDDB_VERSION2	2	/* minor revision - not relevant for */
1180Sstevel@tonic-gate 					/*	core files */
1190Sstevel@tonic-gate #define	R_RTLDDB_VERSION3	3
1200Sstevel@tonic-gate #define	R_RTLDDB_VERSION4	4
1210Sstevel@tonic-gate #define	R_RTLDDB_VERSION5	5
1220Sstevel@tonic-gate #define	R_RTLDDB_VERSION	R_RTLDDB_VERSION5	/* current version */
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate typedef struct rtld_db_priv {
1250Sstevel@tonic-gate 	struct r_debug	rtd_rdebug;	/* original r_debug structure */
1260Sstevel@tonic-gate 	Word		rtd_version;	/* version no. */
1270Sstevel@tonic-gate 	size_t		rtd_objpad;	/* padding around mmap()ed objects */
128*8598SRod.Evans@Sun.COM 	List		*rtd_dynlmlst;	/* pointer to Dynlm_list */
1290Sstevel@tonic-gate } Rtld_db_priv;
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate #ifdef _SYSCALL32
1320Sstevel@tonic-gate typedef struct rtld_db_priv32 {
1330Sstevel@tonic-gate 	struct r_debug32 rtd_rdebug;	/* original r_debug structure */
1340Sstevel@tonic-gate 	Elf32_Word	rtd_version;	/* version no. */
1350Sstevel@tonic-gate 	Elf32_Word	rtd_objpad;	/* padding around mmap()ed objects */
1360Sstevel@tonic-gate 	Elf32_Addr	rtd_dynlmlst;	/* pointer to Dynlm_list */
1370Sstevel@tonic-gate } Rtld_db_priv32;
1380Sstevel@tonic-gate #endif	/* _SYSCALL32 */
1390Sstevel@tonic-gate 
1401824Srie /*
1411824Srie  * External function definitions.  ld.so.1 must convey information to libc in
1421824Srie  * regards to threading.  libc also provides routines for atexit() and message
1431824Srie  * localization.  libc provides the necessary interfaces via its RTLDINFO
1441824Srie  * structure and/or later _ld_libc() calls.
1451824Srie  *
1461824Srie  * These external functions are maintained for each link-map list, and used
1471824Srie  * where appropriate.  The functions are associated with the object that
1481824Srie  * provided them, so that should the object be deleted (say, from an alternative
1491824Srie  * link-map), the functions can be removed.
1501824Srie  */
1511824Srie typedef struct {
1521824Srie 	Rt_map	*lc_lmp;			/* function provider */
1531824Srie 	union {
1541824Srie 		int		(*lc_func)();	/* external function pointer */
1551824Srie 		uintptr_t	lc_val;		/* external value */
1561824Srie 		char    	*lc_ptr;	/* external character pointer */
1571824Srie 	} lc_un;
1581824Srie } Lc_desc;
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate /*
1610Sstevel@tonic-gate  * Link map list definition.  Link-maps are used to describe each loaded object.
1620Sstevel@tonic-gate  * Lists of these link-maps describe the various namespaces within a process.
1630Sstevel@tonic-gate  * The process executable and its dependencies are maintained on the lml_main
1640Sstevel@tonic-gate  * list.  The runtime linker, and its dependencies are maintained on the
1650Sstevel@tonic-gate  * lml_rtld list.  Additional lists can be created (see dlmopen()) for such
1660Sstevel@tonic-gate  * things as auditors and their dependencies.
1670Sstevel@tonic-gate  *
1680Sstevel@tonic-gate  * Each link-map list maintains an Alist of one, or more, linked lists of
1690Sstevel@tonic-gate  * link-maps.  For backward compatibility, the lm_head/lm_tail elements are
1700Sstevel@tonic-gate  * initialized to the first linked-list of link-maps:
1710Sstevel@tonic-gate  *
1720Sstevel@tonic-gate  *      Lm_list
1730Sstevel@tonic-gate  *    ----------
1740Sstevel@tonic-gate  *   | lm_tail  | ------------------------------------
1750Sstevel@tonic-gate  *   | lm_head  | --------------------                |
1760Sstevel@tonic-gate  *   |          |                     |     Rt_map    |     Rt_map
1770Sstevel@tonic-gate  *   |          |                     |     ------    |     ------
1780Sstevel@tonic-gate  *   |          |          Alist       --> |      |   |--> |      |
1790Sstevel@tonic-gate  *   |          |        ---------    |    |      | --     |      |
1800Sstevel@tonic-gate  *   | lm_lists | ----> |         |   |    |      |    --> |      |
1810Sstevel@tonic-gate  *   |          |       |---------|   |    |      |   |    |      |
1820Sstevel@tonic-gate  *   |          |       | lc_head | --      ------    |     ------
1830Sstevel@tonic-gate  *   |          |       | lc_tail | ------------------
1840Sstevel@tonic-gate  *   |          |       |---------|
1850Sstevel@tonic-gate  *                      | lc_head |
1860Sstevel@tonic-gate  *                      | lc_tail |
1870Sstevel@tonic-gate  *                      |---------|
1880Sstevel@tonic-gate  *
1890Sstevel@tonic-gate  * Multiple link-map lists exist to support the addition of lazy loaded
1900Sstevel@tonic-gate  * families, filtee families, and dlopen() families.  The intent of these
1910Sstevel@tonic-gate  * lists is to insure that a family of objects that are to be loaded are
1920Sstevel@tonic-gate  * fully relocatable, and hence usable, before they become part of the main
1930Sstevel@tonic-gate  * (al_data[0]) link-map control list.  This main link-map control list is
1940Sstevel@tonic-gate  * the only list in existence when control is transferred to user code.
1950Sstevel@tonic-gate  *
1960Sstevel@tonic-gate  * During process initialization, the dynamic executable and its non-lazy
1970Sstevel@tonic-gate  * dependencies are maintained on al_data[0].  If a new object is loaded, then
1980Sstevel@tonic-gate  * this object is added to the next available control list [1], typically
1990Sstevel@tonic-gate  * al_data[1].  Any dependencies of this object that have not already been
2000Sstevel@tonic-gate  * loaded are added to the same control list.  Once all of the objects on the
2010Sstevel@tonic-gate  * new control list have been successfully relocated, the objects are moved from
2020Sstevel@tonic-gate  * the new control list to the highest control list to which objects of the new
2030Sstevel@tonic-gate  * control list bound to, typically al_data[1] to al_data[0].
2040Sstevel@tonic-gate  *
2050Sstevel@tonic-gate  * Each loading scenario can be broken down as follows:
2060Sstevel@tonic-gate  *
2070Sstevel@tonic-gate  *  setup() - only the initial link-map control list is used:
2080Sstevel@tonic-gate  *   i.	  create al_data[0]
2090Sstevel@tonic-gate  *   ii.  add new link-map for main on al_data[0]
2100Sstevel@tonic-gate  *   iii. analyze al_data[0] to add all non-lazy dependencies
2110Sstevel@tonic-gate  *   iv.  relocate al_data[0] dependencies.
2120Sstevel@tonic-gate  *
2130Sstevel@tonic-gate  *  dlopen() - the initiator can only be the initial link-map control list:
2140Sstevel@tonic-gate  *   i.   create al_data[1] from caller al_data[0]
2150Sstevel@tonic-gate  *   ii.  add new link-map for the dlopen'ed object on al_data[1]
2160Sstevel@tonic-gate  *   iii. analyze al_data[1] to add all non-lazy dependencies
2170Sstevel@tonic-gate  *   iv.  relocate al_data[1] dependencies, and move to al_data[0].
2180Sstevel@tonic-gate  *
2190Sstevel@tonic-gate  *  filtee and lazy loading processing - the initiator can be any link-map
2200Sstevel@tonic-gate  *  control list that is being relocated:
2210Sstevel@tonic-gate  *   i.   create al_data[y] from caller al_data[x]
2220Sstevel@tonic-gate  *   ii.  add new link-map for the new object on al_data[y]
2230Sstevel@tonic-gate  *   iii. analyze al_data[y] to add all non-lazy dependencies
2240Sstevel@tonic-gate  *   iv.  relocate al_data[y] dependencies, and move to al_data[x].
2250Sstevel@tonic-gate  *
2260Sstevel@tonic-gate  * This Alist therefore maintains a stack of link-map control lists.  The newest
2270Sstevel@tonic-gate  * link-map control list can locate symbols within any of the former lists,
2280Sstevel@tonic-gate  * however, control is not passed to a former list until the newest lists
2290Sstevel@tonic-gate  * processing is complete.  Thus, objects can't bind to new objects until they
2300Sstevel@tonic-gate  * have been fully analyzed and relocated.
2310Sstevel@tonic-gate  *
2320Sstevel@tonic-gate  * [1]  Note, additional link-map control list creation occurs after the head
2330Sstevel@tonic-gate  * link-map object (typically the dynamic executable) has been relocated.  This
2340Sstevel@tonic-gate  * staging is required to satisfy the binding requirements of copy relocations.
2350Sstevel@tonic-gate  * Copy relocations, effectively, transfer the bindings of the copied data
2360Sstevel@tonic-gate  * (say _iob in libc.so.1) to the copy location (_iob in the application).
2370Sstevel@tonic-gate  * Thus an object that might bind to the original copy data must be redirected
2380Sstevel@tonic-gate  * to the copy reference.  As the knowledge of a copy relocation having taken
2390Sstevel@tonic-gate  * place is only known after relocating the application, link-map control list
2400Sstevel@tonic-gate  * additions are suspended until after this relocation has completed.
2410Sstevel@tonic-gate  */
2420Sstevel@tonic-gate typedef struct {
2430Sstevel@tonic-gate 	Rt_map		*lc_head;
2440Sstevel@tonic-gate 	Rt_map		*lc_tail;
2455892Sab196087 	APlist		*lc_now;	/* pending promoted bind-now objects */
2460Sstevel@tonic-gate 	uint_t		lc_flags;
2470Sstevel@tonic-gate } Lm_cntl;
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate #define	LMC_FLG_ANALYZING	0x01	/* control list is being analyzed */
2500Sstevel@tonic-gate #define	LMC_FLG_RELOCATING	0x02	/* control list is being relocated */
2510Sstevel@tonic-gate #define	LMC_FLG_REANALYZE	0x04	/* repeat analysis (established when */
2520Sstevel@tonic-gate 					/*	interposers are added */
2530Sstevel@tonic-gate 
2541618Srie struct lm_list {
2550Sstevel@tonic-gate 	/*
2560Sstevel@tonic-gate 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
2570Sstevel@tonic-gate 	 */
2580Sstevel@tonic-gate 	Rt_map		*lm_head;	/* linked list pointers to active */
2590Sstevel@tonic-gate 	Rt_map		*lm_tail;	/*	link-map list */
2605892Sab196087 	APlist		*lm_handle;	/* not used by rtld_db - but spacing */
2610Sstevel@tonic-gate 					/*	is required for flags */
2620Sstevel@tonic-gate 	Word		lm_flags;
2630Sstevel@tonic-gate 	/*
2640Sstevel@tonic-gate 	 * END: Exposed to rtld_db - don't move, don't delete
2650Sstevel@tonic-gate 	 */
2661824Srie 	Alist		*lm_rti;	/* list of RTLDINFO tables */
2675067Srie 	Audit_list	*lm_alp;	/* audit list descriptor */
2680Sstevel@tonic-gate 	avl_tree_t	*lm_fpavl;	/* avl tree of objects loaded */
2690Sstevel@tonic-gate 	Alist		*lm_lists;	/* active and pending link-map lists */
2706Srie 	char		***lm_environ;	/* pointer to environment array */
2710Sstevel@tonic-gate 	Word		lm_tflags;	/* transferable flags */
2721618Srie 	uint_t		lm_obj;		/* total number of objs on link-map */
2731618Srie 	uint_t		lm_init;	/* new obj since last init processing */
2741618Srie 	uint_t		lm_lazy;	/* obj with pending lazy dependencies */
2751824Srie 	uint_t		lm_tls;		/* new obj that require TLS */
2761618Srie 	uint_t		lm_lmid;	/* unique link-map list identifier, */
2771618Srie 	char		*lm_lmidstr;	/* and associated diagnostic string */
2785892Sab196087 	APlist		*lm_actaudit;	/* list of pending audit activity */
2791824Srie 	Lc_desc		lm_lcs[CI_MAX];	/* external libc functions */
2801618Srie };
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate #ifdef	_SYSCALL32
2831618Srie struct lm_list32 {
2840Sstevel@tonic-gate 	/*
2850Sstevel@tonic-gate 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
2860Sstevel@tonic-gate 	 */
2870Sstevel@tonic-gate 	Elf32_Addr	lm_head;
2880Sstevel@tonic-gate 	Elf32_Addr	lm_tail;
2890Sstevel@tonic-gate 	Elf32_Addr	lm_handle;
2900Sstevel@tonic-gate 	Elf32_Word	lm_flags;
2910Sstevel@tonic-gate 	/*
2920Sstevel@tonic-gate 	 * END: Exposed to rtld_db - don't move, don't delete
2930Sstevel@tonic-gate 	 */
2941824Srie 	Elf32_Addr	lm_rti;
2950Sstevel@tonic-gate 	Elf32_Addr	lm_fpavl;
2960Sstevel@tonic-gate 	Elf32_Addr	lm_lists;
2976Srie 	Elf32_Addr	lm_environ;
2980Sstevel@tonic-gate 	Elf32_Word	lm_tflags;
2991618Srie 	uint_t		lm_obj;
3001618Srie 	uint_t		lm_init;
3011618Srie 	uint_t		lm_lazy;
3021824Srie 	uint_t		lm_tls;
3031618Srie 	uint_t		lm_lmid;
3041618Srie 	Elf32_Addr	lm_lmidstr;
3054679Srie 	Elf32_Addr	lm_actaudit;
3061824Srie 	Elf32_Addr	lm_lcs[CI_MAX];
3071618Srie };
3080Sstevel@tonic-gate #endif /* _SYSCALL32 */
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate /*
3110Sstevel@tonic-gate  * Possible Link_map list flags (Lm_list.lm_flags)
3120Sstevel@tonic-gate  */
3130Sstevel@tonic-gate /*
3140Sstevel@tonic-gate  * BEGIN: Exposed to rtld_db - don't move, don't delete
3150Sstevel@tonic-gate  */
3160Sstevel@tonic-gate #define	LML_FLG_BASELM		0x00000001	/* primary link-map */
3170Sstevel@tonic-gate #define	LML_FLG_RTLDLM		0x00000002	/* rtld link-map */
3180Sstevel@tonic-gate /*
3190Sstevel@tonic-gate  * END: Exposed to rtld_db - don't move, don't delete
3200Sstevel@tonic-gate  */
3210Sstevel@tonic-gate #define	LML_FLG_NOAUDIT		0x00000004	/* symbol auditing disabled */
3220Sstevel@tonic-gate #define	LML_FLG_PLTREL		0x00000008	/* deferred plt relocation */
3230Sstevel@tonic-gate 						/* 	initialization */
3240Sstevel@tonic-gate 						/*	(ld.so.1 only) */
3250Sstevel@tonic-gate #define	LML_FLG_HOLDLOCK	0x00000010	/* hold the rtld mutex lock */
3260Sstevel@tonic-gate #define	LML_FLG_ENVIRON		0x00000020	/* environ var initialized */
3270Sstevel@tonic-gate #define	LML_FLG_INTRPOSE	0x00000040	/* interposing objs on list */
3280Sstevel@tonic-gate #define	LML_FLG_LOCAUDIT	0x00000080	/* local auditors exists for */
3290Sstevel@tonic-gate 						/*	this link-map list */
3300Sstevel@tonic-gate #define	LML_FLG_LOADAVAIL	0x00000100	/* load anything available */
3310Sstevel@tonic-gate #define	LML_FLG_IGNRELERR	0x00000200	/* ignore relocation errors - */
3320Sstevel@tonic-gate 						/*	internal for crle(1) */
3330Sstevel@tonic-gate #define	LML_FLG_DBNOTIF		0x00000400	/* binding activity going on */
334280Srie #define	LML_FLG_STARTREL	0x00000800	/* relocation started */
335280Srie #define	LML_FLG_ATEXIT		0x00001000	/* atexit processing */
336280Srie #define	LML_FLG_OBJADDED	0x00002000	/* object(s) added */
337280Srie #define	LML_FLG_OBJDELETED	0x00004000	/* object(s) deleted */
338280Srie #define	LML_FLG_OBJREEVAL	0x00008000	/* existing object(s) needs */
339280Srie 						/*	tsort reevaluation */
3402850Srie #define	LML_FLG_NOPENDGLBLAZY	0x00010000	/* no pending, global, lazy */
3412850Srie 						/*	dependencies remain */
3423817Srie #define	LML_FLG_INTRPOSETSORT	0x00020000	/* interpose tsorting done */
3434679Srie #define	LML_FLG_AUDITNOTIFY	0x00040000	/* audit consistent required */
3445220Srie #define	LML_FLG_GROUPSEXIST	0x00080000	/* local groups exist */
3452850Srie 
3460Sstevel@tonic-gate #define	LML_FLG_TRC_LDDSTUB	0x00100000	/* identify lddstub */
3470Sstevel@tonic-gate #define	LML_FLG_TRC_ENABLE	0x00200000	/* tracing enabled (ldd) */
3480Sstevel@tonic-gate #define	LML_FLG_TRC_WARN	0x00400000	/* print warnings for undefs */
3490Sstevel@tonic-gate #define	LML_FLG_TRC_VERBOSE	0x00800000	/* verbose (versioning) trace */
3500Sstevel@tonic-gate #define	LML_FLG_TRC_SEARCH	0x01000000	/* trace search paths */
3510Sstevel@tonic-gate #define	LML_FLG_TRC_UNREF	0x02000000	/* trace unreferenced */
3520Sstevel@tonic-gate 						/*	dependencies */
3530Sstevel@tonic-gate #define	LML_FLG_TRC_UNUSED	0x04000000	/* trace unused dependencies */
3540Sstevel@tonic-gate #define	LML_FLG_TRC_INIT	0x08000000	/* print .init order */
3554947Srie #define	LML_FLG_TRC_NOUNRESWEAK	0x10000000	/* unresolved weak references */
3564947Srie 						/*	are not allowed */
3576150Srie #define	LML_FLG_TRC_NOPAREXT	0x20000000	/* unresolved PARENT/EXTERN */
3586150Srie 						/*	references are not */
3596150Srie 						/*	allowed */
3600Sstevel@tonic-gate #define	LML_MSK_TRC		0xfff00000	/* tracing mask */
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate /*
3630Sstevel@tonic-gate  * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map
3640Sstevel@tonic-gate  * list flags that can be propagated to any new link-map list created.
3650Sstevel@tonic-gate  */
3660Sstevel@tonic-gate #define	LML_TFLG_NOLAZYLD	0x00000001	/* lazy loading disabled */
3670Sstevel@tonic-gate #define	LML_TFLG_NODIRECT	0x00000002	/* direct bindings disabled */
3680Sstevel@tonic-gate 
3690Sstevel@tonic-gate #define	LML_TFLG_LOADFLTR	0x00000008	/* trigger filtee loading */
3700Sstevel@tonic-gate 
371*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_PREINIT	0x00001000	/* preinit (audit) exists */
372*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_OBJSEARCH	0x00002000	/* objsearch (audit) exists */
373*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_OBJOPEN	0x00004000	/* objopen (audit) exists */
374*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_OBJFILTER	0x00008000	/* objfilter (audit) exists */
375*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_OBJCLOSE	0x00010000	/* objclose (audit) exists */
376*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_SYMBIND	0x00020000	/* symbind (audit) exists */
377*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_PLTENTER	0x00040000	/* pltenter (audit) exists */
378*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_PLTEXIT	0x00080000	/* pltexit (audit) exists */
379*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_ACTIVITY	0x00100000	/* activity (audit) exists */
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate /*
382*8598SRod.Evans@Sun.COM  * NOTE: Each auditing module establishes a set of audit flags, AFLAGS(), that
383*8598SRod.Evans@Sun.COM  * define the auditing interfaces the module offers.  These auditing flags are
384*8598SRod.Evans@Sun.COM  * the LML_TFLG_AUD_ flags defined above.  Global auditors result in setting
385*8598SRod.Evans@Sun.COM  * the lm_tflags too.  Local auditors only use the AFLAGS().  All tests for
386*8598SRod.Evans@Sun.COM  * auditing inspect the lm_tflags and AFLAGS() for a specific auditing
387*8598SRod.Evans@Sun.COM  * interface, and thus use the same flag to test for both types of auditors.
3880Sstevel@tonic-gate  */
389*8598SRod.Evans@Sun.COM #define	LML_TFLG_AUD_MASK	0x0ffff000	/* audit interfaces mask */
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate /*
3925067Srie  * Define a Group Handle.
3935067Srie  *
3945067Srie  * The capability of ld.so.1 to associate a group of objects, look for symbols
3955067Srie  * within that group, ensure that groups are isolated from one another (with
3965067Srie  * regard to relocations), and to unload a group, centers around a handle.  This
3975067Srie  * data structure is tracked from the link-map HANDLE(), and is the structure
3985067Srie  * returned from dlopen(), and similar object loading capabilities such as
3995067Srie  * filter/filtee processing.
4005067Srie  *
4015067Srie  * A handle keeps track of all the dependencies of the associated object.
4025067Srie  * These dependencies may be added as objects are lazily loaded.  The core
4035067Srie  * dependencies on the handle are the ldd(1) list of the associated object.
4045067Srie  * The object assigned the handle, and the parent (or caller) who requested the
4055067Srie  * handle are also maintained as dependencies on the handle.
4065067Srie  *
4075067Srie  * Presently, an object may have two handles, one requested with RTLD_FIRST
4085067Srie  * and one without.
4095067Srie  *
4105067Srie  * A handle may be referenced by any number of parents (callers).  A reference
4115067Srie  * count tracks the number.  A dlclose() operation drops the reference count,
4125067Srie  * and when the count is zero, the handle is used to determine the family of
4135067Srie  * objects to unload.  As bindings may occur to objects on the handle from
4145067Srie  * other handles, it may not be possible to remove a complete family of
4155067Srie  * objects or that handle itself.  Handles in this state are moved to an orphan
4165067Srie  * list.  A handle on the orphan list is taken off the orphan list if the
4175067Srie  * associated object is reopened.  Otherwise, the handle remains on the orphan
4185067Srie  * list for the duration of the process.  The orphan list is inspected any time
4195067Srie  * objects are unloaded, to determine if the orphaned objects can also be
4205067Srie  * unloaded.
4215067Srie  *
4225067Srie  * Objects can be dlopened using RTLD_NOW.  This attribute requires that all
4235067Srie  * relocations of the object, and its dependencies are processed immediately,
4245067Srie  * before return to the caller.  Typically, an object is loaded without
4255067Srie  * RTLD_NOW, and procedure linkage relocations are satisfied when their
4265067Srie  * associated function is first called.  If an object is already loaded, and an
4275067Srie  * RTLD_NOW request is made, then the object, and its dependencies, most undergo
4285067Srie  * additional relocation processing.   This promotion from lazy binding to
4295067Srie  * immediate binding is carried out using handles, as the handle defines the
4305067Srie  * dependencies that must be processed.  A temporary handle is created for this
4315067Srie  * purpose, and is discarded immediately after the promotion operation has been
4325067Srie  * completed.
4330Sstevel@tonic-gate  */
4340Sstevel@tonic-gate typedef struct {
4351618Srie 	Alist		*gh_depends;	/* handle dependency list */
4361618Srie 	Rt_map		*gh_ownlmp;	/* handle owners link-map */
4371618Srie 	Lm_list		*gh_ownlml;	/* handle owners link-map list */
4380Sstevel@tonic-gate 	uint_t		gh_refcnt;	/* handle reference count */
4395067Srie 	uint_t		gh_flags;	/* handle flags (GPH_ values) */
4400Sstevel@tonic-gate } Grp_hdl;
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate #define	GPH_ZERO	0x0001		/* special handle for dlopen(0) */
4430Sstevel@tonic-gate #define	GPH_LDSO	0x0002		/* special handle for ld.so.1 */
4440Sstevel@tonic-gate #define	GPH_FIRST	0x0004		/* dlsym() can only use originating */
4450Sstevel@tonic-gate 					/*	dependency */
4465067Srie #define	GPH_FILTEE	0x0008		/* handle used to specify a filtee */
4475067Srie #define	GPH_INITIAL	0x0010		/* handle is initialized */
4485067Srie #define	GPH_NOPENDLAZY	0x0020		/* no pending lazy dependencies */
4492850Srie 					/*	remain for this handle */
4500Sstevel@tonic-gate 
4510Sstevel@tonic-gate /*
4525067Srie  * Define a Group Descriptor.
4535067Srie  *
4545067Srie  * Each dependency associated with a group handle is maintained by a group
4555067Srie  * descriptor.  The descriptor defines the associated dependency together with
4565067Srie  * flags that indicate how the dependency can be used.
4570Sstevel@tonic-gate  */
4580Sstevel@tonic-gate typedef struct {
459*8598SRod.Evans@Sun.COM 	Rt_map		*gd_depend;	/* dependency */
4605067Srie 	uint_t		gd_flags;	/* dependency flags (GPD_ values) */
4610Sstevel@tonic-gate } Grp_desc;
4620Sstevel@tonic-gate 
4634699Srie #define	GPD_DLSYM	0x0001		/* dependency available to dlsym() */
4644699Srie #define	GPD_RELOC	0x0002		/* dependency available to satisfy */
4654699Srie 					/*	relocation binding */
4664699Srie #define	GPD_ADDEPS	0x0004		/* dependencies of this dependency */
4670Sstevel@tonic-gate 					/*	should be added to handle */
4684699Srie #define	GPD_PARENT	0x0008		/* dependency is a parent */
4694699Srie #define	GPD_FILTER	0x0010		/* dependency is our filter */
4705067Srie #define	GPD_PROMOTE	0x0020		/* dependency is our RTLD_NOW */
4715067Srie 					/*	promoter */
4720Sstevel@tonic-gate #define	GPD_REMOVE	0x1000		/* descriptor is a candidate for */
4730Sstevel@tonic-gate 					/*	removal from the group */
4740Sstevel@tonic-gate 
4750Sstevel@tonic-gate /*
4760Sstevel@tonic-gate  * Define threading structures.  For compatibility with libthread (T1_VERSION 1
4770Sstevel@tonic-gate  * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a
4780Sstevel@tonic-gate  * readers/writers lock.
4790Sstevel@tonic-gate  */
4800Sstevel@tonic-gate typedef struct {
4810Sstevel@tonic-gate 	union {
4820Sstevel@tonic-gate 		mutex_t		l_mutex;
4830Sstevel@tonic-gate 		rwlock_t	l_rwlock;
4840Sstevel@tonic-gate 	} u;
4850Sstevel@tonic-gate } Rt_lock;
4860Sstevel@tonic-gate 
4870Sstevel@tonic-gate typedef	cond_t	Rt_cond;
4880Sstevel@tonic-gate 
4890Sstevel@tonic-gate /*
4900Sstevel@tonic-gate  * Define a dynamic section information descriptor.  This parallels the entries
4910Sstevel@tonic-gate  * in the .dynamic section and holds auxiliary information to implement lazy
4920Sstevel@tonic-gate  * loading and filtee processing.
4930Sstevel@tonic-gate  */
4940Sstevel@tonic-gate typedef struct {
4950Sstevel@tonic-gate 	uint_t	di_flags;
4960Sstevel@tonic-gate 	void	*di_info;
4970Sstevel@tonic-gate } Dyninfo;
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate #define	FLG_DI_STDFLTR	0x00001		/* .dynamic entry for DT_FILTER */
5000Sstevel@tonic-gate #define	FLG_DI_AUXFLTR	0x00002		/* .dynamic entry for DT_AUXILIARY */
5010Sstevel@tonic-gate #define	FLG_DI_SYMFLTR	0x00004		/* .dynamic entry for DT_SYMFILTER */
5020Sstevel@tonic-gate 					/*	and DT_SYMAUXILIARY */
5030Sstevel@tonic-gate #define	MSK_DI_FILTER	0x0000f		/* mask for all filter possibilities */
5040Sstevel@tonic-gate 
5055950Srie #define	FLG_DI_POSFLAG1	0x00010		/* .dynamic entry for DT_POSFLAG_1 */
5065950Srie #define	FLG_DI_NEEDED	0x00020		/* .dynamic entry for DT_NEEDED */
5075950Srie #define	FLG_DI_LAZY	0x00100		/* lazy needed entry - preceded by */
5085950Srie 					/*    DF_P1_LAZYLOAD (DT_POSFLAG_1) */
5095950Srie #define	FLG_DI_GROUP	0x00200		/* group needed entry - preceded by */
5105950Srie 					/*    DF_P1_GROUPPERM (DT_POSFLAG_1) */
5110Sstevel@tonic-gate 
5125950Srie #define	FLG_DI_LDD_DONE	0x01000		/* entry has been processed (ldd) */
5135950Srie #define	FLG_DI_LAZYFAIL	0x02000		/* the lazy loading of this entry */
5145950Srie 					/*    failed */
5150Sstevel@tonic-gate /*
5166387Srie  * Data structure to track AVL tree of pathnames.  This structure provides the
5176387Srie  * basis of both the "not-found" node tree, and the "full-path" node tree.  Both
5186387Srie  * of these trees persist for the life of a process, although the "not-found"
5196387Srie  * tree may be moved aside during a dlopen() or dlsym() fall back operation.
5200Sstevel@tonic-gate  */
5210Sstevel@tonic-gate typedef struct {
5226387Srie 	const char	*pn_name;	/* path name */
5236387Srie 	avl_node_t	pn_avl;		/* avl book-keeping (see SGSOFFSETOF) */
5246387Srie 	uint_t		pn_hash;	/* path name hash value */
5256387Srie } PathNode;
5266387Srie 
5276387Srie /*
5286387Srie  * Data structure to track AVL tree for full path names of objects that are
5296387Srie  * loaded into memory.
5306387Srie  */
5316387Srie typedef struct {
5326387Srie 	PathNode	fpn_node;	/* path node */
5330Sstevel@tonic-gate 	Rt_map		*fpn_lmp;	/* object link-map */
5346387Srie } FullPathNode;
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate /*
5375892Sab196087  * A given link-map can hold either a supplier or receiver copy
5385892Sab196087  * relocation list, but not both. This union is used to overlap
5395892Sab196087  * the space used for the two lists.
5405892Sab196087  */
5415892Sab196087 typedef union {
5425892Sab196087 	Alist	*rtc_r;		/* receiver list (Rel_copy) */
5435892Sab196087 	APlist	*rtc_s;		/* supplier list (Rt_map *) */
5445892Sab196087 } Rt_map_copy;
5455892Sab196087 
5465892Sab196087 
5475892Sab196087 /*
5480Sstevel@tonic-gate  * Link-map definition.
5490Sstevel@tonic-gate  */
5500Sstevel@tonic-gate struct rt_map {
5510Sstevel@tonic-gate 	/*
5520Sstevel@tonic-gate 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
5530Sstevel@tonic-gate 	 */
5540Sstevel@tonic-gate 	Link_map	rt_public;	/* public data */
555*8598SRod.Evans@Sun.COM 	const char	*rt_pathname;	/* full pathname of loaded object */
5560Sstevel@tonic-gate 	ulong_t		rt_padstart;	/* start of image (including padding) */
5570Sstevel@tonic-gate 	ulong_t		rt_padimlen;	/* size of image (including padding */
558*8598SRod.Evans@Sun.COM 	ulong_t		rt_msize;	/* total memory reservation range */
5590Sstevel@tonic-gate 	uint_t		rt_flags;	/* state flags, see FLG below */
5600Sstevel@tonic-gate 	uint_t		rt_flags1;	/* state flags1, see FL1 below */
5610Sstevel@tonic-gate 	ulong_t		rt_tlsmodid;	/* TLS module id */
5620Sstevel@tonic-gate 	/*
5630Sstevel@tonic-gate 	 * END: Exposed to rtld_db - don't move, don't delete
5640Sstevel@tonic-gate 	 */
5655892Sab196087 	APlist		*rt_alias;	/* list of linked file names */
5665892Sab196087 	APlist		*rt_fpnode;	/* list of FullpathNode AVL nodes */
5670Sstevel@tonic-gate 	char		*rt_runpath;	/* LD_RUN_PATH and its equivalent */
568*8598SRod.Evans@Sun.COM 	Alist		*rt_runlist;	/*	Pdesc structures */
5695892Sab196087 	APlist		*rt_depends;	/* list of dependencies */
5705892Sab196087 	APlist		*rt_callers;	/* list of callers */
5715892Sab196087 	APlist		*rt_handles;	/* dlopen handles */
5725892Sab196087 	APlist		*rt_groups;	/* groups we're a member of */
5730Sstevel@tonic-gate 	struct fct	*rt_fct;	/* file class table for this object */
5740Sstevel@tonic-gate 	void		*rt_priv;	/* private data, object type specific */
5750Sstevel@tonic-gate 	Lm_list		*rt_list;	/* link map list we belong to */
5760Sstevel@tonic-gate 	uint_t		rt_objfltrndx;	/* object filtees .dynamic index */
5770Sstevel@tonic-gate 	uint_t		rt_symsfltrcnt;	/* number of standard symbol filtees */
5780Sstevel@tonic-gate 	uint_t		rt_symafltrcnt;	/* number of auxiliary symbol filtees */
5790Sstevel@tonic-gate 	int		rt_mode;	/* usage mode, see RTLD mode flags */
580280Srie 	int		rt_sortval;	/* temporary buffer to traverse graph */
5810Sstevel@tonic-gate 	uint_t		rt_cycgroup;	/* cyclic group */
5820Sstevel@tonic-gate 	dev_t		rt_stdev;	/* device id and inode number for .so */
5838394SAli.Bahrami@Sun.COM 	rtld_ino_t	rt_stino;	/*	multiple inclusion checks */
584*8598SRod.Evans@Sun.COM 	const char	*rt_origname;	/* original pathname of loaded object */
5850Sstevel@tonic-gate 	size_t		rt_dirsz;	/*	and its size */
586*8598SRod.Evans@Sun.COM 	size_t		rt_lmsize;	/* size of the link-map allocation */
5875892Sab196087 	Rt_map_copy	rt_copy;	/* list of copy relocations */
5880Sstevel@tonic-gate 	Audit_desc	*rt_auditors;	/* audit descriptor array */
5890Sstevel@tonic-gate 	Audit_info	*rt_audinfo;	/* audit information descriptor */
5900Sstevel@tonic-gate 	Syminfo		*rt_syminfo;	/* elf .syminfo section - here */
5910Sstevel@tonic-gate 					/*	because it is checked in */
5920Sstevel@tonic-gate 					/*	common code */
5930Sstevel@tonic-gate 	Addr		*rt_initarray;	/* .initarray table */
5940Sstevel@tonic-gate 	Addr		*rt_finiarray;	/* .finiarray table */
5950Sstevel@tonic-gate 	Addr		*rt_preinitarray; /* .preinitarray table */
596*8598SRod.Evans@Sun.COM 	mmapobj_result_t *rt_mmaps;	/* array of mapping information */
5970Sstevel@tonic-gate 	uint_t		rt_mmapcnt;	/*	and associated number */
5980Sstevel@tonic-gate 	uint_t		rt_initarraysz;	/* size of .initarray table */
5990Sstevel@tonic-gate 	uint_t		rt_finiarraysz;	/* size of .finiarray table */
6000Sstevel@tonic-gate 	uint_t		rt_preinitarraysz; /* size of .preinitarray table */
6010Sstevel@tonic-gate 	Dyninfo		*rt_dyninfo;	/* .dynamic information descriptors */
6020Sstevel@tonic-gate 	uint_t		rt_dyninfocnt;	/* count of dyninfo entries */
6030Sstevel@tonic-gate 	uint_t		rt_relacount;	/* no. of RELATIVE relocations */
6040Sstevel@tonic-gate 	uint_t		rt_idx;		/* hold index within linkmap list */
6050Sstevel@tonic-gate 	uint_t		rt_lazy;	/* lazy dependencies pending */
6060Sstevel@tonic-gate 	Xword		rt_hwcap;	/* hardware capabilities */
6070Sstevel@tonic-gate 	Xword		rt_sfcap;	/* software capabilities */
6080Sstevel@tonic-gate 	uint_t		rt_cntl;	/* link-map control list we belong to */
609*8598SRod.Evans@Sun.COM 	uint_t		rt_aflags;	/* auditor flags, see LML_TFLG_AUD_ */
610*8598SRod.Evans@Sun.COM 					/* address of _init */
611*8598SRod.Evans@Sun.COM 	void		(*rt_init)(void);
612*8598SRod.Evans@Sun.COM 					/* address of _fini */
613*8598SRod.Evans@Sun.COM 	void		(*rt_fini)(void);
614*8598SRod.Evans@Sun.COM 					/* link map symbol interpreter */
615*8598SRod.Evans@Sun.COM 	Sym		*(*rt_symintp)(Slookup *, Rt_map **, uint_t *, int *);
6160Sstevel@tonic-gate };
6170Sstevel@tonic-gate 
6180Sstevel@tonic-gate #ifdef _SYSCALL32
6190Sstevel@tonic-gate /*
6200Sstevel@tonic-gate  * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs.
6210Sstevel@tonic-gate  */
6225892Sab196087 typedef union {
6235892Sab196087 	uint32_t	rtc_r;
6245892Sab196087 	uint32_t	rtc_s;
6255892Sab196087 } Rt_map_copy32;
6265892Sab196087 
6270Sstevel@tonic-gate typedef struct rt_map32 {
6280Sstevel@tonic-gate 	/*
6290Sstevel@tonic-gate 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
6300Sstevel@tonic-gate 	 */
6310Sstevel@tonic-gate 	Link_map32	rt_public;
6320Sstevel@tonic-gate 	uint32_t	rt_pathname;
6330Sstevel@tonic-gate 	uint32_t	rt_padstart;
6340Sstevel@tonic-gate 	uint32_t	rt_padimlen;
6350Sstevel@tonic-gate 	uint32_t	rt_msize;
6360Sstevel@tonic-gate 	uint32_t	rt_flags;
6370Sstevel@tonic-gate 	uint32_t	rt_flags1;
6380Sstevel@tonic-gate 	uint32_t	rt_tlsmodid;
6390Sstevel@tonic-gate 	/*
6400Sstevel@tonic-gate 	 * END: Exposed to rtld_db - don't move, don't delete
6410Sstevel@tonic-gate 	 */
6420Sstevel@tonic-gate 	uint32_t	rt_alias;
6430Sstevel@tonic-gate 	uint32_t	rt_fpnode;
6440Sstevel@tonic-gate 	uint32_t	rt_runpath;
6450Sstevel@tonic-gate 	uint32_t	rt_runlist;
6460Sstevel@tonic-gate 	uint32_t	rt_depends;
6470Sstevel@tonic-gate 	uint32_t	rt_callers;
6480Sstevel@tonic-gate 	uint32_t	rt_handles;
6490Sstevel@tonic-gate 	uint32_t	rt_groups;
6500Sstevel@tonic-gate 	uint32_t	rt_fct;
6510Sstevel@tonic-gate 	uint32_t	rt_priv;
6520Sstevel@tonic-gate 	uint32_t 	rt_list;
6530Sstevel@tonic-gate 	uint32_t 	rt_objfltrndx;
6540Sstevel@tonic-gate 	uint32_t 	rt_symsfltrcnt;
6550Sstevel@tonic-gate 	uint32_t 	rt_symafltrcnt;
656280Srie 	int32_t		rt_mode;
657280Srie 	int32_t		rt_sortval;
6580Sstevel@tonic-gate 	uint32_t	rt_cycgroup;
6590Sstevel@tonic-gate 	uint32_t	rt_stdev;
6600Sstevel@tonic-gate 	uint32_t	rt_stino;
6610Sstevel@tonic-gate 	uint32_t	rt_origname;
6620Sstevel@tonic-gate 	uint32_t	rt_dirsz;
6635892Sab196087 	Rt_map_copy32	rt_copy;
6640Sstevel@tonic-gate 	uint32_t 	rt_auditors;
6650Sstevel@tonic-gate 	uint32_t 	rt_audinfo;
6660Sstevel@tonic-gate 	uint32_t	rt_syminfo;
6670Sstevel@tonic-gate 	uint32_t	rt_initarray;
6680Sstevel@tonic-gate 	uint32_t	rt_finiarray;
6690Sstevel@tonic-gate 	uint32_t	rt_preinitarray;
6700Sstevel@tonic-gate 	uint32_t	rt_mmaps;
6710Sstevel@tonic-gate 	uint32_t	rt_mmapcnt;
6720Sstevel@tonic-gate 	uint32_t	rt_initarraysz;
6730Sstevel@tonic-gate 	uint32_t	rt_finiarraysz;
6740Sstevel@tonic-gate 	uint32_t	rt_preinitarraysz;
6750Sstevel@tonic-gate 	uint32_t 	rt_dyninfo;
6760Sstevel@tonic-gate 	uint32_t 	rt_dyninfocnt;
6770Sstevel@tonic-gate 	uint32_t	rt_relacount;
6780Sstevel@tonic-gate 	uint32_t	rt_idx;
6790Sstevel@tonic-gate 	uint32_t	rt_lazy;
6800Sstevel@tonic-gate 	uint32_t	rt_hwcap;
6810Sstevel@tonic-gate 	uint32_t	rt_sfcap;
6820Sstevel@tonic-gate 	uint32_t	rt_cntl;
683*8598SRod.Evans@Sun.COM 	uint32_t	rt_aflags;
684*8598SRod.Evans@Sun.COM 	uint32_t 	rt_init;
685*8598SRod.Evans@Sun.COM 	uint32_t	rt_fini;
686*8598SRod.Evans@Sun.COM 	uint32_t	rt_symintp;
6870Sstevel@tonic-gate } Rt_map32;
6880Sstevel@tonic-gate 
6890Sstevel@tonic-gate #endif	/* _SYSCALL32 */
6900Sstevel@tonic-gate 
6910Sstevel@tonic-gate /*
6920Sstevel@tonic-gate  * Link map state flags.
6930Sstevel@tonic-gate  */
6940Sstevel@tonic-gate /*
6950Sstevel@tonic-gate  * BEGIN: Exposed to rtld_db - don't move, don't delete
6960Sstevel@tonic-gate  */
6970Sstevel@tonic-gate #define	FLG_RT_ISMAIN	0x00000001	/* object represents main executable */
6980Sstevel@tonic-gate #define	FLG_RT_IMGALLOC	0x00000002	/* image is allocated (not mmap'ed) */
6990Sstevel@tonic-gate 	/*
700*8598SRod.Evans@Sun.COM 	 * Available for r_debug version >= R_RTLDDB_VERSION5
7010Sstevel@tonic-gate 	 */
7020Sstevel@tonic-gate #define	FLG_RT_RELOCED	0x00000004	/* object has been relocated */
7030Sstevel@tonic-gate /*
7040Sstevel@tonic-gate  * END: Exposed to rtld_db - don't move, don't delete
7050Sstevel@tonic-gate  */
7060Sstevel@tonic-gate #define	FLG_RT_SETGROUP	0x00000008	/* group establishment required */
7070Sstevel@tonic-gate #define	FLG_RT_HWCAP	0x00000010	/* process $HWCAP expansion */
7080Sstevel@tonic-gate #define	FLG_RT_OBJECT	0x00000020	/* object processing (ie. .o's) */
70964Srie #define	FLG_RT_NEWLOAD	0x00000040	/* object is newly loaded */
7100Sstevel@tonic-gate #define	FLG_RT_NODUMP	0x00000080	/* object can't be dldump(3x)'ed */
7110Sstevel@tonic-gate #define	FLG_RT_DELETE	0x00000100	/* object can be deleted */
7120Sstevel@tonic-gate #define	FLG_RT_ANALYZED	0x00000200	/* object has been analyzed */
7130Sstevel@tonic-gate #define	FLG_RT_INITDONE	0x00000400	/* objects .init has been completed */
7140Sstevel@tonic-gate #define	FLG_RT_TRANS	0x00000800	/* object is acting as a translator */
7150Sstevel@tonic-gate #define	FLG_RT_FIXED	0x00001000	/* image location is fixed */
7160Sstevel@tonic-gate #define	FLG_RT_PRELOAD	0x00002000	/* object was preloaded */
7170Sstevel@tonic-gate #define	FLG_RT_ALTER	0x00004000	/* alternative object used */
7180Sstevel@tonic-gate #define	FLG_RT_LOADFLTR	0x00008000	/* trigger filtee loading */
7190Sstevel@tonic-gate #define	FLG_RT_AUDIT	0x00010000	/* object is an auditor */
7200Sstevel@tonic-gate #define	FLG_RT_MODESET	0x00020000	/* MODE() has been initialized */
7210Sstevel@tonic-gate #define	FLG_RT_ANALZING	0x00040000	/* object is being analyzed */
7220Sstevel@tonic-gate #define	FLG_RT_INITFRST 0x00080000	/* execute .init first */
7230Sstevel@tonic-gate #define	FLG_RT_NOOPEN	0x00100000	/* dlopen() not allowed */
7240Sstevel@tonic-gate #define	FLG_RT_FINICLCT	0x00200000	/* fini has been collected (tsort) */
7250Sstevel@tonic-gate #define	FLG_RT_INITCALL	0x00400000	/* objects .init has been called */
7268159SAli.Bahrami@Sun.COM #define	FLG_RT_OBJINTPO	0x00800000	/* object is a global interposer */
7278159SAli.Bahrami@Sun.COM #define	FLG_RT_SYMINTPO	0x01000000	/* object contains symbol interposer */
7288159SAli.Bahrami@Sun.COM #define	MSK_RT_INTPOSE	0x01800000	/* mask for all interposer */
7293466Srie 					/*	possibilities */
7308159SAli.Bahrami@Sun.COM #define	FLG_RT_MOVE	0x02000000	/* object needs move operation */
7318159SAli.Bahrami@Sun.COM #define	FLG_RT_TMPLIST	0x04000000	/* object is part of a temporary list */
7328159SAli.Bahrami@Sun.COM #define	FLG_RT_REGSYMS	0x08000000	/* object has DT_REGISTER entries */
7338159SAli.Bahrami@Sun.COM #define	FLG_RT_INITCLCT	0x10000000	/* init has been collected (tsort) */
7348159SAli.Bahrami@Sun.COM #define	FLG_RT_HANDLE	0x20000000	/* generate a handle for this object */
7358159SAli.Bahrami@Sun.COM #define	FLG_RT_RELOCING	0x40000000	/* object is being relocated */
7360Sstevel@tonic-gate 
7370Sstevel@tonic-gate #define	FL1_RT_COPYTOOK	0x00000001	/* copy relocation taken */
738*8598SRod.Evans@Sun.COM 
7390Sstevel@tonic-gate #define	FL1_RT_CONFSET	0x00000004	/* object was loaded by crle(1) */
7400Sstevel@tonic-gate #define	FL1_RT_NODEFLIB	0x00000008	/* ignore default library search */
7410Sstevel@tonic-gate #define	FL1_RT_ENDFILTE	0x00000010	/* filtee terminates filters search */
7420Sstevel@tonic-gate #define	FL1_RT_DISPREL	0x00000020	/* object has *disp* relocation */
743*8598SRod.Evans@Sun.COM #define	FL1_RT_DTFLAGS	0x00000040	/* DT_FLAGS element exists */
744*8598SRod.Evans@Sun.COM 
7450Sstevel@tonic-gate #define	FL1_RT_LDDSTUB	0x00000100	/* identify lddstub */
7460Sstevel@tonic-gate #define	FL1_RT_NOINIFIN	0x00000200	/* no .init or .fini exists */
7470Sstevel@tonic-gate #define	FL1_RT_USED	0x00000400	/* symbol referenced from this object */
7480Sstevel@tonic-gate #define	FL1_RT_SYMBOLIC	0x00000800	/* DF_SYMBOLIC was set - use */
7490Sstevel@tonic-gate 					/*	symbolic sym resolution */
7500Sstevel@tonic-gate #define	FL1_RT_OBJSFLTR	0x00001000	/* object is acting as a standard */
7510Sstevel@tonic-gate #define	FL1_RT_OBJAFLTR	0x00002000	/*	or auxiliary filter */
7520Sstevel@tonic-gate #define	FL1_RT_SYMSFLTR	0x00004000	/* symbol is acting as a standard */
7530Sstevel@tonic-gate #define	FL1_RT_SYMAFLTR	0x00008000	/*	or auxiliary filter */
7545067Srie #define	MSK_RT_FILTER	0x0000f000	/* mask for all filter possibilities */
7550Sstevel@tonic-gate 
7561824Srie #define	FL1_RT_TLSADD	0x00010000	/* objects TLS has been registered */
7572145Srie #define	FL1_RT_TLSSTAT	0x00020000	/* object requires static TLS */
7583466Srie #define	FL1_RT_DIRECT	0x00040000	/* object has DIRECT bindings enabled */
7594679Srie #define	FL1_RT_GLOBAUD	0x00080000	/* establish global auditing */
7601824Srie 
7610Sstevel@tonic-gate /*
7620Sstevel@tonic-gate  * Flags for the tls_modactivity() routine
7630Sstevel@tonic-gate  */
7640Sstevel@tonic-gate #define	TM_FLG_MODADD	0x01		/* call tls_modadd() interface */
7650Sstevel@tonic-gate #define	TM_FLG_MODREM	0x02		/* call tls_modrem() interface */
7660Sstevel@tonic-gate 
7670Sstevel@tonic-gate /*
768*8598SRod.Evans@Sun.COM  * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION <= 2).
7690Sstevel@tonic-gate  */
7700Sstevel@tonic-gate #define	ADDR(X)		((X)->rt_public.l_addr)
7710Sstevel@tonic-gate #define	NAME(X)		((X)->rt_public.l_name)
7720Sstevel@tonic-gate #define	DYN(X)		((X)->rt_public.l_ld)
7730Sstevel@tonic-gate #define	NEXT(X)		((X)->rt_public.l_next)
7740Sstevel@tonic-gate #define	PREV(X)		((X)->rt_public.l_prev)
7750Sstevel@tonic-gate #define	REFNAME(X)	((X)->rt_public.l_refname)
7760Sstevel@tonic-gate 
7770Sstevel@tonic-gate /*
7788394SAli.Bahrami@Sun.COM  * An Rt_map starts with a Link_map, followed by other information.
7798394SAli.Bahrami@Sun.COM  * ld.so.1 allocates Rt_map structures, and then casts them to Link_map,
7808394SAli.Bahrami@Sun.COM  * and back, depending on context.
7818394SAli.Bahrami@Sun.COM  *
7828394SAli.Bahrami@Sun.COM  * On some platforms, Rt_map can have a higher alignment requirement
7838394SAli.Bahrami@Sun.COM  * than Link_map. On such platforms, the cast from Link_map to Rt_map will
7848394SAli.Bahrami@Sun.COM  * draw an E_BAD_PTR_CAST_ALIGN warning from lint. Since we allocate
7858394SAli.Bahrami@Sun.COM  * the memory as the higher alignment Rt_map, we know that this is a safe
7868394SAli.Bahrami@Sun.COM  * conversion. The LINKMAP_TO_RTMAP macro is used to handle the conversion
7878394SAli.Bahrami@Sun.COM  * in a manner that satisfies lint.
7888394SAli.Bahrami@Sun.COM  */
7898394SAli.Bahrami@Sun.COM #ifdef lint
7908394SAli.Bahrami@Sun.COM #define	LINKMAP_TO_RTMAP(X)	(Rt_map *)(void *)(X)
7918394SAli.Bahrami@Sun.COM #else
7928394SAli.Bahrami@Sun.COM #define	LINKMAP_TO_RTMAP(X)	(Rt_map *)(X)
7938394SAli.Bahrami@Sun.COM #endif
7948394SAli.Bahrami@Sun.COM 
7958394SAli.Bahrami@Sun.COM /*
7968394SAli.Bahrami@Sun.COM  * Convenience macros for the common case of using
7978394SAli.Bahrami@Sun.COM  * NEXT()/PREV() and casting the result to (Rt_map *)
7988394SAli.Bahrami@Sun.COM  */
7998394SAli.Bahrami@Sun.COM #define	NEXT_RT_MAP(X)	LINKMAP_TO_RTMAP(NEXT(X))
8008394SAli.Bahrami@Sun.COM #define	PREV_RT_MAP(X)	LINKMAP_TO_RTMAP(PREV(X))
8018394SAli.Bahrami@Sun.COM 
8028394SAli.Bahrami@Sun.COM /*
803*8598SRod.Evans@Sun.COM  * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION3).
8040Sstevel@tonic-gate  */
8050Sstevel@tonic-gate #define	PATHNAME(X)	((X)->rt_pathname)
8060Sstevel@tonic-gate #define	PADSTART(X)	((X)->rt_padstart)
8070Sstevel@tonic-gate #define	PADIMLEN(X)	((X)->rt_padimlen)
8080Sstevel@tonic-gate #define	MSIZE(X)	((X)->rt_msize)
8090Sstevel@tonic-gate #define	FLAGS(X)	((X)->rt_flags)
8100Sstevel@tonic-gate #define	FLAGS1(X)	((X)->rt_flags1)
811*8598SRod.Evans@Sun.COM 
812*8598SRod.Evans@Sun.COM /*
813*8598SRod.Evans@Sun.COM  * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION4).
814*8598SRod.Evans@Sun.COM  */
8150Sstevel@tonic-gate #define	TLSMODID(X)	((X)->rt_tlsmodid)
8160Sstevel@tonic-gate 
817*8598SRod.Evans@Sun.COM /*
818*8598SRod.Evans@Sun.COM  * Macros for getting to unexposed, link-map data.
819*8598SRod.Evans@Sun.COM  */
820*8598SRod.Evans@Sun.COM #define	LMSIZE(X)	((X)->rt_lmsize)
821*8598SRod.Evans@Sun.COM #define	AFLAGS(X)	((X)->rt_aflags)
8220Sstevel@tonic-gate #define	ALIAS(X)	((X)->rt_alias)
8230Sstevel@tonic-gate #define	FPNODE(X)	((X)->rt_fpnode)
8240Sstevel@tonic-gate #define	INIT(X)		((X)->rt_init)
8250Sstevel@tonic-gate #define	FINI(X)		((X)->rt_fini)
8260Sstevel@tonic-gate #define	RPATH(X)	((X)->rt_runpath)
8270Sstevel@tonic-gate #define	RLIST(X)	((X)->rt_runlist)
8280Sstevel@tonic-gate #define	DEPENDS(X)	((X)->rt_depends)
8290Sstevel@tonic-gate #define	CALLERS(X)	((X)->rt_callers)
8300Sstevel@tonic-gate #define	HANDLES(X)	((X)->rt_handles)
8310Sstevel@tonic-gate #define	GROUPS(X)	((X)->rt_groups)
8320Sstevel@tonic-gate #define	FCT(X)		((X)->rt_fct)
8330Sstevel@tonic-gate #define	SYMINTP(X)	((X)->rt_symintp)
8340Sstevel@tonic-gate #define	LIST(X)		((X)->rt_list)
8350Sstevel@tonic-gate #define	OBJFLTRNDX(X)	((X)->rt_objfltrndx)
8360Sstevel@tonic-gate #define	SYMSFLTRCNT(X)	((X)->rt_symsfltrcnt)
8370Sstevel@tonic-gate #define	SYMAFLTRCNT(X)	((X)->rt_symafltrcnt)
8380Sstevel@tonic-gate #define	MODE(X)		((X)->rt_mode)
8390Sstevel@tonic-gate #define	SORTVAL(X)	((X)->rt_sortval)
8400Sstevel@tonic-gate #define	CYCGROUP(X)	((X)->rt_cycgroup)
8410Sstevel@tonic-gate #define	STDEV(X)	((X)->rt_stdev)
8420Sstevel@tonic-gate #define	STINO(X)	((X)->rt_stino)
8430Sstevel@tonic-gate #define	ORIGNAME(X)	((X)->rt_origname)
8440Sstevel@tonic-gate #define	DIRSZ(X)	((X)->rt_dirsz)
8455892Sab196087 #define	COPY_R(X)	((X)->rt_copy.rtc_r)
8465892Sab196087 #define	COPY_S(X)	((X)->rt_copy.rtc_s)
8470Sstevel@tonic-gate #define	AUDITORS(X)	((X)->rt_auditors)
8480Sstevel@tonic-gate #define	AUDINFO(X)	((X)->rt_audinfo)
8490Sstevel@tonic-gate #define	SYMINFO(X)	((X)->rt_syminfo)
8500Sstevel@tonic-gate #define	INITARRAY(X)	((X)->rt_initarray)
8510Sstevel@tonic-gate #define	FINIARRAY(X)	((X)->rt_finiarray)
8520Sstevel@tonic-gate #define	PREINITARRAY(X)	((X)->rt_preinitarray)
8530Sstevel@tonic-gate #define	MMAPS(X)	((X)->rt_mmaps)
8540Sstevel@tonic-gate #define	MMAPCNT(X)	((X)->rt_mmapcnt)
8550Sstevel@tonic-gate #define	INITARRAYSZ(X)	((X)->rt_initarraysz)
8560Sstevel@tonic-gate #define	FINIARRAYSZ(X)	((X)->rt_finiarraysz)
8570Sstevel@tonic-gate #define	PREINITARRAYSZ(X) ((X)->rt_preinitarraysz)
8580Sstevel@tonic-gate #define	DYNINFO(X)	((X)->rt_dyninfo)
8590Sstevel@tonic-gate #define	DYNINFOCNT(X)	((X)->rt_dyninfocnt)
8600Sstevel@tonic-gate #define	RELACOUNT(X)	((X)->rt_relacount)
8610Sstevel@tonic-gate #define	IDX(X)		((X)->rt_idx)
8620Sstevel@tonic-gate #define	LAZY(X)		((X)->rt_lazy)
8630Sstevel@tonic-gate #define	CNTL(X)		((X)->rt_cntl)
8640Sstevel@tonic-gate #define	HWCAP(X)	((X)->rt_hwcap)
8650Sstevel@tonic-gate #define	SFCAP(X)	((X)->rt_sfcap)
8660Sstevel@tonic-gate 
867280Srie /*
868280Srie  * Flags for tsorting.
869280Srie  */
870280Srie #define	RT_SORT_FWD	0x01		/* topological sort (.fini) */
871280Srie #define	RT_SORT_REV	0x02		/* reverse topological sort (.init) */
872*8598SRod.Evans@Sun.COM #define	RT_SORT_DELETE	0x10		/* process FLG_RT_DELETE objects */
873280Srie 					/*	only (called via dlclose()) */
8743817Srie #define	RT_SORT_INTPOSE	0x20		/* process interposer objects */
8753817Srie 
8760Sstevel@tonic-gate /*
8770Sstevel@tonic-gate  * Flags for lookup_sym (and hence find_sym) routines.
8780Sstevel@tonic-gate  */
8790Sstevel@tonic-gate #define	LKUP_DEFT	0x0000		/* simple lookup request */
8800Sstevel@tonic-gate #define	LKUP_SPEC	0x0001		/* special ELF lookup (allows address */
8810Sstevel@tonic-gate 					/*	resolutions to plt[] entries) */
8820Sstevel@tonic-gate #define	LKUP_LDOT	0x0002		/* indicates the original A_OUT */
8830Sstevel@tonic-gate 					/*	symbol had a leading `.' */
8840Sstevel@tonic-gate #define	LKUP_FIRST	0x0004		/* lookup symbol in first link map */
8850Sstevel@tonic-gate 					/*	only */
8860Sstevel@tonic-gate #define	LKUP_COPY	0x0008		/* lookup symbol for a COPY reloc, do */
8870Sstevel@tonic-gate 					/*	not bind to symbol at head */
8885220Srie #define	LKUP_STDRELOC	0x0010		/* lookup originates from a standard */
8895220Srie 					/*	relocation (elf_reloc()) */
8900Sstevel@tonic-gate #define	LKUP_SELF	0x0020		/* lookup symbol in ourself - undef */
8910Sstevel@tonic-gate 					/*	is valid */
8920Sstevel@tonic-gate #define	LKUP_WEAK	0x0040		/* relocation reference is weak */
8930Sstevel@tonic-gate #define	LKUP_NEXT	0x0080		/* request originates from RTLD_NEXT */
8940Sstevel@tonic-gate #define	LKUP_NODESCENT	0x0100		/* don't descend through dependencies */
8955950Srie #define	LKUP_NOFALLBACK	0x0200		/* don't fall back to loading */
8960Sstevel@tonic-gate 					/*	pending lazy dependencies */
8970Sstevel@tonic-gate #define	LKUP_DIRECT	0x0400		/* direct binding request */
898502Srie #define	LKUP_SYMNDX	0x0800		/* establish symbol index */
8995220Srie #define	LKUP_SINGLETON	0x1000		/* search for a singleton symbol */
9005220Srie #define	LKUP_STANDARD	0x2000		/* standard lookup - originated from */
9015220Srie 					/* 	head link-map element */
9028388SRod.Evans@Sun.COM #define	LKUP_WORLD	0x4000		/* ensure world lookup */
9030Sstevel@tonic-gate 
9040Sstevel@tonic-gate /*
9055950Srie  * For the runtime linker to perform a symbol search, a number of data items
9065950Srie  * related to the search are required.  An Slookup data structure is used to
9075950Srie  * convey this data to lookup_sym(), and in special cases, to other core
9085950Srie  * routines that provide the implementation details for lookup_sym()
9095950Srie  *
9105950Srie  * The symbol name (sl_name), the caller (sl_cmap), and the link-map from which
9115950Srie  * to start the search (sl_imap) are fundamental to the symbol search.  The
9125950Srie  * initial search link-map might get modified by the core routines that provide
9135950Srie  * the implementation details for lookup_sym().  This modification accommodates
9145950Srie  * requirements such as processing a handle, direct binding and interposition.
9155950Srie  * The association between the caller and the potential destination also
9165950Srie  * determines whether the destination is a candidate to search.
9175950Srie  *
9185950Srie  * The lookup identifier (sl_id) is used to identify a runtime linker operation.
9195950Srie  * Within this operation, any lazy loads that fail are not re-examined.  This
9205950Srie  * technique keeps the overhead of processing a failed lazy load to a minimum.
9215950Srie  *
9225950Srie  * Symbol searches that originate from a relocation record are accompanied by
9235950Srie  * the relocation index (sl_rsymndx), the symbol reference (sl_rsym) and
9245950Srie  * possibly the relocation type (sl_rtype).  This data provides for determining
9255950Srie  * lazy loading, direct binding, and special symbol processing requirements
9265950Srie  * such as copy relocations and singleton lookup.
9275950Srie  *
9285950Srie  * The symbols hash value is computed by lookup_sym, and propagated throughout
9295950Srie  * the search engine.  Note, occasionally the Slookup data is passed to a core
9305950Srie  * routine that provides the implementation details for lookup_sym(), ie.
9315950Srie  * elf_find_sym(), in which case the caller must initialize the hash value.
9325950Srie  *
9335950Srie  * The symbols binding information is established by lookup_sym() when the
9345950Srie  * symbols relocation type is supplied.  Weak bindings allow relocations to
9355950Srie  * be set to zero should a symbol lookup fail.
9365950Srie  *
9375950Srie  * The flags allow the caller to control aspects of the search, including the
9385950Srie  * interpretation of copy relocations, etc.  Note, a number of flag settings
9395950Srie  * are established in lookup_sym() from attributes of the symbol reference.
9400Sstevel@tonic-gate  */
941*8598SRod.Evans@Sun.COM struct slookup {
9420Sstevel@tonic-gate 	const char	*sl_name;	/* symbol name */
9430Sstevel@tonic-gate 	Rt_map		*sl_cmap;	/* callers link-map */
9440Sstevel@tonic-gate 	Rt_map		*sl_imap;	/* initial link-map to search */
9455950Srie 	ulong_t		sl_id;		/* identifier for this lookup */
9460Sstevel@tonic-gate 	ulong_t		sl_hash;	/* symbol hash value */
9470Sstevel@tonic-gate 	ulong_t		sl_rsymndx;	/* referencing reloc symndx */
9485220Srie 	Sym		*sl_rsym;	/* referencing symbol */
9495220Srie 	uchar_t		sl_rtype;	/* relocation type associate with */
9505220Srie 					/*    symbol */
9515220Srie 	uchar_t		sl_bind;	/* symbols binding (returned) */
9520Sstevel@tonic-gate 	uint_t		sl_flags;	/* lookup flags */
953*8598SRod.Evans@Sun.COM };
9540Sstevel@tonic-gate 
9555950Srie #define	SLOOKUP_INIT(sl, name, cmap, imap, id, hash, rsymndx, rsym, rtype, \
9565950Srie     flags) \
9575950Srie 	(void) (sl.sl_name = (name), sl.sl_cmap = (cmap), sl.sl_imap = (imap), \
9585950Srie 	    sl.sl_id = (id), sl.sl_hash = (hash), sl.sl_rsymndx = (rsymndx), \
9595950Srie 	    sl.sl_rsym = (rsym), sl.sl_rtype = (rtype), sl.sl_bind = 0, \
9605950Srie 	    sl.sl_flags = (flags))
9610Sstevel@tonic-gate 
9625950Srie /*
9635950Srie  * Define a number of .plt lookup outcomes, for use in binding diagnostics.
9645950Srie  */
9650Sstevel@tonic-gate typedef	enum {
9660Sstevel@tonic-gate 	PLT_T_NONE = 0,
9670Sstevel@tonic-gate 	PLT_T_21D,
9680Sstevel@tonic-gate 	PLT_T_24D,
9690Sstevel@tonic-gate 	PLT_T_U32,
9700Sstevel@tonic-gate 	PLT_T_U44,
9710Sstevel@tonic-gate 	PLT_T_FULL,
9720Sstevel@tonic-gate 	PLT_T_FAR,
9730Sstevel@tonic-gate 	PLT_T_NUM			/* Must be last */
9740Sstevel@tonic-gate } Pltbindtype;
9750Sstevel@tonic-gate 
9760Sstevel@tonic-gate /*
9770Sstevel@tonic-gate  * Prototypes.
9780Sstevel@tonic-gate  */
9795950Srie extern ulong_t		ld_entry_cnt;	/* counter bumped on each entry to */
9805950Srie 					/*    ld.so.1. */
9810Sstevel@tonic-gate extern Lm_list		lml_main;	/* main's link map list */
9820Sstevel@tonic-gate extern Lm_list		lml_rtld;	/* rtld's link map list */
9830Sstevel@tonic-gate extern Lm_list		*lml_list[];
9840Sstevel@tonic-gate 
9850Sstevel@tonic-gate extern Pltbindtype	elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t,
9860Sstevel@tonic-gate 			    Xword);
9876387Srie extern Rt_map		*is_so_loaded(Lm_list *, const char *, int *);
9886387Srie extern Sym		*lookup_sym(Slookup *, Rt_map **, uint_t *, int *);
9890Sstevel@tonic-gate extern int		rt_dldump(Rt_map *, const char *, int, Addr);
9900Sstevel@tonic-gate 
9910Sstevel@tonic-gate #ifdef	__cplusplus
9920Sstevel@tonic-gate }
9930Sstevel@tonic-gate #endif
9940Sstevel@tonic-gate 
9950Sstevel@tonic-gate #endif /* _RTLD_H */
996