xref: /titanic_52/usr/src/head/dlfcn.h (revision 80b8e1d8e1181e1da4f3eccd1df6261d543bf793)
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*80b8e1d8Srie #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
3941072f3cSrie #include <sys/auxv.h>
40*80b8e1d8Srie #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
4741072f3cSrie  * Information structures for various dlinfo() requests.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
507c478bd9Sstevel@tonic-gate #ifdef __STDC__
517c478bd9Sstevel@tonic-gate typedef struct	dl_info {
527c478bd9Sstevel@tonic-gate 	const char	*dli_fname;	/* file containing address range */
537c478bd9Sstevel@tonic-gate 	void		*dli_fbase;	/* base address of file image */
547c478bd9Sstevel@tonic-gate 	const char	*dli_sname;	/* symbol name */
557c478bd9Sstevel@tonic-gate 	void		*dli_saddr;	/* symbol address */
567c478bd9Sstevel@tonic-gate } Dl_info;
577c478bd9Sstevel@tonic-gate #else
587c478bd9Sstevel@tonic-gate typedef struct	dl_info {
597c478bd9Sstevel@tonic-gate 	char		*dli_fname;
607c478bd9Sstevel@tonic-gate 	void		*dli_fbase;
617c478bd9Sstevel@tonic-gate 	char		*dli_sname;
627c478bd9Sstevel@tonic-gate 	void		*dli_saddr;
637c478bd9Sstevel@tonic-gate } Dl_info;
647c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate typedef struct	dl_serpath {
677c478bd9Sstevel@tonic-gate 	char		*dls_name;	/* library search path name */
687c478bd9Sstevel@tonic-gate 	uint_t		dls_flags;	/* path information */
697c478bd9Sstevel@tonic-gate } Dl_serpath;
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;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate typedef struct {
787c478bd9Sstevel@tonic-gate 	uint_t	    dlui_version;	/* version # */
797c478bd9Sstevel@tonic-gate 	uint_t	    dlui_flags;		/* flags */
807c478bd9Sstevel@tonic-gate 	char	    *dlui_objname;	/* path to object */
817c478bd9Sstevel@tonic-gate 	void	    *dlui_unwindstart;	/* star of unwind hdr */
827c478bd9Sstevel@tonic-gate 	void	    *dlui_unwindend;	/* end of unwind hdr */
837c478bd9Sstevel@tonic-gate 	void	    *dlui_segstart;	/* start of segment described */
847c478bd9Sstevel@tonic-gate 					/*  by unwind block */
857c478bd9Sstevel@tonic-gate 	void	    *dlui_segend;	/* end of segment described */
867c478bd9Sstevel@tonic-gate 					/*  by unwind block */
877c478bd9Sstevel@tonic-gate } Dl_amd64_unwindinfo;
8841072f3cSrie 
8941072f3cSrie typedef struct	dl_argsinfo {
9041072f3cSrie 	long		dla_argc;	/* process argument count */
9141072f3cSrie 	char		**dla_argv;	/* process arguments */
9241072f3cSrie 	char		**dla_envp;	/* process environment variables */
9341072f3cSrie 	auxv_t		*dla_auxv;	/* process auxv vectors */
9441072f3cSrie } Dl_argsinfo;
957c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate typedef ulong_t		Lmid_t;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Declarations used for dynamic linking support routines.
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate #ifdef __STDC__
1047c478bd9Sstevel@tonic-gate extern void	*dlopen(const char *, int);
1057c478bd9Sstevel@tonic-gate extern void   	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
1067c478bd9Sstevel@tonic-gate extern int	dlclose(void *);
1077c478bd9Sstevel@tonic-gate extern char	*dlerror(void);
1087c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1097c478bd9Sstevel@tonic-gate extern void	*dlmopen(Lmid_t, const char *, int);
1107c478bd9Sstevel@tonic-gate extern int	dladdr(void *, Dl_info *);
1117c478bd9Sstevel@tonic-gate extern int	dladdr1(void *, Dl_info *, void **, int);
1127c478bd9Sstevel@tonic-gate extern int	dldump(const char *, const char *, int);
1137c478bd9Sstevel@tonic-gate extern int	dlinfo(void *, int, void *);
1147c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
1157c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1167c478bd9Sstevel@tonic-gate #else
1177c478bd9Sstevel@tonic-gate extern void	*dlopen();
1187c478bd9Sstevel@tonic-gate extern void	*dlsym();
1197c478bd9Sstevel@tonic-gate extern int	dlclose();
1207c478bd9Sstevel@tonic-gate extern char	*dlerror();
1217c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1227c478bd9Sstevel@tonic-gate extern void 	*dlmopen();
1237c478bd9Sstevel@tonic-gate extern int	dladdr();
1247c478bd9Sstevel@tonic-gate extern int	dladdr1();
1257c478bd9Sstevel@tonic-gate extern int	dldump();
1267c478bd9Sstevel@tonic-gate extern int	dlinfo();
1277c478bd9Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind();
1287c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1297c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
1327c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1337c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
1347c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate  * Valid values for handle argument to dlsym(3x).
1387c478bd9Sstevel@tonic-gate  */
1397c478bd9Sstevel@tonic-gate #define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
1407c478bd9Sstevel@tonic-gate #define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
1417c478bd9Sstevel@tonic-gate 						/*	of current object */
1427c478bd9Sstevel@tonic-gate #define	RTLD_SELF		(void *)-3	/* look in `ourself' */
1437c478bd9Sstevel@tonic-gate #define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
1447c478bd9Sstevel@tonic-gate 						/*	of current object, */
1457c478bd9Sstevel@tonic-gate 						/*	using currently */
1467c478bd9Sstevel@tonic-gate 						/*	loaded objects only. */
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate  * Valid values for mode argument to dlopen.
1497c478bd9Sstevel@tonic-gate  */
1507c478bd9Sstevel@tonic-gate #define	RTLD_LAZY		0x00001		/* deferred function binding */
1517c478bd9Sstevel@tonic-gate #define	RTLD_NOW		0x00002		/* immediate function binding */
1527c478bd9Sstevel@tonic-gate #define	RTLD_NOLOAD		0x00004		/* don't load object */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #define	RTLD_GLOBAL		0x00100		/* export symbols to others */
1557c478bd9Sstevel@tonic-gate #define	RTLD_LOCAL		0x00000		/* symbols are only available */
1567c478bd9Sstevel@tonic-gate 						/*	to group members */
1577c478bd9Sstevel@tonic-gate #define	RTLD_PARENT		0x00200		/* add parent (caller) to */
1587c478bd9Sstevel@tonic-gate 						/*	a group dependencies */
1597c478bd9Sstevel@tonic-gate #define	RTLD_GROUP		0x00400		/* resolve symbols within */
1607c478bd9Sstevel@tonic-gate 						/*	members of the group */
1617c478bd9Sstevel@tonic-gate #define	RTLD_WORLD		0x00800		/* resolve symbols within */
1627c478bd9Sstevel@tonic-gate 						/*	global objects */
1637c478bd9Sstevel@tonic-gate #define	RTLD_NODELETE		0x01000		/* do not remove members */
1647c478bd9Sstevel@tonic-gate #define	RTLD_FIRST		0x02000		/* only first object is */
1657c478bd9Sstevel@tonic-gate 						/*	available for dlsym */
1667c478bd9Sstevel@tonic-gate #define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
1677c478bd9Sstevel@tonic-gate 						/*	internal use only */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * Valid values for flag argument to dldump.
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate #define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
1737c478bd9Sstevel@tonic-gate #define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
1747c478bd9Sstevel@tonic-gate 						/*	bind to main */
1757c478bd9Sstevel@tonic-gate #define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
1767c478bd9Sstevel@tonic-gate 						/*	bind to dependencies */
1777c478bd9Sstevel@tonic-gate #define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
1787c478bd9Sstevel@tonic-gate 						/*	bind to preload objs */
1797c478bd9Sstevel@tonic-gate #define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
1807c478bd9Sstevel@tonic-gate 						/*	bind to ourself */
1817c478bd9Sstevel@tonic-gate #define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
1827c478bd9Sstevel@tonic-gate 						/*	even if unresolved */
1837c478bd9Sstevel@tonic-gate #define	RTLD_REL_ALL		0x00fff 	/* apply all relocs */
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate #define	RTLD_MEMORY		0x01000		/* use memory sections */
1867c478bd9Sstevel@tonic-gate #define	RTLD_STRIP		0x02000		/* retain allocable sections */
1877c478bd9Sstevel@tonic-gate 						/*	only */
1887c478bd9Sstevel@tonic-gate #define	RTLD_NOHEAP		0x04000		/* do no save any heap */
1897c478bd9Sstevel@tonic-gate #define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
1907c478bd9Sstevel@tonic-gate 						/*	internal use only */
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate  * Valid values for dladdr1() flags.
1947c478bd9Sstevel@tonic-gate  */
1957c478bd9Sstevel@tonic-gate #define	RTLD_DL_SYMENT		1		/* return symbol table entry */
1967c478bd9Sstevel@tonic-gate #define	RTLD_DL_LINKMAP		2		/* return public link-map */
1977c478bd9Sstevel@tonic-gate #define	RTLD_DL_MASK		0xffff
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * Arguments for dlinfo()
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate #define	RTLD_DI_LMID		1		/* obtain link-map id */
2047c478bd9Sstevel@tonic-gate #define	RTLD_DI_LINKMAP		2		/* obtain link-map */
2057c478bd9Sstevel@tonic-gate #define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
2067c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFO		4		/* obtain search path info or */
2077c478bd9Sstevel@tonic-gate #define	RTLD_DI_SERINFOSIZE	5		/*	associated info size */
2087c478bd9Sstevel@tonic-gate #define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
2097c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
2107c478bd9Sstevel@tonic-gate 						/*	internal use only */
2117c478bd9Sstevel@tonic-gate #define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
2127c478bd9Sstevel@tonic-gate 						/*	internal use only */
2137c478bd9Sstevel@tonic-gate #define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
2147c478bd9Sstevel@tonic-gate #define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
21541072f3cSrie #define	RTLD_DI_ARGSINFO	11		/* get process arguments */
21641072f3cSrie 						/*	environment and auxv */
21741072f3cSrie #define	RTLD_DI_MAX		11
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
2207c478bd9Sstevel@tonic-gate /*
2217c478bd9Sstevel@tonic-gate  * Version information for Dl_amd64_unwindinfo.dlui_version
2227c478bd9Sstevel@tonic-gate  */
2237c478bd9Sstevel@tonic-gate #define	DLUI_VERS_1		1
2247c478bd9Sstevel@tonic-gate #define	DLUI_VERS_CURRENT	DLUI_VERS_1
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate  * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
2307c478bd9Sstevel@tonic-gate #define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
2317c478bd9Sstevel@tonic-gate 						/*  matching the pc provided */
2327c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate #endif
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate #endif	/* _DLFCN_H */
239