xref: /titanic_50/usr/src/head/dlfcn.h (revision f441771b0ce9f9d6122d318ff8290cb1a2848f9d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5959ee943SRod Evans  * Common Development and Distribution License (the "License").
6959ee943SRod Evans  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*f441771bSRod Evans  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  *
247c478bd9Sstevel@tonic-gate  *	Copyright (c) 1989 AT&T
257c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
267c478bd9Sstevel@tonic-gate  *
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef _DLFCN_H
307c478bd9Sstevel@tonic-gate #define	_DLFCN_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
3480b8e1d8Srie #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
3541072f3cSrie #include <sys/auxv.h>
36959ee943SRod Evans #include <sys/mman.h>
3780b8e1d8Srie #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
4441072f3cSrie  * Information structures for various dlinfo() requests.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
477c478bd9Sstevel@tonic-gate #ifdef __STDC__
487c478bd9Sstevel@tonic-gate typedef struct	dl_info {
497c478bd9Sstevel@tonic-gate 	const char	*dli_fname;	/* file containing address range */
507c478bd9Sstevel@tonic-gate 	void		*dli_fbase;	/* base address of file image */
517c478bd9Sstevel@tonic-gate 	const char	*dli_sname;	/* symbol name */
527c478bd9Sstevel@tonic-gate 	void		*dli_saddr;	/* symbol address */
537c478bd9Sstevel@tonic-gate } Dl_info;
547c478bd9Sstevel@tonic-gate #else
557c478bd9Sstevel@tonic-gate typedef struct	dl_info {
567c478bd9Sstevel@tonic-gate 	char		*dli_fname;
577c478bd9Sstevel@tonic-gate 	void		*dli_fbase;
587c478bd9Sstevel@tonic-gate 	char		*dli_sname;
597c478bd9Sstevel@tonic-gate 	void		*dli_saddr;
607c478bd9Sstevel@tonic-gate } Dl_info;
617c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
62959ee943SRod Evans typedef	Dl_info		Dl_info_t;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate typedef struct	dl_serpath {
657c478bd9Sstevel@tonic-gate 	char		*dls_name;	/* library search path name */
667c478bd9Sstevel@tonic-gate 	uint_t		dls_flags;	/* path information */
677c478bd9Sstevel@tonic-gate } Dl_serpath;
68959ee943SRod Evans typedef	Dl_serpath	Dl_serpath_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate typedef struct	dl_serinfo {
717c478bd9Sstevel@tonic-gate 	size_t		dls_size;	/* total buffer size */
727c478bd9Sstevel@tonic-gate 	uint_t		dls_cnt;	/* number of path entries */
737c478bd9Sstevel@tonic-gate 	Dl_serpath	dls_serpath[1];	/* there may be more than one */
747c478bd9Sstevel@tonic-gate } Dl_serinfo;
75959ee943SRod Evans typedef	Dl_serinfo	Dl_serinfo_t;
76959ee943SRod Evans 
77959ee943SRod Evans typedef struct	dl_argsinfo {
78959ee943SRod Evans 	long		dla_argc;	/* process argument count */
79959ee943SRod Evans 	char		**dla_argv;	/* process arguments */
80959ee943SRod Evans 	char		**dla_envp;	/* process environment variables */
81959ee943SRod Evans 	auxv_t		*dla_auxv;	/* process auxv vectors */
82959ee943SRod Evans } Dl_argsinfo;
83959ee943SRod Evans typedef	Dl_argsinfo	Dl_argsinfo_t;
84959ee943SRod Evans 
85959ee943SRod Evans typedef struct {
86959ee943SRod Evans 	mmapobj_result_t *dlm_maps;	/* mapping information */
87959ee943SRod Evans 	uint_t		dlm_acnt;	/* number of dlm_maps mappings */
88959ee943SRod Evans 	uint_t		dlm_rcnt;	/* number of returned mappings */
89959ee943SRod Evans } Dl_mapinfo_t;
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate typedef struct {
927c478bd9Sstevel@tonic-gate 	uint_t		dlui_version;	/* version # */
937c478bd9Sstevel@tonic-gate 	uint_t		dlui_flags;	/* flags */
947c478bd9Sstevel@tonic-gate 	char		*dlui_objname;	/* path to object */
957c478bd9Sstevel@tonic-gate 	void		*dlui_unwindstart; /* star of unwind hdr */
967c478bd9Sstevel@tonic-gate 	void		*dlui_unwindend; /* end of unwind hdr */
977c478bd9Sstevel@tonic-gate 	void		*dlui_segstart;	/* start of segment described */
987c478bd9Sstevel@tonic-gate 					/*  by unwind block */
997c478bd9Sstevel@tonic-gate 	void		*dlui_segend;	/* end of segment described */
1007c478bd9Sstevel@tonic-gate 					/*  by unwind block */
1017c478bd9Sstevel@tonic-gate } Dl_amd64_unwindinfo;
102959ee943SRod Evans typedef	Dl_amd64_unwindinfo	Dl_amd64_unwindinfo_t;
10341072f3cSrie 
104*f441771bSRod Evans typedef	struct {
105*f441771bSRod Evans 	const char	*dld_refname;	/* reference name */
106*f441771bSRod Evans 	const char	*dld_depname;	/* new dependency name */
107*f441771bSRod Evans } Dl_definfo_t;
108*f441771bSRod Evans 
1097c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate typedef ulong_t		Lmid_t;
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate  * Declarations used for dynamic linking support routines.
1167c478bd9Sstevel@tonic-gate  */
1177c478bd9Sstevel@tonic-gate #ifdef __STDC__
1187c478bd9Sstevel@tonic-gate extern void	*dlopen(const char *, int);
1197c478bd9Sstevel@tonic-gate extern void   	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
1207c478bd9Sstevel@tonic-gate extern int	dlclose(void *);
1217c478bd9Sstevel@tonic-gate extern char	*dlerror(void);
1227c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1237c478bd9Sstevel@tonic-gate extern void	*dlmopen(Lmid_t, const char *, int);
1247c478bd9Sstevel@tonic-gate extern int	dladdr(void *, Dl_info *);
1257c478bd9Sstevel@tonic-gate extern int	dladdr1(void *, Dl_info *, void **, int);
1267c478bd9Sstevel@tonic-gate extern int	dldump(const char *, const char *, int);
1277c478bd9Sstevel@tonic-gate extern int	dlinfo(void *, int, void *);
1287c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
1297c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1307c478bd9Sstevel@tonic-gate #else
1317c478bd9Sstevel@tonic-gate extern void	*dlopen();
1327c478bd9Sstevel@tonic-gate extern void	*dlsym();
1337c478bd9Sstevel@tonic-gate extern int	dlclose();
1347c478bd9Sstevel@tonic-gate extern char	*dlerror();
1357c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1367c478bd9Sstevel@tonic-gate extern void 	*dlmopen();
1377c478bd9Sstevel@tonic-gate extern int	dladdr();
1387c478bd9Sstevel@tonic-gate extern int	dladdr1();
1397c478bd9Sstevel@tonic-gate extern int	dldump();
1407c478bd9Sstevel@tonic-gate extern int	dlinfo();
1417c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind();
1427c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1437c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
1467c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1477c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
1487c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  * Valid values for handle argument to dlsym(3x).
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate #define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
1547c478bd9Sstevel@tonic-gate #define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
1557c478bd9Sstevel@tonic-gate 						/*	of current object */
1567c478bd9Sstevel@tonic-gate #define	RTLD_SELF		(void *)-3	/* look in `ourself' */
1577c478bd9Sstevel@tonic-gate #define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
1587c478bd9Sstevel@tonic-gate 						/*	of current object, */
1597c478bd9Sstevel@tonic-gate 						/*	using currently */
1607c478bd9Sstevel@tonic-gate 						/*	loaded objects only. */
1617c478bd9Sstevel@tonic-gate /*
1627c478bd9Sstevel@tonic-gate  * Valid values for mode argument to dlopen.
1637c478bd9Sstevel@tonic-gate  */
1647c478bd9Sstevel@tonic-gate #define	RTLD_LAZY		0x00001		/* deferred function binding */
1657c478bd9Sstevel@tonic-gate #define	RTLD_NOW		0x00002		/* immediate function binding */
1667c478bd9Sstevel@tonic-gate #define	RTLD_NOLOAD		0x00004		/* don't load object */
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #define	RTLD_GLOBAL		0x00100		/* export symbols to others */
1697c478bd9Sstevel@tonic-gate #define	RTLD_LOCAL		0x00000		/* symbols are only available */
1707c478bd9Sstevel@tonic-gate 						/*	to group members */
1717c478bd9Sstevel@tonic-gate #define	RTLD_PARENT		0x00200		/* add parent (caller) to */
1727c478bd9Sstevel@tonic-gate 						/*	a group dependencies */
1737c478bd9Sstevel@tonic-gate #define	RTLD_GROUP		0x00400		/* resolve symbols within */
1747c478bd9Sstevel@tonic-gate 						/*	members of the group */
1757c478bd9Sstevel@tonic-gate #define	RTLD_WORLD		0x00800		/* resolve symbols within */
1767c478bd9Sstevel@tonic-gate 						/*	global objects */
1777c478bd9Sstevel@tonic-gate #define	RTLD_NODELETE		0x01000		/* do not remove members */
1787c478bd9Sstevel@tonic-gate #define	RTLD_FIRST		0x02000		/* only first object is */
1797c478bd9Sstevel@tonic-gate 						/*	available for dlsym */
1807c478bd9Sstevel@tonic-gate #define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
1817c478bd9Sstevel@tonic-gate 						/*	internal use only */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * Valid values for flag argument to dldump.
1857c478bd9Sstevel@tonic-gate  */
1867c478bd9Sstevel@tonic-gate #define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
1877c478bd9Sstevel@tonic-gate #define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
1887c478bd9Sstevel@tonic-gate 						/*	bind to main */
1897c478bd9Sstevel@tonic-gate #define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
1907c478bd9Sstevel@tonic-gate 						/*	bind to dependencies */
1917c478bd9Sstevel@tonic-gate #define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
1927c478bd9Sstevel@tonic-gate 						/*	bind to preload objs */
1937c478bd9Sstevel@tonic-gate #define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
1947c478bd9Sstevel@tonic-gate 						/*	bind to ourself */
1957c478bd9Sstevel@tonic-gate #define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
1967c478bd9Sstevel@tonic-gate 						/*	even if unresolved */
1977c478bd9Sstevel@tonic-gate #define	RTLD_REL_ALL		0x00fff 	/* apply all relocs */
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate #define	RTLD_MEMORY		0x01000		/* use memory sections */
2007c478bd9Sstevel@tonic-gate #define	RTLD_STRIP		0x02000		/* retain allocable sections */
2017c478bd9Sstevel@tonic-gate 						/*	only */
2027c478bd9Sstevel@tonic-gate #define	RTLD_NOHEAP		0x04000		/* do no save any heap */
2037c478bd9Sstevel@tonic-gate #define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
2047c478bd9Sstevel@tonic-gate 						/*	internal use only */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  * Valid values for dladdr1() flags.
2087c478bd9Sstevel@tonic-gate  */
2097c478bd9Sstevel@tonic-gate #define	RTLD_DL_SYMENT		1		/* return symbol table entry */
2107c478bd9Sstevel@tonic-gate #define	RTLD_DL_LINKMAP		2		/* return public link-map */
2117c478bd9Sstevel@tonic-gate #define	RTLD_DL_MASK		0xffff
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate  * Arguments for dlinfo()
2167c478bd9Sstevel@tonic-gate  */
2177c478bd9Sstevel@tonic-gate #define	RTLD_DI_LMID		1		/* obtain link-map id */
2187c478bd9Sstevel@tonic-gate #define	RTLD_DI_LINKMAP		2		/* obtain link-map */
2197c478bd9Sstevel@tonic-gate #define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
2207c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFO		4		/* obtain search path info or */
2217c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFOSIZE	5		/*    associated info size */
2227c478bd9Sstevel@tonic-gate #define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
2237c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
2247c478bd9Sstevel@tonic-gate 						/*    internal use only */
2257c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
2267c478bd9Sstevel@tonic-gate 						/*    internal use only */
2277c478bd9Sstevel@tonic-gate #define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
2287c478bd9Sstevel@tonic-gate #define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
22941072f3cSrie #define	RTLD_DI_ARGSINFO	11		/* get process arguments */
23041072f3cSrie 						/*    environment and auxv */
231959ee943SRod Evans #define	RTLD_DI_MMAPS		12		/* obtain objects mappings or */
232959ee943SRod Evans #define	RTLD_DI_MMAPCNT		13		/*    mapping count */
233*f441771bSRod Evans #define	RTLD_DI_DEFERRED	14		/* assign new dependency to a */
234*f441771bSRod Evans 						/*    deferred dependency */
235*f441771bSRod Evans #define	RTLD_DI_DEFERRED_SYM	15		/* assign new dependency to a */
236*f441771bSRod Evans 						/*    deferred dependency */
237*f441771bSRod Evans 						/*    using a symbol name */
238*f441771bSRod Evans #define	RTLD_DI_MAX		15
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
2417c478bd9Sstevel@tonic-gate /*
2427c478bd9Sstevel@tonic-gate  * Version information for Dl_amd64_unwindinfo.dlui_version
2437c478bd9Sstevel@tonic-gate  */
2447c478bd9Sstevel@tonic-gate #define	DLUI_VERS_1		1
2457c478bd9Sstevel@tonic-gate #define	DLUI_VERS_CURRENT	DLUI_VERS_1
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
2497c478bd9Sstevel@tonic-gate  */
2507c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
2517c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
2527c478bd9Sstevel@tonic-gate 						/*  matching the pc provided */
2537c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2567c478bd9Sstevel@tonic-gate }
2577c478bd9Sstevel@tonic-gate #endif
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate #endif	/* _DLFCN_H */
260