xref: /onnv-gate/usr/src/head/dlfcn.h (revision 12449:a87750d92895)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58699SRod.Evans@Sun.COM  * Common Development and Distribution License (the "License").
68699SRod.Evans@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12449SRod.Evans@Sun.COM  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  *
240Sstevel@tonic-gate  *	Copyright (c) 1989 AT&T
250Sstevel@tonic-gate  *	  All Rights Reserved
260Sstevel@tonic-gate  *
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifndef _DLFCN_H
300Sstevel@tonic-gate #define	_DLFCN_H
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/feature_tests.h>
330Sstevel@tonic-gate #include <sys/types.h>
34208Srie #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
356Srie #include <sys/auxv.h>
368699SRod.Evans@Sun.COM #include <sys/mman.h>
37208Srie #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef	__cplusplus
400Sstevel@tonic-gate extern "C" {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
446Srie  * Information structures for various dlinfo() requests.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
470Sstevel@tonic-gate #ifdef __STDC__
480Sstevel@tonic-gate typedef struct	dl_info {
490Sstevel@tonic-gate 	const char	*dli_fname;	/* file containing address range */
500Sstevel@tonic-gate 	void		*dli_fbase;	/* base address of file image */
510Sstevel@tonic-gate 	const char	*dli_sname;	/* symbol name */
520Sstevel@tonic-gate 	void		*dli_saddr;	/* symbol address */
530Sstevel@tonic-gate } Dl_info;
540Sstevel@tonic-gate #else
550Sstevel@tonic-gate typedef struct	dl_info {
560Sstevel@tonic-gate 	char		*dli_fname;
570Sstevel@tonic-gate 	void		*dli_fbase;
580Sstevel@tonic-gate 	char		*dli_sname;
590Sstevel@tonic-gate 	void		*dli_saddr;
600Sstevel@tonic-gate } Dl_info;
610Sstevel@tonic-gate #endif /* __STDC__ */
628699SRod.Evans@Sun.COM typedef	Dl_info		Dl_info_t;
630Sstevel@tonic-gate 
640Sstevel@tonic-gate typedef struct	dl_serpath {
650Sstevel@tonic-gate 	char		*dls_name;	/* library search path name */
660Sstevel@tonic-gate 	uint_t		dls_flags;	/* path information */
670Sstevel@tonic-gate } Dl_serpath;
688699SRod.Evans@Sun.COM typedef	Dl_serpath	Dl_serpath_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate typedef struct	dl_serinfo {
710Sstevel@tonic-gate 	size_t		dls_size;	/* total buffer size */
720Sstevel@tonic-gate 	uint_t		dls_cnt;	/* number of path entries */
730Sstevel@tonic-gate 	Dl_serpath	dls_serpath[1];	/* there may be more than one */
740Sstevel@tonic-gate } Dl_serinfo;
758699SRod.Evans@Sun.COM typedef	Dl_serinfo	Dl_serinfo_t;
766Srie 
776Srie typedef struct	dl_argsinfo {
786Srie 	long		dla_argc;	/* process argument count */
796Srie 	char		**dla_argv;	/* process arguments */
806Srie 	char		**dla_envp;	/* process environment variables */
816Srie 	auxv_t		*dla_auxv;	/* process auxv vectors */
826Srie } Dl_argsinfo;
838699SRod.Evans@Sun.COM typedef	Dl_argsinfo	Dl_argsinfo_t;
848699SRod.Evans@Sun.COM 
858699SRod.Evans@Sun.COM typedef struct {
868699SRod.Evans@Sun.COM 	mmapobj_result_t *dlm_maps;	/* mapping information */
878699SRod.Evans@Sun.COM 	uint_t		dlm_acnt;	/* number of dlm_maps mappings */
888699SRod.Evans@Sun.COM 	uint_t		dlm_rcnt;	/* number of returned mappings */
898699SRod.Evans@Sun.COM } Dl_mapinfo_t;
908699SRod.Evans@Sun.COM 
918699SRod.Evans@Sun.COM typedef struct {
928699SRod.Evans@Sun.COM 	uint_t		dlui_version;	/* version # */
938699SRod.Evans@Sun.COM 	uint_t		dlui_flags;	/* flags */
948699SRod.Evans@Sun.COM 	char		*dlui_objname;	/* path to object */
958699SRod.Evans@Sun.COM 	void		*dlui_unwindstart; /* star of unwind hdr */
968699SRod.Evans@Sun.COM 	void		*dlui_unwindend; /* end of unwind hdr */
978699SRod.Evans@Sun.COM 	void		*dlui_segstart;	/* start of segment described */
988699SRod.Evans@Sun.COM 					/*  by unwind block */
998699SRod.Evans@Sun.COM 	void		*dlui_segend;	/* end of segment described */
1008699SRod.Evans@Sun.COM 					/*  by unwind block */
1018699SRod.Evans@Sun.COM } Dl_amd64_unwindinfo;
1028699SRod.Evans@Sun.COM typedef	Dl_amd64_unwindinfo	Dl_amd64_unwindinfo_t;
1038699SRod.Evans@Sun.COM 
104*12449SRod.Evans@Sun.COM typedef	struct {
105*12449SRod.Evans@Sun.COM 	const char	*dld_refname;	/* reference name */
106*12449SRod.Evans@Sun.COM 	const char	*dld_depname;	/* new dependency name */
107*12449SRod.Evans@Sun.COM } Dl_definfo_t;
108*12449SRod.Evans@Sun.COM 
1090Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate typedef ulong_t		Lmid_t;
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate /*
1150Sstevel@tonic-gate  * Declarations used for dynamic linking support routines.
1160Sstevel@tonic-gate  */
1170Sstevel@tonic-gate #ifdef __STDC__
1180Sstevel@tonic-gate extern void	*dlopen(const char *, int);
1190Sstevel@tonic-gate extern void   	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
1200Sstevel@tonic-gate extern int	dlclose(void *);
1210Sstevel@tonic-gate extern char	*dlerror(void);
1220Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1230Sstevel@tonic-gate extern void	*dlmopen(Lmid_t, const char *, int);
1240Sstevel@tonic-gate extern int	dladdr(void *, Dl_info *);
1250Sstevel@tonic-gate extern int	dladdr1(void *, Dl_info *, void **, int);
1260Sstevel@tonic-gate extern int	dldump(const char *, const char *, int);
1270Sstevel@tonic-gate extern int	dlinfo(void *, int, void *);
1280Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
1290Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1300Sstevel@tonic-gate #else
1310Sstevel@tonic-gate extern void	*dlopen();
1320Sstevel@tonic-gate extern void	*dlsym();
1330Sstevel@tonic-gate extern int	dlclose();
1340Sstevel@tonic-gate extern char	*dlerror();
1350Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1360Sstevel@tonic-gate extern void 	*dlmopen();
1370Sstevel@tonic-gate extern int	dladdr();
1380Sstevel@tonic-gate extern int	dladdr1();
1390Sstevel@tonic-gate extern int	dldump();
1400Sstevel@tonic-gate extern int	dlinfo();
1410Sstevel@tonic-gate extern Dl_amd64_unwindinfo  *dlamd64getunwind();
1420Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1430Sstevel@tonic-gate #endif /* __STDC__ */
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
1460Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
1470Sstevel@tonic-gate #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
1480Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate /*
1510Sstevel@tonic-gate  * Valid values for handle argument to dlsym(3x).
1520Sstevel@tonic-gate  */
1530Sstevel@tonic-gate #define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
1540Sstevel@tonic-gate #define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
1550Sstevel@tonic-gate 						/*	of current object */
1560Sstevel@tonic-gate #define	RTLD_SELF		(void *)-3	/* look in `ourself' */
1570Sstevel@tonic-gate #define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
1580Sstevel@tonic-gate 						/*	of current object, */
1590Sstevel@tonic-gate 						/*	using currently */
1600Sstevel@tonic-gate 						/*	loaded objects only. */
1610Sstevel@tonic-gate /*
1620Sstevel@tonic-gate  * Valid values for mode argument to dlopen.
1630Sstevel@tonic-gate  */
1640Sstevel@tonic-gate #define	RTLD_LAZY		0x00001		/* deferred function binding */
1650Sstevel@tonic-gate #define	RTLD_NOW		0x00002		/* immediate function binding */
1660Sstevel@tonic-gate #define	RTLD_NOLOAD		0x00004		/* don't load object */
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #define	RTLD_GLOBAL		0x00100		/* export symbols to others */
1690Sstevel@tonic-gate #define	RTLD_LOCAL		0x00000		/* symbols are only available */
1700Sstevel@tonic-gate 						/*	to group members */
1710Sstevel@tonic-gate #define	RTLD_PARENT		0x00200		/* add parent (caller) to */
1720Sstevel@tonic-gate 						/*	a group dependencies */
1730Sstevel@tonic-gate #define	RTLD_GROUP		0x00400		/* resolve symbols within */
1740Sstevel@tonic-gate 						/*	members of the group */
1750Sstevel@tonic-gate #define	RTLD_WORLD		0x00800		/* resolve symbols within */
1760Sstevel@tonic-gate 						/*	global objects */
1770Sstevel@tonic-gate #define	RTLD_NODELETE		0x01000		/* do not remove members */
1780Sstevel@tonic-gate #define	RTLD_FIRST		0x02000		/* only first object is */
1790Sstevel@tonic-gate 						/*	available for dlsym */
1800Sstevel@tonic-gate #define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
1810Sstevel@tonic-gate 						/*	internal use only */
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate /*
1840Sstevel@tonic-gate  * Valid values for flag argument to dldump.
1850Sstevel@tonic-gate  */
1860Sstevel@tonic-gate #define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
1870Sstevel@tonic-gate #define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
1880Sstevel@tonic-gate 						/*	bind to main */
1890Sstevel@tonic-gate #define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
1900Sstevel@tonic-gate 						/*	bind to dependencies */
1910Sstevel@tonic-gate #define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
1920Sstevel@tonic-gate 						/*	bind to preload objs */
1930Sstevel@tonic-gate #define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
1940Sstevel@tonic-gate 						/*	bind to ourself */
1950Sstevel@tonic-gate #define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
1960Sstevel@tonic-gate 						/*	even if unresolved */
1970Sstevel@tonic-gate #define	RTLD_REL_ALL		0x00fff 	/* apply all relocs */
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate #define	RTLD_MEMORY		0x01000		/* use memory sections */
2000Sstevel@tonic-gate #define	RTLD_STRIP		0x02000		/* retain allocable sections */
2010Sstevel@tonic-gate 						/*	only */
2020Sstevel@tonic-gate #define	RTLD_NOHEAP		0x04000		/* do no save any heap */
2030Sstevel@tonic-gate #define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
2040Sstevel@tonic-gate 						/*	internal use only */
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate /*
2070Sstevel@tonic-gate  * Valid values for dladdr1() flags.
2080Sstevel@tonic-gate  */
2090Sstevel@tonic-gate #define	RTLD_DL_SYMENT		1		/* return symbol table entry */
2100Sstevel@tonic-gate #define	RTLD_DL_LINKMAP		2		/* return public link-map */
2110Sstevel@tonic-gate #define	RTLD_DL_MASK		0xffff
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate /*
2150Sstevel@tonic-gate  * Arguments for dlinfo()
2160Sstevel@tonic-gate  */
2170Sstevel@tonic-gate #define	RTLD_DI_LMID		1		/* obtain link-map id */
2180Sstevel@tonic-gate #define	RTLD_DI_LINKMAP		2		/* obtain link-map */
2190Sstevel@tonic-gate #define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
2200Sstevel@tonic-gate #define	RTLD_DI_SERINFO		4		/* obtain search path info or */
221*12449SRod.Evans@Sun.COM #define	RTLD_DI_SERINFOSIZE	5		/*    associated info size */
2220Sstevel@tonic-gate #define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
2230Sstevel@tonic-gate #define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
224*12449SRod.Evans@Sun.COM 						/*    internal use only */
2250Sstevel@tonic-gate #define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
226*12449SRod.Evans@Sun.COM 						/*    internal use only */
2270Sstevel@tonic-gate #define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
2280Sstevel@tonic-gate #define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
2296Srie #define	RTLD_DI_ARGSINFO	11		/* get process arguments */
230*12449SRod.Evans@Sun.COM 						/*    environment and auxv */
2318699SRod.Evans@Sun.COM #define	RTLD_DI_MMAPS		12		/* obtain objects mappings or */
232*12449SRod.Evans@Sun.COM #define	RTLD_DI_MMAPCNT		13		/*    mapping count */
233*12449SRod.Evans@Sun.COM #define	RTLD_DI_DEFERRED	14		/* assign new dependency to a */
234*12449SRod.Evans@Sun.COM 						/*    deferred dependency */
235*12449SRod.Evans@Sun.COM #define	RTLD_DI_DEFERRED_SYM	15		/* assign new dependency to a */
236*12449SRod.Evans@Sun.COM 						/*    deferred dependency */
237*12449SRod.Evans@Sun.COM 						/*    using a symbol name */
238*12449SRod.Evans@Sun.COM #define	RTLD_DI_MAX		15
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
2410Sstevel@tonic-gate /*
2420Sstevel@tonic-gate  * Version information for Dl_amd64_unwindinfo.dlui_version
2430Sstevel@tonic-gate  */
2440Sstevel@tonic-gate #define	DLUI_VERS_1		1
2450Sstevel@tonic-gate #define	DLUI_VERS_CURRENT	DLUI_VERS_1
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate /*
2480Sstevel@tonic-gate  * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
2490Sstevel@tonic-gate  */
2500Sstevel@tonic-gate #define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
2510Sstevel@tonic-gate #define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
2520Sstevel@tonic-gate 						/*  matching the pc provided */
2530Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate #ifdef	__cplusplus
2560Sstevel@tonic-gate }
2570Sstevel@tonic-gate #endif
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate #endif	/* _DLFCN_H */
260