xref: /titanic_52/usr/src/head/dlfcn.h (revision 959ee9437869ba1ddb2763b82b8773f25e5871d0)
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
5*959ee943SRod Evans  * Common Development and Distribution License (the "License").
6*959ee943SRod 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*959ee943SRod Evans  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  *	Copyright (c) 1989 AT&T
267c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
277c478bd9Sstevel@tonic-gate  *
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _DLFCN_H
317c478bd9Sstevel@tonic-gate #define	_DLFCN_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
3580b8e1d8Srie #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
3641072f3cSrie #include <sys/auxv.h>
37*959ee943SRod Evans #include <sys/mman.h>
3880b8e1d8Srie #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
417c478bd9Sstevel@tonic-gate extern "C" {
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
4541072f3cSrie  * Information structures for various dlinfo() requests.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
487c478bd9Sstevel@tonic-gate #ifdef __STDC__
497c478bd9Sstevel@tonic-gate typedef struct	dl_info {
507c478bd9Sstevel@tonic-gate 	const char	*dli_fname;	/* file containing address range */
517c478bd9Sstevel@tonic-gate 	void		*dli_fbase;	/* base address of file image */
527c478bd9Sstevel@tonic-gate 	const char	*dli_sname;	/* symbol name */
537c478bd9Sstevel@tonic-gate 	void		*dli_saddr;	/* symbol address */
547c478bd9Sstevel@tonic-gate } Dl_info;
557c478bd9Sstevel@tonic-gate #else
567c478bd9Sstevel@tonic-gate typedef struct	dl_info {
577c478bd9Sstevel@tonic-gate 	char		*dli_fname;
587c478bd9Sstevel@tonic-gate 	void		*dli_fbase;
597c478bd9Sstevel@tonic-gate 	char		*dli_sname;
607c478bd9Sstevel@tonic-gate 	void		*dli_saddr;
617c478bd9Sstevel@tonic-gate } Dl_info;
627c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
63*959ee943SRod Evans typedef	Dl_info		Dl_info_t;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate typedef struct	dl_serpath {
667c478bd9Sstevel@tonic-gate 	char		*dls_name;	/* library search path name */
677c478bd9Sstevel@tonic-gate 	uint_t		dls_flags;	/* path information */
687c478bd9Sstevel@tonic-gate } Dl_serpath;
69*959ee943SRod Evans typedef	Dl_serpath	Dl_serpath_t;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate typedef struct	dl_serinfo {
727c478bd9Sstevel@tonic-gate 	size_t		dls_size;	/* total buffer size */
737c478bd9Sstevel@tonic-gate 	uint_t		dls_cnt;	/* number of path entries */
747c478bd9Sstevel@tonic-gate 	Dl_serpath	dls_serpath[1];	/* there may be more than one */
757c478bd9Sstevel@tonic-gate } Dl_serinfo;
76*959ee943SRod Evans typedef	Dl_serinfo	Dl_serinfo_t;
77*959ee943SRod Evans 
78*959ee943SRod Evans typedef struct	dl_argsinfo {
79*959ee943SRod Evans 	long		dla_argc;	/* process argument count */
80*959ee943SRod Evans 	char		**dla_argv;	/* process arguments */
81*959ee943SRod Evans 	char		**dla_envp;	/* process environment variables */
82*959ee943SRod Evans 	auxv_t		*dla_auxv;	/* process auxv vectors */
83*959ee943SRod Evans } Dl_argsinfo;
84*959ee943SRod Evans typedef	Dl_argsinfo	Dl_argsinfo_t;
85*959ee943SRod Evans 
86*959ee943SRod Evans typedef struct {
87*959ee943SRod Evans 	mmapobj_result_t *dlm_maps;	/* mapping information */
88*959ee943SRod Evans 	uint_t		dlm_acnt;	/* number of dlm_maps mappings */
89*959ee943SRod Evans 	uint_t		dlm_rcnt;	/* number of returned mappings */
90*959ee943SRod Evans } Dl_mapinfo_t;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate typedef struct {
937c478bd9Sstevel@tonic-gate 	uint_t		dlui_version;	/* version # */
947c478bd9Sstevel@tonic-gate 	uint_t		dlui_flags;	/* flags */
957c478bd9Sstevel@tonic-gate 	char		*dlui_objname;	/* path to object */
967c478bd9Sstevel@tonic-gate 	void		*dlui_unwindstart; /* star of unwind hdr */
977c478bd9Sstevel@tonic-gate 	void		*dlui_unwindend; /* end of unwind hdr */
987c478bd9Sstevel@tonic-gate 	void		*dlui_segstart;	/* start of segment described */
997c478bd9Sstevel@tonic-gate 					/*  by unwind block */
1007c478bd9Sstevel@tonic-gate 	void		*dlui_segend;	/* end of segment described */
1017c478bd9Sstevel@tonic-gate 					/*  by unwind block */
1027c478bd9Sstevel@tonic-gate } Dl_amd64_unwindinfo;
103*959ee943SRod Evans typedef	Dl_amd64_unwindinfo	Dl_amd64_unwindinfo_t;
10441072f3cSrie 
1057c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate typedef ulong_t		Lmid_t;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Declarations used for dynamic linking support routines.
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate #ifdef __STDC__
1147c478bd9Sstevel@tonic-gate extern void	*dlopen(const char *, int);
1157c478bd9Sstevel@tonic-gate extern void   	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
1167c478bd9Sstevel@tonic-gate extern int	dlclose(void *);
1177c478bd9Sstevel@tonic-gate extern char	*dlerror(void);
1187c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1197c478bd9Sstevel@tonic-gate extern void	*dlmopen(Lmid_t, const char *, int);
1207c478bd9Sstevel@tonic-gate extern int	dladdr(void *, Dl_info *);
1217c478bd9Sstevel@tonic-gate extern int	dladdr1(void *, Dl_info *, void **, int);
1227c478bd9Sstevel@tonic-gate extern int	dldump(const char *, const char *, int);
1237c478bd9Sstevel@tonic-gate extern int	dlinfo(void *, int, void *);
1247c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
1257c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1267c478bd9Sstevel@tonic-gate #else
1277c478bd9Sstevel@tonic-gate extern void	*dlopen();
1287c478bd9Sstevel@tonic-gate extern void	*dlsym();
1297c478bd9Sstevel@tonic-gate extern int	dlclose();
1307c478bd9Sstevel@tonic-gate extern char	*dlerror();
1317c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1327c478bd9Sstevel@tonic-gate extern void 	*dlmopen();
1337c478bd9Sstevel@tonic-gate extern int	dladdr();
1347c478bd9Sstevel@tonic-gate extern int	dladdr1();
1357c478bd9Sstevel@tonic-gate extern int	dldump();
1367c478bd9Sstevel@tonic-gate extern int	dlinfo();
1377c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind();
1387c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1397c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
1427c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1437c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
1447c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * Valid values for handle argument to dlsym(3x).
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate #define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
1507c478bd9Sstevel@tonic-gate #define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
1517c478bd9Sstevel@tonic-gate 						/*	of current object */
1527c478bd9Sstevel@tonic-gate #define	RTLD_SELF		(void *)-3	/* look in `ourself' */
1537c478bd9Sstevel@tonic-gate #define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
1547c478bd9Sstevel@tonic-gate 						/*	of current object, */
1557c478bd9Sstevel@tonic-gate 						/*	using currently */
1567c478bd9Sstevel@tonic-gate 						/*	loaded objects only. */
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate  * Valid values for mode argument to dlopen.
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate #define	RTLD_LAZY		0x00001		/* deferred function binding */
1617c478bd9Sstevel@tonic-gate #define	RTLD_NOW		0x00002		/* immediate function binding */
1627c478bd9Sstevel@tonic-gate #define	RTLD_NOLOAD		0x00004		/* don't load object */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate #define	RTLD_GLOBAL		0x00100		/* export symbols to others */
1657c478bd9Sstevel@tonic-gate #define	RTLD_LOCAL		0x00000		/* symbols are only available */
1667c478bd9Sstevel@tonic-gate 						/*	to group members */
1677c478bd9Sstevel@tonic-gate #define	RTLD_PARENT		0x00200		/* add parent (caller) to */
1687c478bd9Sstevel@tonic-gate 						/*	a group dependencies */
1697c478bd9Sstevel@tonic-gate #define	RTLD_GROUP		0x00400		/* resolve symbols within */
1707c478bd9Sstevel@tonic-gate 						/*	members of the group */
1717c478bd9Sstevel@tonic-gate #define	RTLD_WORLD		0x00800		/* resolve symbols within */
1727c478bd9Sstevel@tonic-gate 						/*	global objects */
1737c478bd9Sstevel@tonic-gate #define	RTLD_NODELETE		0x01000		/* do not remove members */
1747c478bd9Sstevel@tonic-gate #define	RTLD_FIRST		0x02000		/* only first object is */
1757c478bd9Sstevel@tonic-gate 						/*	available for dlsym */
1767c478bd9Sstevel@tonic-gate #define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
1777c478bd9Sstevel@tonic-gate 						/*	internal use only */
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate  * Valid values for flag argument to dldump.
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate #define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
1837c478bd9Sstevel@tonic-gate #define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
1847c478bd9Sstevel@tonic-gate 						/*	bind to main */
1857c478bd9Sstevel@tonic-gate #define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
1867c478bd9Sstevel@tonic-gate 						/*	bind to dependencies */
1877c478bd9Sstevel@tonic-gate #define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
1887c478bd9Sstevel@tonic-gate 						/*	bind to preload objs */
1897c478bd9Sstevel@tonic-gate #define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
1907c478bd9Sstevel@tonic-gate 						/*	bind to ourself */
1917c478bd9Sstevel@tonic-gate #define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
1927c478bd9Sstevel@tonic-gate 						/*	even if unresolved */
1937c478bd9Sstevel@tonic-gate #define	RTLD_REL_ALL		0x00fff 	/* apply all relocs */
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #define	RTLD_MEMORY		0x01000		/* use memory sections */
1967c478bd9Sstevel@tonic-gate #define	RTLD_STRIP		0x02000		/* retain allocable sections */
1977c478bd9Sstevel@tonic-gate 						/*	only */
1987c478bd9Sstevel@tonic-gate #define	RTLD_NOHEAP		0x04000		/* do no save any heap */
1997c478bd9Sstevel@tonic-gate #define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
2007c478bd9Sstevel@tonic-gate 						/*	internal use only */
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * Valid values for dladdr1() flags.
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate #define	RTLD_DL_SYMENT		1		/* return symbol table entry */
2067c478bd9Sstevel@tonic-gate #define	RTLD_DL_LINKMAP		2		/* return public link-map */
2077c478bd9Sstevel@tonic-gate #define	RTLD_DL_MASK		0xffff
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate /*
2117c478bd9Sstevel@tonic-gate  * Arguments for dlinfo()
2127c478bd9Sstevel@tonic-gate  */
2137c478bd9Sstevel@tonic-gate #define	RTLD_DI_LMID		1		/* obtain link-map id */
2147c478bd9Sstevel@tonic-gate #define	RTLD_DI_LINKMAP		2		/* obtain link-map */
2157c478bd9Sstevel@tonic-gate #define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
2167c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFO		4		/* obtain search path info or */
2177c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFOSIZE	5		/*	associated info size */
2187c478bd9Sstevel@tonic-gate #define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
2197c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
2207c478bd9Sstevel@tonic-gate 						/*	internal use only */
2217c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
2227c478bd9Sstevel@tonic-gate 						/*	internal use only */
2237c478bd9Sstevel@tonic-gate #define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
2247c478bd9Sstevel@tonic-gate #define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
22541072f3cSrie #define	RTLD_DI_ARGSINFO	11		/* get process arguments */
22641072f3cSrie 						/*	environment and auxv */
227*959ee943SRod Evans #define	RTLD_DI_MMAPS		12		/* obtain objects mappings or */
228*959ee943SRod Evans #define	RTLD_DI_MMAPCNT		13		/*	mapping count */
229*959ee943SRod Evans #define	RTLD_DI_MAX		13
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
2327c478bd9Sstevel@tonic-gate /*
2337c478bd9Sstevel@tonic-gate  * Version information for Dl_amd64_unwindinfo.dlui_version
2347c478bd9Sstevel@tonic-gate  */
2357c478bd9Sstevel@tonic-gate #define	DLUI_VERS_1		1
2367c478bd9Sstevel@tonic-gate #define	DLUI_VERS_CURRENT	DLUI_VERS_1
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate /*
2397c478bd9Sstevel@tonic-gate  * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
2407c478bd9Sstevel@tonic-gate  */
2417c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
2427c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
2437c478bd9Sstevel@tonic-gate 						/*  matching the pc provided */
2447c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2477c478bd9Sstevel@tonic-gate }
2487c478bd9Sstevel@tonic-gate #endif
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate #endif	/* _DLFCN_H */
251