xref: /titanic_52/usr/src/head/dlfcn.h (revision 41072f3cdbe3949252c173e744eb182ef4cc525f)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  *
267c478bd9Sstevel@tonic-gate  *	Copyright (c) 1989 AT&T
277c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef _DLFCN_H
327c478bd9Sstevel@tonic-gate #define	_DLFCN_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2	*/
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
377c478bd9Sstevel@tonic-gate #include <sys/types.h>
38*41072f3cSrie #include <sys/auxv.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
417c478bd9Sstevel@tonic-gate extern "C" {
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
45*41072f3cSrie  * 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__ */
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;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef struct	dl_serinfo {
707c478bd9Sstevel@tonic-gate 	size_t		dls_size;	/* total buffer size */
717c478bd9Sstevel@tonic-gate 	uint_t		dls_cnt;	/* number of path entries */
727c478bd9Sstevel@tonic-gate 	Dl_serpath	dls_serpath[1];	/* there may be more than one */
737c478bd9Sstevel@tonic-gate } Dl_serinfo;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate typedef struct {
767c478bd9Sstevel@tonic-gate 	uint_t	    dlui_version;	/* version # */
777c478bd9Sstevel@tonic-gate 	uint_t	    dlui_flags;		/* flags */
787c478bd9Sstevel@tonic-gate 	char	    *dlui_objname;	/* path to object */
797c478bd9Sstevel@tonic-gate 	void	    *dlui_unwindstart;	/* star of unwind hdr */
807c478bd9Sstevel@tonic-gate 	void	    *dlui_unwindend;	/* end of unwind hdr */
817c478bd9Sstevel@tonic-gate 	void	    *dlui_segstart;	/* start of segment described */
827c478bd9Sstevel@tonic-gate 					/*  by unwind block */
837c478bd9Sstevel@tonic-gate 	void	    *dlui_segend;	/* end of segment described */
847c478bd9Sstevel@tonic-gate 					/*  by unwind block */
857c478bd9Sstevel@tonic-gate } Dl_amd64_unwindinfo;
86*41072f3cSrie 
87*41072f3cSrie typedef struct	dl_argsinfo {
88*41072f3cSrie 	long		dla_argc;	/* process argument count */
89*41072f3cSrie 	char		**dla_argv;	/* process arguments */
90*41072f3cSrie 	char		**dla_envp;	/* process environment variables */
91*41072f3cSrie 	auxv_t		*dla_auxv;	/* process auxv vectors */
92*41072f3cSrie } Dl_argsinfo;
937c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate typedef ulong_t		Lmid_t;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * Declarations used for dynamic linking support routines.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate #ifdef __STDC__
1027c478bd9Sstevel@tonic-gate extern void	*dlopen(const char *, int);
1037c478bd9Sstevel@tonic-gate extern void   	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
1047c478bd9Sstevel@tonic-gate extern int	dlclose(void *);
1057c478bd9Sstevel@tonic-gate extern char	*dlerror(void);
1067c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1077c478bd9Sstevel@tonic-gate extern void	*dlmopen(Lmid_t, const char *, int);
1087c478bd9Sstevel@tonic-gate extern int	dladdr(void *, Dl_info *);
1097c478bd9Sstevel@tonic-gate extern int	dladdr1(void *, Dl_info *, void **, int);
1107c478bd9Sstevel@tonic-gate extern int	dldump(const char *, const char *, int);
1117c478bd9Sstevel@tonic-gate extern int	dlinfo(void *, int, void *);
1127c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
1137c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1147c478bd9Sstevel@tonic-gate #else
1157c478bd9Sstevel@tonic-gate extern void	*dlopen();
1167c478bd9Sstevel@tonic-gate extern void	*dlsym();
1177c478bd9Sstevel@tonic-gate extern int	dlclose();
1187c478bd9Sstevel@tonic-gate extern char	*dlerror();
1197c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1207c478bd9Sstevel@tonic-gate extern void 	*dlmopen();
1217c478bd9Sstevel@tonic-gate extern int	dladdr();
1227c478bd9Sstevel@tonic-gate extern int	dladdr1();
1237c478bd9Sstevel@tonic-gate extern int	dldump();
1247c478bd9Sstevel@tonic-gate extern int	dlinfo();
1257c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind();
1267c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1277c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
1307c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1317c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
1327c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  * Valid values for handle argument to dlsym(3x).
1367c478bd9Sstevel@tonic-gate  */
1377c478bd9Sstevel@tonic-gate #define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
1387c478bd9Sstevel@tonic-gate #define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
1397c478bd9Sstevel@tonic-gate 						/*	of current object */
1407c478bd9Sstevel@tonic-gate #define	RTLD_SELF		(void *)-3	/* look in `ourself' */
1417c478bd9Sstevel@tonic-gate #define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
1427c478bd9Sstevel@tonic-gate 						/*	of current object, */
1437c478bd9Sstevel@tonic-gate 						/*	using currently */
1447c478bd9Sstevel@tonic-gate 						/*	loaded objects only. */
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * Valid values for mode argument to dlopen.
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate #define	RTLD_LAZY		0x00001		/* deferred function binding */
1497c478bd9Sstevel@tonic-gate #define	RTLD_NOW		0x00002		/* immediate function binding */
1507c478bd9Sstevel@tonic-gate #define	RTLD_NOLOAD		0x00004		/* don't load object */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #define	RTLD_GLOBAL		0x00100		/* export symbols to others */
1537c478bd9Sstevel@tonic-gate #define	RTLD_LOCAL		0x00000		/* symbols are only available */
1547c478bd9Sstevel@tonic-gate 						/*	to group members */
1557c478bd9Sstevel@tonic-gate #define	RTLD_PARENT		0x00200		/* add parent (caller) to */
1567c478bd9Sstevel@tonic-gate 						/*	a group dependencies */
1577c478bd9Sstevel@tonic-gate #define	RTLD_GROUP		0x00400		/* resolve symbols within */
1587c478bd9Sstevel@tonic-gate 						/*	members of the group */
1597c478bd9Sstevel@tonic-gate #define	RTLD_WORLD		0x00800		/* resolve symbols within */
1607c478bd9Sstevel@tonic-gate 						/*	global objects */
1617c478bd9Sstevel@tonic-gate #define	RTLD_NODELETE		0x01000		/* do not remove members */
1627c478bd9Sstevel@tonic-gate #define	RTLD_FIRST		0x02000		/* only first object is */
1637c478bd9Sstevel@tonic-gate 						/*	available for dlsym */
1647c478bd9Sstevel@tonic-gate #define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
1657c478bd9Sstevel@tonic-gate 						/*	internal use only */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate /*
1687c478bd9Sstevel@tonic-gate  * Valid values for flag argument to dldump.
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate #define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
1717c478bd9Sstevel@tonic-gate #define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
1727c478bd9Sstevel@tonic-gate 						/*	bind to main */
1737c478bd9Sstevel@tonic-gate #define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
1747c478bd9Sstevel@tonic-gate 						/*	bind to dependencies */
1757c478bd9Sstevel@tonic-gate #define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
1767c478bd9Sstevel@tonic-gate 						/*	bind to preload objs */
1777c478bd9Sstevel@tonic-gate #define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
1787c478bd9Sstevel@tonic-gate 						/*	bind to ourself */
1797c478bd9Sstevel@tonic-gate #define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
1807c478bd9Sstevel@tonic-gate 						/*	even if unresolved */
1817c478bd9Sstevel@tonic-gate #define	RTLD_REL_ALL		0x00fff 	/* apply all relocs */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #define	RTLD_MEMORY		0x01000		/* use memory sections */
1847c478bd9Sstevel@tonic-gate #define	RTLD_STRIP		0x02000		/* retain allocable sections */
1857c478bd9Sstevel@tonic-gate 						/*	only */
1867c478bd9Sstevel@tonic-gate #define	RTLD_NOHEAP		0x04000		/* do no save any heap */
1877c478bd9Sstevel@tonic-gate #define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
1887c478bd9Sstevel@tonic-gate 						/*	internal use only */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate /*
1917c478bd9Sstevel@tonic-gate  * Valid values for dladdr1() flags.
1927c478bd9Sstevel@tonic-gate  */
1937c478bd9Sstevel@tonic-gate #define	RTLD_DL_SYMENT		1		/* return symbol table entry */
1947c478bd9Sstevel@tonic-gate #define	RTLD_DL_LINKMAP		2		/* return public link-map */
1957c478bd9Sstevel@tonic-gate #define	RTLD_DL_MASK		0xffff
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*
1997c478bd9Sstevel@tonic-gate  * Arguments for dlinfo()
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate #define	RTLD_DI_LMID		1		/* obtain link-map id */
2027c478bd9Sstevel@tonic-gate #define	RTLD_DI_LINKMAP		2		/* obtain link-map */
2037c478bd9Sstevel@tonic-gate #define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
2047c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFO		4		/* obtain search path info or */
2057c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFOSIZE	5		/*	associated info size */
2067c478bd9Sstevel@tonic-gate #define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
2077c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
2087c478bd9Sstevel@tonic-gate 						/*	internal use only */
2097c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
2107c478bd9Sstevel@tonic-gate 						/*	internal use only */
2117c478bd9Sstevel@tonic-gate #define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
2127c478bd9Sstevel@tonic-gate #define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
213*41072f3cSrie #define	RTLD_DI_ARGSINFO	11		/* get process arguments */
214*41072f3cSrie 						/*	environment and auxv */
215*41072f3cSrie #define	RTLD_DI_MAX		11
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
2187c478bd9Sstevel@tonic-gate /*
2197c478bd9Sstevel@tonic-gate  * Version information for Dl_amd64_unwindinfo.dlui_version
2207c478bd9Sstevel@tonic-gate  */
2217c478bd9Sstevel@tonic-gate #define	DLUI_VERS_1		1
2227c478bd9Sstevel@tonic-gate #define	DLUI_VERS_CURRENT	DLUI_VERS_1
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate /*
2257c478bd9Sstevel@tonic-gate  * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
2267c478bd9Sstevel@tonic-gate  */
2277c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
2287c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
2297c478bd9Sstevel@tonic-gate 						/*  matching the pc provided */
2307c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2337c478bd9Sstevel@tonic-gate }
2347c478bd9Sstevel@tonic-gate #endif
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate #endif	/* _DLFCN_H */
237