xref: /illumos-gate/usr/src/cmd/sgs/include/rtld.h (revision 63ea9ad24896f2939472f8f96f568086d190eb33)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #ifndef	_RTLD_H
27 #define	_RTLD_H
28 
29 /*
30  * Global include file for the runtime linker.
31  */
32 #include <sys/mman.h>
33 #include <time.h>
34 #include <sgs.h>
35 #include <thread.h>
36 #include <synch.h>
37 #include <link.h>
38 #include <sys/avl.h>
39 #include <alist.h>
40 #include <libc_int.h>
41 
42 #ifdef	_SYSCALL32
43 #include <inttypes.h>
44 #endif
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 /*
51  * We use rtld_ino_t instead of ino_t so that we can get
52  * access to large inode values from 32-bit code.
53  */
54 #ifdef _LP64
55 typedef ino_t		rtld_ino_t;
56 #else
57 typedef ino64_t		rtld_ino_t;
58 #endif
59 
60 typedef struct rt_map	Rt_map;
61 typedef struct slookup	Slookup;
62 
63 /*
64  * A binding descriptor.  Establishes the binding relationship between two
65  * objects, the caller (originator) and the dependency (destination).
66  */
67 typedef struct {
68 	Rt_map		*b_caller;	/* caller (originator) of a binding */
69 	Rt_map		*b_depend;	/* dependency (destination) of a */
70 					/*	binding */
71 	uint_t		b_flags;	/* relationship of caller to the */
72 					/*	dependency */
73 } Bnd_desc;
74 
75 #define	BND_NEEDED	0x0001		/* caller NEEDED the dependency */
76 #define	BND_REFER	0x0002		/* caller relocation references the */
77 					/*	dependency */
78 #define	BND_FILTER	0x0004		/* pseudo binding to identify filter */
79 
80 /*
81  * Private structure for communication between rtld_db and rtld.
82  *
83  * We must bump the version number when ever an update in one of the
84  * structures/fields that rtld_db reads is updated.  This hopefully permits
85  * rtld_db implementations of the future to recognize core files produced on
86  * older systems and deal with these core files accordingly.
87  *
88  * As of version 'R_RTLDDB_VERSION <= 2' the following fields were valid for
89  * core file examination (basically the public Link_map):
90  *
91  *		ADDR()
92  *		NAME()
93  *		DYN()
94  *		NEXT()
95  *		PREV()
96  *
97  * Valid fields for R_RTLDDB_VERSION3
98  *
99  *		PATHNAME()
100  *		PADSTART()
101  *		PADIMLEN()
102  *		MSIZE()
103  *		FLAGS()
104  *		FLAGS1()
105  *
106  * Valid fields for R_RTLDDB_VERSION4
107  *
108  *		TLSMODID()
109  *
110  * Valid fields for R_RTLDDB_VERSION5
111  *
112  *		Added rtld_flags & FLG_RT_RELOCED to stable flags range
113  *
114  */
115 #define	R_RTLDDB_VERSION1	1	/* base version level - used for core */
116 					/*	file examination */
117 #define	R_RTLDDB_VERSION2	2	/* minor revision - not relevant for */
118 					/*	core files */
119 #define	R_RTLDDB_VERSION3	3
120 #define	R_RTLDDB_VERSION4	4
121 #define	R_RTLDDB_VERSION5	5
122 #define	R_RTLDDB_VERSION	R_RTLDDB_VERSION5	/* current version */
123 
124 typedef struct rtld_db_priv {
125 	struct r_debug	rtd_rdebug;	/* original r_debug structure */
126 	Word		rtd_version;	/* version no. */
127 	size_t		rtd_objpad;	/* padding around mmap()ed objects */
128 	List		*rtd_dynlmlst;	/* pointer to Dynlm_list */
129 } Rtld_db_priv;
130 
131 #ifdef _SYSCALL32
132 typedef struct rtld_db_priv32 {
133 	struct r_debug32 rtd_rdebug;	/* original r_debug structure */
134 	Elf32_Word	rtd_version;	/* version no. */
135 	Elf32_Word	rtd_objpad;	/* padding around mmap()ed objects */
136 	Elf32_Addr	rtd_dynlmlst;	/* pointer to Dynlm_list */
137 } Rtld_db_priv32;
138 #endif	/* _SYSCALL32 */
139 
140 /*
141  * External function definitions.  ld.so.1 must convey information to libc in
142  * regards to threading.  libc also provides routines for atexit() and message
143  * localization.  libc provides the necessary interfaces via its RTLDINFO
144  * structure and/or later _ld_libc() calls.
145  *
146  * These external functions are maintained for each link-map list, and used
147  * where appropriate.  The functions are associated with the object that
148  * provided them, so that should the object be deleted (say, from an alternative
149  * link-map), the functions can be removed.
150  */
151 typedef struct {
152 	Rt_map	*lc_lmp;			/* function provider */
153 	union {
154 		int		(*lc_func)();	/* external function pointer */
155 		uintptr_t	lc_val;		/* external value */
156 		char    	*lc_ptr;	/* external character pointer */
157 	} lc_un;
158 } Lc_desc;
159 
160 /*
161  * Link map list definition.  Link-maps are used to describe each loaded object.
162  * Lists of these link-maps describe the various namespaces within a process.
163  * The process executable and its dependencies are maintained on the lml_main
164  * list.  The runtime linker, and its dependencies are maintained on the
165  * lml_rtld list.  Additional lists can be created (see dlmopen()) for such
166  * things as auditors and their dependencies.
167  *
168  * Each link-map list maintains an Alist of one, or more, linked lists of
169  * link-maps.  For backward compatibility, the lm_head/lm_tail elements are
170  * initialized to the first linked-list of link-maps:
171  *
172  *      Lm_list
173  *    ----------
174  *   | lm_tail  | ------------------------------------
175  *   | lm_head  | --------------------                |
176  *   |          |                     |     Rt_map    |     Rt_map
177  *   |          |                     |     ------    |     ------
178  *   |          |          Alist       --> |      |   |--> |      |
179  *   |          |        ---------    |    |      | --     |      |
180  *   | lm_lists | ----> |         |   |    |      |    --> |      |
181  *   |          |       |---------|   |    |      |   |    |      |
182  *   |          |       | lc_head | --      ------    |     ------
183  *   |          |       | lc_tail | ------------------
184  *   |          |       |---------|
185  *                      | lc_head |
186  *                      | lc_tail |
187  *                      |---------|
188  *
189  * Multiple link-map lists exist to support the addition of lazy loaded
190  * families, filtee families, and dlopen() families.  The intent of these
191  * lists is to insure that a family of objects that are to be loaded are
192  * fully relocatable, and hence usable, before they become part of the main
193  * (al_data[0]) link-map control list.  This main link-map control list is
194  * the only list in existence when control is transferred to user code.
195  *
196  * During process initialization, the dynamic executable and its non-lazy
197  * dependencies are maintained on al_data[0].  If a new object is loaded, then
198  * this object is added to the next available control list [1], typically
199  * al_data[1].  Any dependencies of this object that have not already been
200  * loaded are added to the same control list.  Once all of the objects on the
201  * new control list have been successfully relocated, the objects are moved from
202  * the new control list to the highest control list to which objects of the new
203  * control list bound to, typically al_data[1] to al_data[0].
204  *
205  * Each loading scenario can be broken down as follows:
206  *
207  *  setup() - only the initial link-map control list is used:
208  *   i.	  create al_data[0]
209  *   ii.  add new link-map for main on al_data[0]
210  *   iii. analyze al_data[0] to add all non-lazy dependencies
211  *   iv.  relocate al_data[0] dependencies.
212  *
213  *  dlopen() - the initiator can only be the initial link-map control list:
214  *   i.   create al_data[1] from caller al_data[0]
215  *   ii.  add new link-map for the dlopen'ed object on al_data[1]
216  *   iii. analyze al_data[1] to add all non-lazy dependencies
217  *   iv.  relocate al_data[1] dependencies, and move to al_data[0].
218  *
219  *  filtee and lazy loading processing - the initiator can be any link-map
220  *  control list that is being relocated:
221  *   i.   create al_data[y] from caller al_data[x]
222  *   ii.  add new link-map for the new object on al_data[y]
223  *   iii. analyze al_data[y] to add all non-lazy dependencies
224  *   iv.  relocate al_data[y] dependencies, and move to al_data[x].
225  *
226  * This Alist therefore maintains a stack of link-map control lists.  The newest
227  * link-map control list can locate symbols within any of the former lists,
228  * however, control is not passed to a former list until the newest lists
229  * processing is complete.  Thus, objects can't bind to new objects until they
230  * have been fully analyzed and relocated.
231  *
232  * [1]  Note, additional link-map control list creation occurs after the head
233  * link-map object (typically the dynamic executable) has been relocated.  This
234  * staging is required to satisfy the binding requirements of copy relocations.
235  * Copy relocations, effectively, transfer the bindings of the copied data
236  * (say _iob in libc.so.1) to the copy location (_iob in the application).
237  * Thus an object that might bind to the original copy data must be redirected
238  * to the copy reference.  As the knowledge of a copy relocation having taken
239  * place is only known after relocating the application, link-map control list
240  * additions are suspended until after this relocation has completed.
241  */
242 typedef struct {
243 	Rt_map		*lc_head;
244 	Rt_map		*lc_tail;
245 	APlist		*lc_now;	/* pending promoted bind-now objects */
246 	uint_t		lc_flags;
247 } Lm_cntl;
248 
249 #define	LMC_FLG_ANALYZING	0x01	/* control list is being analyzed */
250 #define	LMC_FLG_RELOCATING	0x02	/* control list is being relocated */
251 #define	LMC_FLG_REANALYZE	0x04	/* repeat analysis (established when */
252 					/*	interposers are added */
253 
254 struct lm_list {
255 	/*
256 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
257 	 */
258 	Rt_map		*lm_head;	/* linked list pointers to active */
259 	Rt_map		*lm_tail;	/*	link-map list */
260 	APlist		*lm_handle;	/* not used by rtld_db - but spacing */
261 					/*	is required for flags */
262 	Word		lm_flags;
263 	/*
264 	 * END: Exposed to rtld_db - don't move, don't delete
265 	 */
266 	Alist		*lm_rti;	/* list of RTLDINFO tables */
267 	Audit_list	*lm_alp;	/* audit list descriptor */
268 	avl_tree_t	*lm_fpavl;	/* avl tree of objects loaded */
269 	Alist		*lm_lists;	/* active and pending link-map lists */
270 	char		***lm_environ;	/* pointer to environment array */
271 	Word		lm_tflags;	/* transferable flags */
272 	uint_t		lm_obj;		/* total number of objs on link-map */
273 	uint_t		lm_init;	/* new obj since last init processing */
274 	uint_t		lm_lazy;	/* obj with pending lazy dependencies */
275 	uint_t		lm_tls;		/* new obj that require TLS */
276 	uint_t		lm_lmid;	/* unique link-map list identifier, */
277 	char		*lm_lmidstr;	/* and associated diagnostic string */
278 	APlist		*lm_actaudit;	/* list of pending audit activity */
279 	Lc_desc		lm_lcs[CI_MAX];	/* external libc functions */
280 };
281 
282 #ifdef	_SYSCALL32
283 struct lm_list32 {
284 	/*
285 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
286 	 */
287 	Elf32_Addr	lm_head;
288 	Elf32_Addr	lm_tail;
289 	Elf32_Addr	lm_handle;
290 	Elf32_Word	lm_flags;
291 	/*
292 	 * END: Exposed to rtld_db - don't move, don't delete
293 	 */
294 	Elf32_Addr	lm_rti;
295 	Elf32_Addr	lm_fpavl;
296 	Elf32_Addr	lm_lists;
297 	Elf32_Addr	lm_environ;
298 	Elf32_Word	lm_tflags;
299 	uint_t		lm_obj;
300 	uint_t		lm_init;
301 	uint_t		lm_lazy;
302 	uint_t		lm_tls;
303 	uint_t		lm_lmid;
304 	Elf32_Addr	lm_lmidstr;
305 	Elf32_Addr	lm_actaudit;
306 	Elf32_Addr	lm_lcs[CI_MAX];
307 };
308 #endif /* _SYSCALL32 */
309 
310 /*
311  * Possible Link_map list flags (Lm_list.lm_flags)
312  */
313 /*
314  * BEGIN: Exposed to rtld_db - don't move, don't delete
315  */
316 #define	LML_FLG_BASELM		0x00000001	/* primary link-map */
317 #define	LML_FLG_RTLDLM		0x00000002	/* rtld link-map */
318 /*
319  * END: Exposed to rtld_db - don't move, don't delete
320  */
321 #define	LML_FLG_NOAUDIT		0x00000004	/* symbol auditing disabled */
322 #define	LML_FLG_PLTREL		0x00000008	/* deferred plt relocation */
323 						/* 	initialization */
324 						/*	(ld.so.1 only) */
325 #define	LML_FLG_HOLDLOCK	0x00000010	/* hold the rtld mutex lock */
326 #define	LML_FLG_ENVIRON		0x00000020	/* environ var initialized */
327 #define	LML_FLG_INTRPOSE	0x00000040	/* interposing objs on list */
328 #define	LML_FLG_LOCAUDIT	0x00000080	/* local auditors exists for */
329 						/*	this link-map list */
330 #define	LML_FLG_LOADAVAIL	0x00000100	/* load anything available */
331 #define	LML_FLG_IGNRELERR	0x00000200	/* ignore relocation errors - */
332 						/*	internal for crle(1) */
333 #define	LML_FLG_DBNOTIF		0x00000400	/* binding activity going on */
334 #define	LML_FLG_STARTREL	0x00000800	/* relocation started */
335 #define	LML_FLG_ATEXIT		0x00001000	/* atexit processing */
336 #define	LML_FLG_OBJADDED	0x00002000	/* object(s) added */
337 #define	LML_FLG_OBJDELETED	0x00004000	/* object(s) deleted */
338 #define	LML_FLG_OBJREEVAL	0x00008000	/* existing object(s) needs */
339 						/*	tsort reevaluation */
340 #define	LML_FLG_NOPENDGLBLAZY	0x00010000	/* no pending, global, lazy */
341 						/*	dependencies remain */
342 #define	LML_FLG_INTRPOSETSORT	0x00020000	/* interpose tsorting done */
343 #define	LML_FLG_AUDITNOTIFY	0x00040000	/* audit consistent required */
344 #define	LML_FLG_GROUPSEXIST	0x00080000	/* local groups exist */
345 
346 #define	LML_FLG_TRC_LDDSTUB	0x00100000	/* identify lddstub */
347 #define	LML_FLG_TRC_ENABLE	0x00200000	/* tracing enabled (ldd) */
348 #define	LML_FLG_TRC_WARN	0x00400000	/* print warnings for undefs */
349 #define	LML_FLG_TRC_VERBOSE	0x00800000	/* verbose (versioning) trace */
350 #define	LML_FLG_TRC_SEARCH	0x01000000	/* trace search paths */
351 #define	LML_FLG_TRC_UNREF	0x02000000	/* trace unreferenced */
352 						/*	dependencies */
353 #define	LML_FLG_TRC_UNUSED	0x04000000	/* trace unused dependencies */
354 #define	LML_FLG_TRC_INIT	0x08000000	/* print .init order */
355 #define	LML_FLG_TRC_NOUNRESWEAK	0x10000000	/* unresolved weak references */
356 						/*	are not allowed */
357 #define	LML_FLG_TRC_NOPAREXT	0x20000000	/* unresolved PARENT/EXTERN */
358 						/*	references are not */
359 						/*	allowed */
360 #define	LML_MSK_TRC		0xfff00000	/* tracing mask */
361 
362 /*
363  * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map
364  * list flags that can be propagated to any new link-map list created.
365  */
366 #define	LML_TFLG_NOLAZYLD	0x00000001	/* lazy loading disabled */
367 #define	LML_TFLG_NODIRECT	0x00000002	/* direct bindings disabled */
368 
369 #define	LML_TFLG_LOADFLTR	0x00000008	/* trigger filtee loading */
370 
371 #define	LML_TFLG_AUD_PREINIT	0x00001000	/* preinit (audit) exists */
372 #define	LML_TFLG_AUD_OBJSEARCH	0x00002000	/* objsearch (audit) exists */
373 #define	LML_TFLG_AUD_OBJOPEN	0x00004000	/* objopen (audit) exists */
374 #define	LML_TFLG_AUD_OBJFILTER	0x00008000	/* objfilter (audit) exists */
375 #define	LML_TFLG_AUD_OBJCLOSE	0x00010000	/* objclose (audit) exists */
376 #define	LML_TFLG_AUD_SYMBIND	0x00020000	/* symbind (audit) exists */
377 #define	LML_TFLG_AUD_PLTENTER	0x00040000	/* pltenter (audit) exists */
378 #define	LML_TFLG_AUD_PLTEXIT	0x00080000	/* pltexit (audit) exists */
379 #define	LML_TFLG_AUD_ACTIVITY	0x00100000	/* activity (audit) exists */
380 
381 /*
382  * NOTE: Each auditing module establishes a set of audit flags, AFLAGS(), that
383  * define the auditing interfaces the module offers.  These auditing flags are
384  * the LML_TFLG_AUD_ flags defined above.  Global auditors result in setting
385  * the lm_tflags too.  Local auditors only use the AFLAGS().  All tests for
386  * auditing inspect the lm_tflags and AFLAGS() for a specific auditing
387  * interface, and thus use the same flag to test for both types of auditors.
388  */
389 #define	LML_TFLG_AUD_MASK	0x0ffff000	/* audit interfaces mask */
390 
391 /*
392  * Define a Group Handle.
393  *
394  * The capability of ld.so.1 to associate a group of objects, look for symbols
395  * within that group, ensure that groups are isolated from one another (with
396  * regard to relocations), and to unload a group, centers around a handle.  This
397  * data structure is tracked from the link-map HANDLE(), and is the structure
398  * returned from dlopen(), and similar object loading capabilities such as
399  * filter/filtee processing.
400  *
401  * A handle keeps track of all the dependencies of the associated object.
402  * These dependencies may be added as objects are lazily loaded.  The core
403  * dependencies on the handle are the ldd(1) list of the associated object.
404  * The object assigned the handle, and the parent (or caller) who requested the
405  * handle are also maintained as dependencies on the handle.
406  *
407  * Presently, an object may have two handles, one requested with RTLD_FIRST
408  * and one without.
409  *
410  * A handle may be referenced by any number of parents (callers).  A reference
411  * count tracks the number.  A dlclose() operation drops the reference count,
412  * and when the count is zero, the handle is used to determine the family of
413  * objects to unload.  As bindings may occur to objects on the handle from
414  * other handles, it may not be possible to remove a complete family of
415  * objects or that handle itself.  Handles in this state are moved to an orphan
416  * list.  A handle on the orphan list is taken off the orphan list if the
417  * associated object is reopened.  Otherwise, the handle remains on the orphan
418  * list for the duration of the process.  The orphan list is inspected any time
419  * objects are unloaded, to determine if the orphaned objects can also be
420  * unloaded.
421  *
422  * Objects can be dlopened using RTLD_NOW.  This attribute requires that all
423  * relocations of the object, and its dependencies are processed immediately,
424  * before return to the caller.  Typically, an object is loaded without
425  * RTLD_NOW, and procedure linkage relocations are satisfied when their
426  * associated function is first called.  If an object is already loaded, and an
427  * RTLD_NOW request is made, then the object, and its dependencies, most undergo
428  * additional relocation processing.   This promotion from lazy binding to
429  * immediate binding is carried out using handles, as the handle defines the
430  * dependencies that must be processed.  A temporary handle is created for this
431  * purpose, and is discarded immediately after the promotion operation has been
432  * completed.
433  */
434 typedef struct {
435 	Alist		*gh_depends;	/* handle dependency list */
436 	Rt_map		*gh_ownlmp;	/* handle owners link-map */
437 	Lm_list		*gh_ownlml;	/* handle owners link-map list */
438 	uint_t		gh_refcnt;	/* handle reference count */
439 	uint_t		gh_flags;	/* handle flags (GPH_ values) */
440 } Grp_hdl;
441 
442 #define	GPH_ZERO	0x0001		/* special handle for dlopen(0) */
443 #define	GPH_LDSO	0x0002		/* special handle for ld.so.1 */
444 #define	GPH_FIRST	0x0004		/* dlsym() can only use originating */
445 					/*	dependency */
446 #define	GPH_FILTEE	0x0008		/* handle used to specify a filtee */
447 #define	GPH_INITIAL	0x0010		/* handle is initialized */
448 #define	GPH_NOPENDLAZY	0x0020		/* no pending lazy dependencies */
449 					/*	remain for this handle */
450 
451 /*
452  * Define a Group Descriptor.
453  *
454  * Each dependency associated with a group handle is maintained by a group
455  * descriptor.  The descriptor defines the associated dependency together with
456  * flags that indicate how the dependency can be used.
457  */
458 typedef struct {
459 	Rt_map		*gd_depend;	/* dependency */
460 	uint_t		gd_flags;	/* dependency flags (GPD_ values) */
461 } Grp_desc;
462 
463 #define	GPD_DLSYM	0x0001		/* dependency available to dlsym() */
464 #define	GPD_RELOC	0x0002		/* dependency available to satisfy */
465 					/*	relocation binding */
466 #define	GPD_ADDEPS	0x0004		/* dependencies of this dependency */
467 					/*	should be added to handle */
468 #define	GPD_PARENT	0x0008		/* dependency is a parent */
469 #define	GPD_FILTER	0x0010		/* dependency is our filter */
470 #define	GPD_PROMOTE	0x0020		/* dependency is our RTLD_NOW */
471 					/*	promoter */
472 #define	GPD_REMOVE	0x1000		/* descriptor is a candidate for */
473 					/*	removal from the group */
474 
475 /*
476  * Define threading structures.  For compatibility with libthread (T1_VERSION 1
477  * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a
478  * readers/writers lock.
479  */
480 typedef struct {
481 	union {
482 		mutex_t		l_mutex;
483 		rwlock_t	l_rwlock;
484 	} u;
485 } Rt_lock;
486 
487 typedef	cond_t	Rt_cond;
488 
489 /*
490  * Define a dynamic section information descriptor.  This parallels the entries
491  * in the .dynamic section and holds auxiliary information to implement lazy
492  * loading and filtee processing.
493  */
494 typedef struct {
495 	uint_t	di_flags;
496 	void	*di_info;
497 } Dyninfo;
498 
499 #define	FLG_DI_STDFLTR	0x00001		/* .dynamic entry for DT_FILTER */
500 #define	FLG_DI_AUXFLTR	0x00002		/* .dynamic entry for DT_AUXILIARY */
501 #define	FLG_DI_SYMFLTR	0x00004		/* .dynamic entry for DT_SYMFILTER */
502 					/*	and DT_SYMAUXILIARY */
503 #define	MSK_DI_FILTER	0x0000f		/* mask for all filter possibilities */
504 
505 #define	FLG_DI_POSFLAG1	0x00010		/* .dynamic entry for DT_POSFLAG_1 */
506 #define	FLG_DI_NEEDED	0x00020		/* .dynamic entry for DT_NEEDED */
507 #define	FLG_DI_LAZY	0x00100		/* lazy needed entry - preceded by */
508 					/*    DF_P1_LAZYLOAD (DT_POSFLAG_1) */
509 #define	FLG_DI_GROUP	0x00200		/* group needed entry - preceded by */
510 					/*    DF_P1_GROUPPERM (DT_POSFLAG_1) */
511 
512 #define	FLG_DI_LDD_DONE	0x01000		/* entry has been processed (ldd) */
513 #define	FLG_DI_LAZYFAIL	0x02000		/* the lazy loading of this entry */
514 					/*    failed */
515 /*
516  * Data structure to track AVL tree of pathnames.  This structure provides the
517  * basis of both the "not-found" node tree, and the "full-path" node tree.  Both
518  * of these trees persist for the life of a process, although the "not-found"
519  * tree may be moved aside during a dlopen() or dlsym() fall back operation.
520  */
521 typedef struct {
522 	const char	*pn_name;	/* path name */
523 	avl_node_t	pn_avl;		/* avl book-keeping (see SGSOFFSETOF) */
524 	uint_t		pn_hash;	/* path name hash value */
525 } PathNode;
526 
527 /*
528  * Data structure to track AVL tree for full path names of objects that are
529  * loaded into memory.
530  */
531 typedef struct {
532 	PathNode	fpn_node;	/* path node */
533 	Rt_map		*fpn_lmp;	/* object link-map */
534 } FullPathNode;
535 
536 /*
537  * A given link-map can hold either a supplier or receiver copy
538  * relocation list, but not both. This union is used to overlap
539  * the space used for the two lists.
540  */
541 typedef union {
542 	Alist	*rtc_r;		/* receiver list (Rel_copy) */
543 	APlist	*rtc_s;		/* supplier list (Rt_map *) */
544 } Rt_map_copy;
545 
546 
547 /*
548  * Link-map definition.
549  */
550 struct rt_map {
551 	/*
552 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
553 	 */
554 	Link_map	rt_public;	/* public data */
555 	const char	*rt_pathname;	/* full pathname of loaded object */
556 	ulong_t		rt_padstart;	/* start of image (including padding) */
557 	ulong_t		rt_padimlen;	/* size of image (including padding */
558 	ulong_t		rt_msize;	/* total memory reservation range */
559 	uint_t		rt_flags;	/* state flags, see FLG below */
560 	uint_t		rt_flags1;	/* state flags1, see FL1 below */
561 	ulong_t		rt_tlsmodid;	/* TLS module id */
562 	/*
563 	 * END: Exposed to rtld_db - don't move, don't delete
564 	 */
565 	APlist		*rt_alias;	/* list of linked file names */
566 	APlist		*rt_fpnode;	/* list of FullpathNode AVL nodes */
567 	char		*rt_runpath;	/* LD_RUN_PATH and its equivalent */
568 	Alist		*rt_runlist;	/*	Pdesc structures */
569 	APlist		*rt_depends;	/* list of dependencies */
570 	APlist		*rt_callers;	/* list of callers */
571 	APlist		*rt_handles;	/* dlopen handles */
572 	APlist		*rt_groups;	/* groups we're a member of */
573 	struct fct	*rt_fct;	/* file class table for this object */
574 	void		*rt_priv;	/* private data, object type specific */
575 	Lm_list		*rt_list;	/* link map list we belong to */
576 	uint_t		rt_objfltrndx;	/* object filtees .dynamic index */
577 	uint_t		rt_symsfltrcnt;	/* number of standard symbol filtees */
578 	uint_t		rt_symafltrcnt;	/* number of auxiliary symbol filtees */
579 	int		rt_mode;	/* usage mode, see RTLD mode flags */
580 	int		rt_sortval;	/* temporary buffer to traverse graph */
581 	uint_t		rt_cycgroup;	/* cyclic group */
582 	dev_t		rt_stdev;	/* device id and inode number for .so */
583 	rtld_ino_t	rt_stino;	/*	multiple inclusion checks */
584 	const char	*rt_origname;	/* original pathname of loaded object */
585 	size_t		rt_dirsz;	/*	and its size */
586 	size_t		rt_lmsize;	/* size of the link-map allocation */
587 	Rt_map_copy	rt_copy;	/* list of copy relocations */
588 	Audit_desc	*rt_auditors;	/* audit descriptor array */
589 	Audit_info	*rt_audinfo;	/* audit information descriptor */
590 	Syminfo		*rt_syminfo;	/* elf .syminfo section - here */
591 					/*	because it is checked in */
592 					/*	common code */
593 	Addr		*rt_initarray;	/* .initarray table */
594 	Addr		*rt_finiarray;	/* .finiarray table */
595 	Addr		*rt_preinitarray; /* .preinitarray table */
596 	mmapobj_result_t *rt_mmaps;	/* array of mapping information */
597 	uint_t		rt_mmapcnt;	/*	and associated number */
598 	uint_t		rt_initarraysz;	/* size of .initarray table */
599 	uint_t		rt_finiarraysz;	/* size of .finiarray table */
600 	uint_t		rt_preinitarraysz; /* size of .preinitarray table */
601 	Dyninfo		*rt_dyninfo;	/* .dynamic information descriptors */
602 	uint_t		rt_dyninfocnt;	/* count of dyninfo entries */
603 	uint_t		rt_relacount;	/* no. of RELATIVE relocations */
604 	uint_t		rt_idx;		/* hold index within linkmap list */
605 	uint_t		rt_lazy;	/* lazy dependencies pending */
606 	Xword		rt_hwcap;	/* hardware capabilities */
607 	Xword		rt_sfcap;	/* software capabilities */
608 	uint_t		rt_cntl;	/* link-map control list we belong to */
609 	uint_t		rt_aflags;	/* auditor flags, see LML_TFLG_AUD_ */
610 					/* address of _init */
611 	void		(*rt_init)(void);
612 					/* address of _fini */
613 	void		(*rt_fini)(void);
614 					/* link map symbol interpreter */
615 	Sym		*(*rt_symintp)(Slookup *, Rt_map **, uint_t *, int *);
616 };
617 
618 #ifdef _SYSCALL32
619 /*
620  * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs.
621  */
622 typedef union {
623 	uint32_t	rtc_r;
624 	uint32_t	rtc_s;
625 } Rt_map_copy32;
626 
627 typedef struct rt_map32 {
628 	/*
629 	 * BEGIN: Exposed to rtld_db - don't move, don't delete
630 	 */
631 	Link_map32	rt_public;
632 	uint32_t	rt_pathname;
633 	uint32_t	rt_padstart;
634 	uint32_t	rt_padimlen;
635 	uint32_t	rt_msize;
636 	uint32_t	rt_flags;
637 	uint32_t	rt_flags1;
638 	uint32_t	rt_tlsmodid;
639 	/*
640 	 * END: Exposed to rtld_db - don't move, don't delete
641 	 */
642 	uint32_t	rt_alias;
643 	uint32_t	rt_fpnode;
644 	uint32_t	rt_runpath;
645 	uint32_t	rt_runlist;
646 	uint32_t	rt_depends;
647 	uint32_t	rt_callers;
648 	uint32_t	rt_handles;
649 	uint32_t	rt_groups;
650 	uint32_t	rt_fct;
651 	uint32_t	rt_priv;
652 	uint32_t 	rt_list;
653 	uint32_t 	rt_objfltrndx;
654 	uint32_t 	rt_symsfltrcnt;
655 	uint32_t 	rt_symafltrcnt;
656 	int32_t		rt_mode;
657 	int32_t		rt_sortval;
658 	uint32_t	rt_cycgroup;
659 	uint32_t	rt_stdev;
660 	uint32_t	rt_stino;
661 	uint32_t	rt_origname;
662 	uint32_t	rt_dirsz;
663 	Rt_map_copy32	rt_copy;
664 	uint32_t 	rt_auditors;
665 	uint32_t 	rt_audinfo;
666 	uint32_t	rt_syminfo;
667 	uint32_t	rt_initarray;
668 	uint32_t	rt_finiarray;
669 	uint32_t	rt_preinitarray;
670 	uint32_t	rt_mmaps;
671 	uint32_t	rt_mmapcnt;
672 	uint32_t	rt_initarraysz;
673 	uint32_t	rt_finiarraysz;
674 	uint32_t	rt_preinitarraysz;
675 	uint32_t 	rt_dyninfo;
676 	uint32_t 	rt_dyninfocnt;
677 	uint32_t	rt_relacount;
678 	uint32_t	rt_idx;
679 	uint32_t	rt_lazy;
680 	uint32_t	rt_hwcap;
681 	uint32_t	rt_sfcap;
682 	uint32_t	rt_cntl;
683 	uint32_t	rt_aflags;
684 	uint32_t 	rt_init;
685 	uint32_t	rt_fini;
686 	uint32_t	rt_symintp;
687 } Rt_map32;
688 
689 #endif	/* _SYSCALL32 */
690 
691 /*
692  * Link map state flags.
693  */
694 /*
695  * BEGIN: Exposed to rtld_db - don't move, don't delete
696  */
697 #define	FLG_RT_ISMAIN	0x00000001	/* object represents main executable */
698 #define	FLG_RT_IMGALLOC	0x00000002	/* image is allocated (not mmap'ed) */
699 	/*
700 	 * Available for r_debug version >= R_RTLDDB_VERSION5
701 	 */
702 #define	FLG_RT_RELOCED	0x00000004	/* object has been relocated */
703 /*
704  * END: Exposed to rtld_db - don't move, don't delete
705  */
706 #define	FLG_RT_SETGROUP	0x00000008	/* group establishment required */
707 #define	FLG_RT_HWCAP	0x00000010	/* process $HWCAP expansion */
708 #define	FLG_RT_OBJECT	0x00000020	/* object processing (ie. .o's) */
709 #define	FLG_RT_NEWLOAD	0x00000040	/* object is newly loaded */
710 #define	FLG_RT_NODUMP	0x00000080	/* object can't be dldump(3x)'ed */
711 #define	FLG_RT_DELETE	0x00000100	/* object can be deleted */
712 #define	FLG_RT_ANALYZED	0x00000200	/* object has been analyzed */
713 #define	FLG_RT_INITDONE	0x00000400	/* objects .init has been completed */
714 #define	FLG_RT_TRANS	0x00000800	/* object is acting as a translator */
715 #define	FLG_RT_FIXED	0x00001000	/* image location is fixed */
716 #define	FLG_RT_PRELOAD	0x00002000	/* object was preloaded */
717 #define	FLG_RT_ALTER	0x00004000	/* alternative object used */
718 #define	FLG_RT_LOADFLTR	0x00008000	/* trigger filtee loading */
719 #define	FLG_RT_AUDIT	0x00010000	/* object is an auditor */
720 #define	FLG_RT_MODESET	0x00020000	/* MODE() has been initialized */
721 #define	FLG_RT_ANALZING	0x00040000	/* object is being analyzed */
722 #define	FLG_RT_INITFRST 0x00080000	/* execute .init first */
723 #define	FLG_RT_NOOPEN	0x00100000	/* dlopen() not allowed */
724 #define	FLG_RT_FINICLCT	0x00200000	/* fini has been collected (tsort) */
725 #define	FLG_RT_INITCALL	0x00400000	/* objects .init has been called */
726 #define	FLG_RT_OBJINTPO	0x00800000	/* object is a global interposer */
727 #define	FLG_RT_SYMINTPO	0x01000000	/* object contains symbol interposer */
728 #define	MSK_RT_INTPOSE	0x01800000	/* mask for all interposer */
729 					/*	possibilities */
730 #define	FLG_RT_MOVE	0x02000000	/* object needs move operation */
731 #define	FLG_RT_TMPLIST	0x04000000	/* object is part of a temporary list */
732 #define	FLG_RT_REGSYMS	0x08000000	/* object has DT_REGISTER entries */
733 #define	FLG_RT_INITCLCT	0x10000000	/* init has been collected (tsort) */
734 #define	FLG_RT_HANDLE	0x20000000	/* generate a handle for this object */
735 #define	FLG_RT_RELOCING	0x40000000	/* object is being relocated */
736 
737 #define	FL1_RT_COPYTOOK	0x00000001	/* copy relocation taken */
738 
739 #define	FL1_RT_CONFSET	0x00000004	/* object was loaded by crle(1) */
740 #define	FL1_RT_NODEFLIB	0x00000008	/* ignore default library search */
741 #define	FL1_RT_ENDFILTE	0x00000010	/* filtee terminates filters search */
742 #define	FL1_RT_DISPREL	0x00000020	/* object has *disp* relocation */
743 #define	FL1_RT_DTFLAGS	0x00000040	/* DT_FLAGS element exists */
744 
745 #define	FL1_RT_LDDSTUB	0x00000100	/* identify lddstub */
746 #define	FL1_RT_NOINIFIN	0x00000200	/* no .init or .fini exists */
747 #define	FL1_RT_USED	0x00000400	/* symbol referenced from this object */
748 #define	FL1_RT_SYMBOLIC	0x00000800	/* DF_SYMBOLIC was set - use */
749 					/*	symbolic sym resolution */
750 #define	FL1_RT_OBJSFLTR	0x00001000	/* object is acting as a standard */
751 #define	FL1_RT_OBJAFLTR	0x00002000	/*	or auxiliary filter */
752 #define	FL1_RT_SYMSFLTR	0x00004000	/* symbol is acting as a standard */
753 #define	FL1_RT_SYMAFLTR	0x00008000	/*	or auxiliary filter */
754 #define	MSK_RT_FILTER	0x0000f000	/* mask for all filter possibilities */
755 
756 #define	FL1_RT_TLSADD	0x00010000	/* objects TLS has been registered */
757 #define	FL1_RT_TLSSTAT	0x00020000	/* object requires static TLS */
758 #define	FL1_RT_DIRECT	0x00040000	/* object has DIRECT bindings enabled */
759 #define	FL1_RT_GLOBAUD	0x00080000	/* establish global auditing */
760 
761 /*
762  * Flags for the tls_modactivity() routine
763  */
764 #define	TM_FLG_MODADD	0x01		/* call tls_modadd() interface */
765 #define	TM_FLG_MODREM	0x02		/* call tls_modrem() interface */
766 
767 /*
768  * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION <= 2).
769  */
770 #define	ADDR(X)		((X)->rt_public.l_addr)
771 #define	NAME(X)		((X)->rt_public.l_name)
772 #define	DYN(X)		((X)->rt_public.l_ld)
773 #define	NEXT(X)		((X)->rt_public.l_next)
774 #define	PREV(X)		((X)->rt_public.l_prev)
775 #define	REFNAME(X)	((X)->rt_public.l_refname)
776 
777 /*
778  * An Rt_map starts with a Link_map, followed by other information.
779  * ld.so.1 allocates Rt_map structures, and then casts them to Link_map,
780  * and back, depending on context.
781  *
782  * On some platforms, Rt_map can have a higher alignment requirement
783  * than Link_map. On such platforms, the cast from Link_map to Rt_map will
784  * draw an E_BAD_PTR_CAST_ALIGN warning from lint. Since we allocate
785  * the memory as the higher alignment Rt_map, we know that this is a safe
786  * conversion. The LINKMAP_TO_RTMAP macro is used to handle the conversion
787  * in a manner that satisfies lint.
788  */
789 #ifdef lint
790 #define	LINKMAP_TO_RTMAP(X)	(Rt_map *)(void *)(X)
791 #else
792 #define	LINKMAP_TO_RTMAP(X)	(Rt_map *)(X)
793 #endif
794 
795 /*
796  * Convenience macros for the common case of using
797  * NEXT()/PREV() and casting the result to (Rt_map *)
798  */
799 #define	NEXT_RT_MAP(X)	LINKMAP_TO_RTMAP(NEXT(X))
800 #define	PREV_RT_MAP(X)	LINKMAP_TO_RTMAP(PREV(X))
801 
802 /*
803  * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION3).
804  */
805 #define	PATHNAME(X)	((X)->rt_pathname)
806 #define	PADSTART(X)	((X)->rt_padstart)
807 #define	PADIMLEN(X)	((X)->rt_padimlen)
808 #define	MSIZE(X)	((X)->rt_msize)
809 #define	FLAGS(X)	((X)->rt_flags)
810 #define	FLAGS1(X)	((X)->rt_flags1)
811 
812 /*
813  * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION4).
814  */
815 #define	TLSMODID(X)	((X)->rt_tlsmodid)
816 
817 /*
818  * Macros for getting to unexposed, link-map data.
819  */
820 #define	LMSIZE(X)	((X)->rt_lmsize)
821 #define	AFLAGS(X)	((X)->rt_aflags)
822 #define	ALIAS(X)	((X)->rt_alias)
823 #define	FPNODE(X)	((X)->rt_fpnode)
824 #define	INIT(X)		((X)->rt_init)
825 #define	FINI(X)		((X)->rt_fini)
826 #define	RPATH(X)	((X)->rt_runpath)
827 #define	RLIST(X)	((X)->rt_runlist)
828 #define	DEPENDS(X)	((X)->rt_depends)
829 #define	CALLERS(X)	((X)->rt_callers)
830 #define	HANDLES(X)	((X)->rt_handles)
831 #define	GROUPS(X)	((X)->rt_groups)
832 #define	FCT(X)		((X)->rt_fct)
833 #define	SYMINTP(X)	((X)->rt_symintp)
834 #define	LIST(X)		((X)->rt_list)
835 #define	OBJFLTRNDX(X)	((X)->rt_objfltrndx)
836 #define	SYMSFLTRCNT(X)	((X)->rt_symsfltrcnt)
837 #define	SYMAFLTRCNT(X)	((X)->rt_symafltrcnt)
838 #define	MODE(X)		((X)->rt_mode)
839 #define	SORTVAL(X)	((X)->rt_sortval)
840 #define	CYCGROUP(X)	((X)->rt_cycgroup)
841 #define	STDEV(X)	((X)->rt_stdev)
842 #define	STINO(X)	((X)->rt_stino)
843 #define	ORIGNAME(X)	((X)->rt_origname)
844 #define	DIRSZ(X)	((X)->rt_dirsz)
845 #define	COPY_R(X)	((X)->rt_copy.rtc_r)
846 #define	COPY_S(X)	((X)->rt_copy.rtc_s)
847 #define	AUDITORS(X)	((X)->rt_auditors)
848 #define	AUDINFO(X)	((X)->rt_audinfo)
849 #define	SYMINFO(X)	((X)->rt_syminfo)
850 #define	INITARRAY(X)	((X)->rt_initarray)
851 #define	FINIARRAY(X)	((X)->rt_finiarray)
852 #define	PREINITARRAY(X)	((X)->rt_preinitarray)
853 #define	MMAPS(X)	((X)->rt_mmaps)
854 #define	MMAPCNT(X)	((X)->rt_mmapcnt)
855 #define	INITARRAYSZ(X)	((X)->rt_initarraysz)
856 #define	FINIARRAYSZ(X)	((X)->rt_finiarraysz)
857 #define	PREINITARRAYSZ(X) ((X)->rt_preinitarraysz)
858 #define	DYNINFO(X)	((X)->rt_dyninfo)
859 #define	DYNINFOCNT(X)	((X)->rt_dyninfocnt)
860 #define	RELACOUNT(X)	((X)->rt_relacount)
861 #define	IDX(X)		((X)->rt_idx)
862 #define	LAZY(X)		((X)->rt_lazy)
863 #define	CNTL(X)		((X)->rt_cntl)
864 #define	HWCAP(X)	((X)->rt_hwcap)
865 #define	SFCAP(X)	((X)->rt_sfcap)
866 
867 /*
868  * Flags for tsorting.
869  */
870 #define	RT_SORT_FWD	0x01		/* topological sort (.fini) */
871 #define	RT_SORT_REV	0x02		/* reverse topological sort (.init) */
872 #define	RT_SORT_DELETE	0x10		/* process FLG_RT_DELETE objects */
873 					/*	only (called via dlclose()) */
874 #define	RT_SORT_INTPOSE	0x20		/* process interposer objects */
875 
876 /*
877  * Flags for lookup_sym (and hence find_sym) routines.
878  */
879 #define	LKUP_DEFT	0x0000		/* simple lookup request */
880 #define	LKUP_SPEC	0x0001		/* special ELF lookup (allows address */
881 					/*	resolutions to plt[] entries) */
882 #define	LKUP_LDOT	0x0002		/* indicates the original A_OUT */
883 					/*	symbol had a leading `.' */
884 #define	LKUP_FIRST	0x0004		/* lookup symbol in first link map */
885 					/*	only */
886 #define	LKUP_COPY	0x0008		/* lookup symbol for a COPY reloc, do */
887 					/*	not bind to symbol at head */
888 #define	LKUP_STDRELOC	0x0010		/* lookup originates from a standard */
889 					/*	relocation (elf_reloc()) */
890 #define	LKUP_SELF	0x0020		/* lookup symbol in ourself - undef */
891 					/*	is valid */
892 #define	LKUP_WEAK	0x0040		/* relocation reference is weak */
893 #define	LKUP_NEXT	0x0080		/* request originates from RTLD_NEXT */
894 #define	LKUP_NODESCENT	0x0100		/* don't descend through dependencies */
895 #define	LKUP_NOFALLBACK	0x0200		/* don't fall back to loading */
896 					/*	pending lazy dependencies */
897 #define	LKUP_DIRECT	0x0400		/* direct binding request */
898 #define	LKUP_SYMNDX	0x0800		/* establish symbol index */
899 #define	LKUP_SINGLETON	0x1000		/* search for a singleton symbol */
900 #define	LKUP_STANDARD	0x2000		/* standard lookup - originated from */
901 					/* 	head link-map element */
902 #define	LKUP_WORLD	0x4000		/* ensure world lookup */
903 
904 /*
905  * For the runtime linker to perform a symbol search, a number of data items
906  * related to the search are required.  An Slookup data structure is used to
907  * convey this data to lookup_sym(), and in special cases, to other core
908  * routines that provide the implementation details for lookup_sym()
909  *
910  * The symbol name (sl_name), the caller (sl_cmap), and the link-map from which
911  * to start the search (sl_imap) are fundamental to the symbol search.  The
912  * initial search link-map might get modified by the core routines that provide
913  * the implementation details for lookup_sym().  This modification accommodates
914  * requirements such as processing a handle, direct binding and interposition.
915  * The association between the caller and the potential destination also
916  * determines whether the destination is a candidate to search.
917  *
918  * The lookup identifier (sl_id) is used to identify a runtime linker operation.
919  * Within this operation, any lazy loads that fail are not re-examined.  This
920  * technique keeps the overhead of processing a failed lazy load to a minimum.
921  *
922  * Symbol searches that originate from a relocation record are accompanied by
923  * the relocation index (sl_rsymndx), the symbol reference (sl_rsym) and
924  * possibly the relocation type (sl_rtype).  This data provides for determining
925  * lazy loading, direct binding, and special symbol processing requirements
926  * such as copy relocations and singleton lookup.
927  *
928  * The symbols hash value is computed by lookup_sym, and propagated throughout
929  * the search engine.  Note, occasionally the Slookup data is passed to a core
930  * routine that provides the implementation details for lookup_sym(), ie.
931  * elf_find_sym(), in which case the caller must initialize the hash value.
932  *
933  * The symbols binding information is established by lookup_sym() when the
934  * symbols relocation type is supplied.  Weak bindings allow relocations to
935  * be set to zero should a symbol lookup fail.
936  *
937  * The flags allow the caller to control aspects of the search, including the
938  * interpretation of copy relocations, etc.  Note, a number of flag settings
939  * are established in lookup_sym() from attributes of the symbol reference.
940  */
941 struct slookup {
942 	const char	*sl_name;	/* symbol name */
943 	Rt_map		*sl_cmap;	/* callers link-map */
944 	Rt_map		*sl_imap;	/* initial link-map to search */
945 	ulong_t		sl_id;		/* identifier for this lookup */
946 	ulong_t		sl_hash;	/* symbol hash value */
947 	ulong_t		sl_rsymndx;	/* referencing reloc symndx */
948 	Sym		*sl_rsym;	/* referencing symbol */
949 	uchar_t		sl_rtype;	/* relocation type associate with */
950 					/*    symbol */
951 	uchar_t		sl_bind;	/* symbols binding (returned) */
952 	uint_t		sl_flags;	/* lookup flags */
953 };
954 
955 #define	SLOOKUP_INIT(sl, name, cmap, imap, id, hash, rsymndx, rsym, rtype, \
956     flags) \
957 	(void) (sl.sl_name = (name), sl.sl_cmap = (cmap), sl.sl_imap = (imap), \
958 	    sl.sl_id = (id), sl.sl_hash = (hash), sl.sl_rsymndx = (rsymndx), \
959 	    sl.sl_rsym = (rsym), sl.sl_rtype = (rtype), sl.sl_bind = 0, \
960 	    sl.sl_flags = (flags))
961 
962 /*
963  * Define a number of .plt lookup outcomes, for use in binding diagnostics.
964  */
965 typedef	enum {
966 	PLT_T_NONE = 0,
967 	PLT_T_21D,
968 	PLT_T_24D,
969 	PLT_T_U32,
970 	PLT_T_U44,
971 	PLT_T_FULL,
972 	PLT_T_FAR,
973 	PLT_T_NUM			/* Must be last */
974 } Pltbindtype;
975 
976 /*
977  * Prototypes.
978  */
979 extern ulong_t		ld_entry_cnt;	/* counter bumped on each entry to */
980 					/*    ld.so.1. */
981 extern Lm_list		lml_main;	/* main's link map list */
982 extern Lm_list		lml_rtld;	/* rtld's link map list */
983 extern Lm_list		*lml_list[];
984 
985 extern Pltbindtype	elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t,
986 			    Xword);
987 extern Rt_map		*is_so_loaded(Lm_list *, const char *, int *);
988 extern Sym		*lookup_sym(Slookup *, Rt_map **, uint_t *, int *);
989 extern int		rt_dldump(Rt_map *, const char *, int, Addr);
990 
991 #ifdef	__cplusplus
992 }
993 #endif
994 
995 #endif /* _RTLD_H */
996