xref: /openbsd-src/libexec/ld.so/resolve.h (revision ce7279d89b71439c96c854f612f4ac93a461fdc4)
1*ce7279d8Sjsg /*	$OpenBSD: resolve.h,v 1.108 2024/05/21 05:00:47 jsg Exp $ */
24d11faf9Srahnds 
34d11faf9Srahnds /*
44d11faf9Srahnds  * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
54d11faf9Srahnds  *
64d11faf9Srahnds  * Redistribution and use in source and binary forms, with or without
74d11faf9Srahnds  * modification, are permitted provided that the following conditions
84d11faf9Srahnds  * are met:
94d11faf9Srahnds  * 1. Redistributions of source code must retain the above copyright
104d11faf9Srahnds  *    notice, this list of conditions and the following disclaimer.
114d11faf9Srahnds  * 2. Redistributions in binary form must reproduce the above copyright
124d11faf9Srahnds  *    notice, this list of conditions and the following disclaimer in the
134d11faf9Srahnds  *    documentation and/or other materials provided with the distribution.
144d11faf9Srahnds  *
154d11faf9Srahnds  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
164d11faf9Srahnds  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
174d11faf9Srahnds  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
184d11faf9Srahnds  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
194d11faf9Srahnds  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
204d11faf9Srahnds  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
214d11faf9Srahnds  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
224d11faf9Srahnds  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
234d11faf9Srahnds  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
244d11faf9Srahnds  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
254d11faf9Srahnds  * SUCH DAMAGE.
264d11faf9Srahnds  *
274d11faf9Srahnds  */
284d11faf9Srahnds 
294d11faf9Srahnds #ifndef _RESOLVE_H_
304d11faf9Srahnds #define _RESOLVE_H_
314d11faf9Srahnds 
320acae5e5Sdrahn #include <sys/queue.h>
3350f3e86fSdrahn #include <dlfcn.h>
34c0197e40Sguenther #include <link.h>
35c0197e40Sguenther #include <tib.h>
364d11faf9Srahnds 
37d1b0fb8fSguenther #define __relro		__attribute__((section(".data.rel.ro")))
38d1b0fb8fSguenther 
39c0197e40Sguenther #ifndef __boot
40c0197e40Sguenther # if DO_CLEAN_BOOT
41c0197e40Sguenther #  define __boot	__attribute__((section(".boot.text")))
42c0197e40Sguenther #  define __boot_data	__attribute__((section(".boot.data")))
43c0197e40Sguenther # else
44c0197e40Sguenther #  define __boot
45c0197e40Sguenther #  define __boot_data
46c0197e40Sguenther # endif
47c0197e40Sguenther #endif
48c0197e40Sguenther 
499b12f513Skettenis /* Number of low tags that are used saved internally (0 .. DT_NUM-1) */
50b3331980Sguenther #define DT_NUM	(DT_RELR + 1)
519b12f513Skettenis 
522ddbd9dfSart struct load_list {
53c452b65eSdrahn 	struct load_list *next;
54f59ebde0Sdrahn 	void		*start;
55c452b65eSdrahn 	size_t		size;
56c452b65eSdrahn 	int		prot;
57f59ebde0Sdrahn 	Elf_Addr	moff;
58f59ebde0Sdrahn 	long		foff;
592ddbd9dfSart };
604d11faf9Srahnds 
61c0197e40Sguenther typedef void initarrayfunc(int, const char **, char **, dl_cb_cb *);
62c0197e40Sguenther typedef void initfunc(void);	/* also fini and fini_array functions */
63c0197e40Sguenther 
644e986f76Sguenther /* Alpha uses 8byte entries for DT_HASH */
654e986f76Sguenther #ifdef __alpha__
664e986f76Sguenther typedef uint64_t Elf_Hash_Word;
674e986f76Sguenther #else
684e986f76Sguenther typedef uint32_t Elf_Hash_Word;
694e986f76Sguenther #endif
704e986f76Sguenther 
71bae526eeSguenther typedef struct elf_object elf_object_t;
72bae526eeSguenther 
73bae526eeSguenther struct object_vector {
74bae526eeSguenther 	int		len;
75bae526eeSguenther 	int		alloc;
76bae526eeSguenther 	elf_object_t	**vec;
77bae526eeSguenther };
78bae526eeSguenther void	object_vec_grow(struct object_vector *_vec, int _more);
79bae526eeSguenther 
804098e116Sgnezdo struct addr_range {
8107cf23bbSderaadt 	vaddr_t start;
8207cf23bbSderaadt 	vaddr_t end;
834098e116Sgnezdo };
844098e116Sgnezdo 
854098e116Sgnezdo struct range_vector {
864098e116Sgnezdo 	struct addr_range slice[40];
874098e116Sgnezdo 	int count;
8807cf23bbSderaadt };
8907cf23bbSderaadt 
904d11faf9Srahnds /*
914d11faf9Srahnds  *  Structure describing a loaded object.
924d11faf9Srahnds  *  The head of this struct must be compatible
93c340fc50Sguenther  *  with struct link_map in <link_elf.h>
944d11faf9Srahnds  */
950acae5e5Sdrahn struct elf_object {
96ce11e090Skurt 	Elf_Addr obj_base;		/* object's address '0' base */
974d11faf9Srahnds 	char	*load_name;		/* Pointer to object name */
98cd0faa30Sdrahn 	Elf_Dyn *load_dyn;		/* Pointer to object dynamic data */
994d11faf9Srahnds 	struct elf_object *next;
1004d11faf9Srahnds 	struct elf_object *prev;
1014d11faf9Srahnds /* End struct link_map compatible */
102ce11e090Skurt 	Elf_Addr load_base;		/* Base address of loadable segments */
1034d11faf9Srahnds 
1042ddbd9dfSart 	struct load_list *load_list;
105c452b65eSdrahn 
1064d11faf9Srahnds 	u_int32_t  load_size;
1074d11faf9Srahnds 
1084d11faf9Srahnds 	union {
109cd0faa30Sdrahn 		u_long		info[DT_NUM + DT_PROCNUM];
1104d11faf9Srahnds 		struct {
111039ca137Sart 			Elf_Addr	null;		/* Not used */
112039ca137Sart 			Elf_Addr	needed;		/* Not used */
113039ca137Sart 			Elf_Addr	pltrelsz;
114039ca137Sart 			Elf_Addr	*pltgot;
115039ca137Sart 			Elf_Addr	*hash;
1164d11faf9Srahnds 			const char	*strtab;
117cd0faa30Sdrahn 			const Elf_Sym	*symtab;
118cd0faa30Sdrahn 			Elf_RelA	*rela;
119039ca137Sart 			Elf_Addr	relasz;
120039ca137Sart 			Elf_Addr	relaent;
121039ca137Sart 			Elf_Addr	strsz;
122039ca137Sart 			Elf_Addr	syment;
123c0197e40Sguenther 			initfunc	*init;
124c0197e40Sguenther 			initfunc	*fini;
1254d11faf9Srahnds 			const char	*soname;
1264d11faf9Srahnds 			const char	*rpath;
127039ca137Sart 			Elf_Addr	symbolic;
128cd0faa30Sdrahn 			Elf_Rel		*rel;
129039ca137Sart 			Elf_Addr	relsz;
130039ca137Sart 			Elf_Addr	relent;
131039ca137Sart 			Elf_Addr	pltrel;
132039ca137Sart 			Elf_Addr	debug;
133039ca137Sart 			Elf_Addr	textrel;
134039ca137Sart 			Elf_Addr	jmprel;
13586fa57a2Skettenis 			Elf_Addr	bind_now;
136c0197e40Sguenther 			initarrayfunc	**init_array;
137c0197e40Sguenther 			initfunc	**fini_array;
13886fa57a2Skettenis 			Elf_Addr	init_arraysz;
13986fa57a2Skettenis 			Elf_Addr	fini_arraysz;
14086fa57a2Skettenis 			const char	*runpath;
14186fa57a2Skettenis 			Elf_Addr	flags;
14286fa57a2Skettenis 			Elf_Addr	encoding;
143c0197e40Sguenther 			initarrayfunc	**preinit_array;
14486fa57a2Skettenis 			Elf_Addr	preinit_arraysz;
145b3331980Sguenther 			Elf_Addr	unassigned;
146b3331980Sguenther 			Elf_Addr	relrsz;
147b3331980Sguenther 			Elf_Relr	*relr;
1484d11faf9Srahnds 		} u;
1494d11faf9Srahnds 	} Dyn;
1504d11faf9Srahnds #define dyn Dyn.u
1514d11faf9Srahnds 
15288098a4dSguenther 	Elf_Addr	relacount;	/* DT_RELACOUNT */
15388098a4dSguenther 	Elf_Addr	relcount;	/* DT_RELCOUNT */
15488098a4dSguenther 
1554d11faf9Srahnds 	int		status;
1565c3b452cSguenther #define	STAT_RELOC_DONE		0x001
1575c3b452cSguenther #define	STAT_GOT_DONE		0x002
1585c3b452cSguenther #define	STAT_INIT_DONE		0x004
1595c3b452cSguenther #define	STAT_FINI_DONE		0x008
1605c3b452cSguenther #define	STAT_FINI_READY		0x010
1615c3b452cSguenther #define	STAT_UNLOADED		0x020
1625c3b452cSguenther #define	STAT_NODELETE		0x040
1635c3b452cSguenther #define	STAT_GNU_HASH		0x080
1645c3b452cSguenther #define	STAT_VISIT_INITFIRST	0x100
1655c3b452cSguenther #define	STAT_VISIT_INIT		0x200
1664d11faf9Srahnds 
167cd0faa30Sdrahn 	Elf_Phdr	*phdrp;
1684d11faf9Srahnds 	int		phdrc;
1694d11faf9Srahnds 
1704d11faf9Srahnds 	int		obj_type;
1714d11faf9Srahnds #define	OBJTYPE_LDR	1
1724d11faf9Srahnds #define	OBJTYPE_EXE	2
1734d11faf9Srahnds #define	OBJTYPE_LIB	3
1744d11faf9Srahnds #define	OBJTYPE_DLO	4
1750fdecfd0Sguenther 	int		obj_flags;	/* c.f. <sys/exec_elf.h> DF_1_* */
17607cf23bbSderaadt 	int		nodelete;
1774d11faf9Srahnds 
178ac51d06cSguenther 	/* shared by ELF and GNU hash */
1794d11faf9Srahnds 	u_int32_t	nbuckets;
180ac51d06cSguenther 	u_int32_t	nchains;	/* really, number of symbols */
181ac51d06cSguenther 	union {
182ac51d06cSguenther 		struct {
183ac51d06cSguenther 			/* specific to ELF hash */
1844e986f76Sguenther 			const Elf_Hash_Word	*buckets;
1854e986f76Sguenther 			const Elf_Hash_Word	*chains;
186ac51d06cSguenther 		} u_elf;
187ac51d06cSguenther 		struct {
188ac51d06cSguenther 			/* specific to GNU hash */
1899d9b0c10Sderaadt 			const Elf_Word		*buckets;
1909d9b0c10Sderaadt 			const Elf_Word		*chains;
191ac51d06cSguenther 			const Elf_Addr		*bloom;
1929d9b0c10Sderaadt 			Elf_Word		mask_bm;
1939d9b0c10Sderaadt 			Elf_Word		shift2;
1949d9b0c10Sderaadt 			Elf_Word		symndx;
195ac51d06cSguenther 		} u_gnu;
196ac51d06cSguenther 	} hash_u;
197ac51d06cSguenther #define buckets_elf	hash_u.u_elf.buckets
198ac51d06cSguenther #define chains_elf	hash_u.u_elf.chains
199ac51d06cSguenther #define buckets_gnu	hash_u.u_gnu.buckets
200ac51d06cSguenther #define chains_gnu	hash_u.u_gnu.chains
201ac51d06cSguenther #define bloom_gnu	hash_u.u_gnu.bloom
202ac51d06cSguenther #define mask_bm_gnu	hash_u.u_gnu.mask_bm
203ac51d06cSguenther #define shift2_gnu	hash_u.u_gnu.shift2
204ac51d06cSguenther #define symndx_gnu	hash_u.u_gnu.symndx
205ac51d06cSguenther 
206d937a926Sguenther 	struct object_vector	child_vec;	/* direct dep libs of object */
207bae526eeSguenther 	struct object_vector	grpsym_vec;	/* ordered complete dep list */
20891de9d58Ssthen 	TAILQ_HEAD(,dep_node)	grpref_list;	/* refs to other load groups */
2090acae5e5Sdrahn 
21050cabf59Skurt 	int		refcount;	/* dep libs only */
21150cabf59Skurt 	int		opencount;	/* # dlopen() & exe */
21250cabf59Skurt 	int		grprefcount;	/* load group refs */
213ca7a62b5Skurt #define OBJECT_REF_CNT(object) \
214ca7a62b5Skurt     ((object->refcount + object->opencount + object->grprefcount))
215ca7a62b5Skurt #define OBJECT_DLREF_CNT(object) \
216ca7a62b5Skurt     ((object->opencount + object->grprefcount))
2178d2dd116Sdrahn 
2180acae5e5Sdrahn 	/* object that caused this module to be loaded, used in symbol lookup */
2190acae5e5Sdrahn 	elf_object_t	*load_object;
2200af06aafSkurt 	struct sod	sod;
2217afb1d1dSkjell 
2227afb1d1dSkjell 	/* for object confirmation */
2237afb1d1dSkjell 	dev_t	dev;
2247afb1d1dSkjell 	ino_t inode;
2251a53160bSdrahn 
226fe38b55cSguenther 	/* thread local storage info */
227fe38b55cSguenther 	Elf_Addr	tls_fsize;
228fe38b55cSguenther 	Elf_Addr	tls_msize;
229fe38b55cSguenther 	Elf_Addr	tls_align;
230fe38b55cSguenther 	const void	*tls_static_data;
231fe38b55cSguenther 	int		tls_offset;
232fe38b55cSguenther 
233660c432fSguenther 	/* relro bits */
234660c432fSguenther 	Elf_Addr	relro_addr;
235660c432fSguenther 	Elf_Addr	relro_size;
236660c432fSguenther 
237b6decd50Sguenther 	/* generation number of last grpsym insert on this object */
238b6decd50Sguenther 	unsigned int grpsym_gen;
239c8dfd7a0Skurt 
240c8dfd7a0Skurt 	char **rpath;
24182c4222eSguenther 	char **runpath;
242ae398163Smiod 
243ae398163Smiod 	/* nonzero if trace enabled for this object */
244ae398163Smiod 	int traced;
2459ba2c65fSderaadt 
2464098e116Sgnezdo 	struct range_vector imut;
2474098e116Sgnezdo 	struct range_vector mut;
2484a066defSderaadt 	int islibc;
2490acae5e5Sdrahn };
2504d11faf9Srahnds 
2515509b646Sdrahn struct dep_node {
2520acae5e5Sdrahn 	TAILQ_ENTRY(dep_node) next_sib;
2535509b646Sdrahn 	elf_object_t *data;
2545509b646Sdrahn };
2555509b646Sdrahn 
256702424caSguenther 
257702424caSguenther /* Please don't rename or make hidden; gdb(1) knows about these. */
258702424caSguenther Elf_Addr _dl_bind(elf_object_t *object, int index);
259702424caSguenther void	_dl_debug_state(void);
260702424caSguenther 
261702424caSguenther /* exported to the application */
262702424caSguenther extern char *__progname;
263702424caSguenther 
264702424caSguenther __BEGIN_HIDDEN_DECLS
265296fbf9fSsemarie void _dl_handle_nodelete(elf_object_t *_object);
26670be5820Sdrahn void _dl_add_object(elf_object_t *object);
2670acae5e5Sdrahn elf_object_t *_dl_finalize_object(const char *objname, Elf_Dyn *dynp,
2689f6c3316Skurt     Elf_Phdr *phdrp, int phdrc, const int objtype, const long lbase,
2699f6c3316Skurt     const long obase);
2700acae5e5Sdrahn void	_dl_remove_object(elf_object_t *object);
2718a1e31c9Sdrahn void	_dl_cleanup_objects(void);
2724d11faf9Srahnds 
273ab4d5173Ssthen void _dl_handle_already_loaded(elf_object_t *_object, int _flags);
27407cf23bbSderaadt elf_object_t *_dl_load_shlib(const char *, elf_object_t *,
27507cf23bbSderaadt     int, int, int nodelete);
27607cf23bbSderaadt elf_object_t *_dl_tryload_shlib(const char *libname, int type,
27707cf23bbSderaadt     int flags, int nodelete);
2784d11faf9Srahnds 
2790acae5e5Sdrahn int _dl_md_reloc(elf_object_t *object, int rel, int relsz);
280e9cfe40cSmiod int _dl_md_reloc_got(elf_object_t *object, int lazy);
2814d11faf9Srahnds 
282143e5accSguenther struct sym_res {
283143e5accSguenther 	const Elf_Sym		*sym;
284143e5accSguenther 	const elf_object_t	*obj;
285143e5accSguenther };
286143e5accSguenther 
287143e5accSguenther struct sym_res _dl_find_symbol(const char *name, int flags,
288143e5accSguenther     const Elf_Sym *ref_sym, elf_object_t *object);
289143e5accSguenther 
2904ffea0b8Sdrahn /*
2914ffea0b8Sdrahn  * defines for _dl_find_symbol() flag field, three bits of meaning
2924ffea0b8Sdrahn  * myself	- clear: search all objects,	set: search only this object
2934ffea0b8Sdrahn  * warnnotfound - clear: no warning,		set: warn if not found
2944ffea0b8Sdrahn  * inplt	- clear: possible plt ref	set: real matching function.
2954ffea0b8Sdrahn  *
2964ffea0b8Sdrahn  * inplt - due to how ELF handles function addresses in shared libraries
2974ffea0b8Sdrahn  * &func may actually refer to the plt entry in the main program
2984ffea0b8Sdrahn  * rather than the actual function address in the .so file.
2994ffea0b8Sdrahn  * This rather bizarre behavior is documented in the SVR4 ABI.
3004ffea0b8Sdrahn  * when getting the function address to relocate a PLT entry
3014ffea0b8Sdrahn  * the 'real' function address is necessary, not the possible PLT address.
3024ffea0b8Sdrahn  */
3034ffea0b8Sdrahn /* myself */
3040acae5e5Sdrahn #define SYM_SEARCH_ALL		0x00
3050acae5e5Sdrahn #define SYM_SEARCH_SELF		0x01
3060acae5e5Sdrahn #define SYM_SEARCH_OTHER	0x02
3070acae5e5Sdrahn #define SYM_SEARCH_NEXT		0x04
3084ffea0b8Sdrahn /* warnnotfound */
3090acae5e5Sdrahn #define SYM_NOWARNNOTFOUND	0x00
3100acae5e5Sdrahn #define SYM_WARNNOTFOUND	0x10
3114ffea0b8Sdrahn /* inplt */
3120acae5e5Sdrahn #define SYM_NOTPLT		0x00
3130acae5e5Sdrahn #define SYM_PLT			0x20
3140acae5e5Sdrahn 
3150acae5e5Sdrahn #define SYM_DLSYM		0x40
3164be7d39eSrahnds 
31767939fc6Skurt int _dl_load_dep_libs(elf_object_t *object, int flags, int booting);
31861632685Sdrahn int _dl_rtld(elf_object_t *object);
3194d11faf9Srahnds void _dl_call_init(elf_object_t *object);
320ea03aff5Skurt void _dl_link_child(elf_object_t *dep, elf_object_t *p);
321bae526eeSguenther void _dl_link_grpsym(elf_object_t *object);
322bae526eeSguenther void _dl_cache_grpsym_list_setup(elf_object_t *_object);
32350cabf59Skurt void _dl_link_grpref(elf_object_t *load_group, elf_object_t *load_object);
324034b0143Sdrahn void _dl_link_dlopen(elf_object_t *dep);
325034b0143Sdrahn void _dl_notify_unload_shlib(elf_object_t *object);
3260acae5e5Sdrahn void _dl_unload_shlib(elf_object_t *object);
327034b0143Sdrahn void _dl_unload_dlopen(void);
3284d11faf9Srahnds 
329034b0143Sdrahn void _dl_run_all_dtors(void);
3305b36bcefSderaadt 
3310af06aafSkurt int	_dl_match_file(struct sod *sodp, const char *name, int namelen);
332c8dfd7a0Skurt char	*_dl_find_shlib(struct sod *sodp, char **searchpath, int nohints);
3335b36bcefSderaadt void	_dl_load_list_free(struct load_list *load_list);
3345b36bcefSderaadt 
3354098e116Sgnezdo void _dl_push_range_size(struct range_vector *v, vaddr_t start, vsize_t len);
3369ba2c65fSderaadt void _dl_apply_immutable(elf_object_t *object);
3379ba2c65fSderaadt 
33897e4ddacSguenther typedef void lock_cb(int);
33997e4ddacSguenther void	_dl_thread_kern_go(lock_cb *);
34097e4ddacSguenther lock_cb	*_dl_thread_kern_stop(void);
341034b0143Sdrahn 
3424a066defSderaadt int	_dl_islibc(Elf_Dyn *_dynp, Elf_Addr loff);
3434a066defSderaadt void	_dl_pin(int, Elf_Phdr *, void *, size_t, void *, size_t);
3444a066defSderaadt 
345c0197e40Sguenther char	*_dl_getenv(const char *, char **) __boot;
346c0197e40Sguenther void	_dl_unsetenv(const char *, char **) __boot;
347ae398163Smiod 
348c0197e40Sguenther void	_dl_trace_setup(char **) __boot;
349ae398163Smiod void	_dl_trace_object_setup(elf_object_t *);
350ae398163Smiod int	_dl_trace_plt(const elf_object_t *, const char *);
351ae398163Smiod 
352ac42b3c8Sguenther /* dlfcn.c */
353ac42b3c8Sguenther void	_dl_show_objects(elf_object_t *_object);
354ac42b3c8Sguenther 
355fe38b55cSguenther /* tib.c */
356c0197e40Sguenther void	_dl_allocate_tls_offsets(void) __boot;
357c0197e40Sguenther void	_dl_allocate_first_tib(void) __boot;
358fe38b55cSguenther void	_dl_set_tls(elf_object_t *_object, Elf_Phdr *_ptls, Elf_Addr _libaddr,
359fe38b55cSguenther 	    const char *_libname);
360fe38b55cSguenther extern int _dl_tib_static_done;
361fe38b55cSguenther 
3624d11faf9Srahnds extern elf_object_t *_dl_objects;
363bae526eeSguenther extern int object_count;	/* how many objects are currently loaded */
3644d11faf9Srahnds 
3650acae5e5Sdrahn extern elf_object_t *_dl_loading_object;
3660acae5e5Sdrahn 
3674d11faf9Srahnds extern struct r_debug *_dl_debug_map;
3684d11faf9Srahnds 
3694d11faf9Srahnds extern int  _dl_pagesz;
3704d11faf9Srahnds extern int  _dl_errno;
3714d11faf9Srahnds 
372c8dfd7a0Skurt extern char **_dl_libpath;
373c8dfd7a0Skurt 
37410200827Sguenther extern int _dl_bindnow;
37510200827Sguenther extern int _dl_traceld;
37610200827Sguenther extern int _dl_debug;
37710200827Sguenther 
3784d11faf9Srahnds extern char *_dl_preload;
379c28b164bSjason extern char *_dl_tracefmt1;
380c28b164bSjason extern char *_dl_tracefmt2;
381c28b164bSjason extern char *_dl_traceprog;
3824d11faf9Srahnds 
3830458707bSkurt extern void *_dl_exec_hint;
3840458707bSkurt 
385337bd349Skurt extern int _dl_trust;
386337bd349Skurt 
3879c8de590Sart #define DL_DEB(P) do { if (_dl_debug) _dl_printf P ; } while (0)
3889c8de590Sart 
3894d11faf9Srahnds #define	DL_NOT_FOUND		1
3904d11faf9Srahnds #define	DL_CANT_OPEN		2
3914d11faf9Srahnds #define	DL_NOT_ELF		3
3924d11faf9Srahnds #define	DL_CANT_OPEN_REF	4
3934d11faf9Srahnds #define	DL_CANT_MMAP		5
3944d11faf9Srahnds #define	DL_NO_SYMBOL		6
3954d11faf9Srahnds #define	DL_INVALID_HANDLE	7
3964d11faf9Srahnds #define	DL_INVALID_CTL		8
3977be38e1cSdrahn #define	DL_NO_OBJECT		9
3987be38e1cSdrahn #define	DL_CANT_FIND_OBJ	10
39983b41cf4Sdrahn #define	DL_CANT_LOAD_OBJ	11
4000fdecfd0Sguenther #define	DL_INVALID_MODE		12
4014d11faf9Srahnds 
402390a5123Sdrahn #define ELF_ROUND(x,malign) (((x) + (malign)-1) & ~((malign)-1))
403390a5123Sdrahn #define ELF_TRUNC(x,malign) ((x) & ~((malign)-1))
404390a5123Sdrahn 
405c9cd759cSdrahn /* symbol lookup cache */
406c9cd759cSdrahn typedef struct sym_cache {
4079cfbcf89Smickey 	const elf_object_t *obj;
408c9cd759cSdrahn 	const Elf_Sym	*sym;
409c9cd759cSdrahn 	int flags;
410c9cd759cSdrahn } sym_cache;
411c9cd759cSdrahn 
4120acae5e5Sdrahn TAILQ_HEAD(dlochld, dep_node);
4130acae5e5Sdrahn extern struct dlochld _dlopened_child_list;
414702424caSguenther __END_HIDDEN_DECLS
4150acae5e5Sdrahn 
4164d11faf9Srahnds #endif /* _RESOLVE_H_ */
417