Home | History | Annotate | Download | only in head
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  *
     26  *	Copyright (c) 1989 AT&T
     27  *	  All Rights Reserved
     28  *
     29  */
     30 
     31 #ifndef _DLFCN_H
     32 #define	_DLFCN_H
     33 
     34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2	*/
     35 
     36 #include <sys/feature_tests.h>
     37 #include <sys/types.h>
     38 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
     39 #include <sys/auxv.h>
     40 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
     41 
     42 #ifdef	__cplusplus
     43 extern "C" {
     44 #endif
     45 
     46 /*
     47  * Information structures for various dlinfo() requests.
     48  */
     49 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
     50 #ifdef __STDC__
     51 typedef struct	dl_info {
     52 	const char	*dli_fname;	/* file containing address range */
     53 	void		*dli_fbase;	/* base address of file image */
     54 	const char	*dli_sname;	/* symbol name */
     55 	void		*dli_saddr;	/* symbol address */
     56 } Dl_info;
     57 #else
     58 typedef struct	dl_info {
     59 	char		*dli_fname;
     60 	void		*dli_fbase;
     61 	char		*dli_sname;
     62 	void		*dli_saddr;
     63 } Dl_info;
     64 #endif /* __STDC__ */
     65 
     66 typedef struct	dl_serpath {
     67 	char		*dls_name;	/* library search path name */
     68 	uint_t		dls_flags;	/* path information */
     69 } Dl_serpath;
     70 
     71 typedef struct	dl_serinfo {
     72 	size_t		dls_size;	/* total buffer size */
     73 	uint_t		dls_cnt;	/* number of path entries */
     74 	Dl_serpath	dls_serpath[1];	/* there may be more than one */
     75 } Dl_serinfo;
     76 
     77 typedef struct {
     78 	uint_t	    dlui_version;	/* version # */
     79 	uint_t	    dlui_flags;		/* flags */
     80 	char	    *dlui_objname;	/* path to object */
     81 	void	    *dlui_unwindstart;	/* star of unwind hdr */
     82 	void	    *dlui_unwindend;	/* end of unwind hdr */
     83 	void	    *dlui_segstart;	/* start of segment described */
     84 					/*  by unwind block */
     85 	void	    *dlui_segend;	/* end of segment described */
     86 					/*  by unwind block */
     87 } Dl_amd64_unwindinfo;
     88 
     89 typedef struct	dl_argsinfo {
     90 	long		dla_argc;	/* process argument count */
     91 	char		**dla_argv;	/* process arguments */
     92 	char		**dla_envp;	/* process environment variables */
     93 	auxv_t		*dla_auxv;	/* process auxv vectors */
     94 } Dl_argsinfo;
     95 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
     96 
     97 
     98 typedef ulong_t		Lmid_t;
     99 
    100 /*
    101  * Declarations used for dynamic linking support routines.
    102  */
    103 #ifdef __STDC__
    104 extern void	*dlopen(const char *, int);
    105 extern void   	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
    106 extern int	dlclose(void *);
    107 extern char	*dlerror(void);
    108 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
    109 extern void	*dlmopen(Lmid_t, const char *, int);
    110 extern int	dladdr(void *, Dl_info *);
    111 extern int	dladdr1(void *, Dl_info *, void **, int);
    112 extern int	dldump(const char *, const char *, int);
    113 extern int	dlinfo(void *, int, void *);
    114 extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
    115 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
    116 #else
    117 extern void	*dlopen();
    118 extern void	*dlsym();
    119 extern int	dlclose();
    120 extern char	*dlerror();
    121 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
    122 extern void 	*dlmopen();
    123 extern int	dladdr();
    124 extern int	dladdr1();
    125 extern int	dldump();
    126 extern int	dlinfo();
    127 extern Dl_amd64_unwindinfo  *dlamd64getunwind();
    128 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
    129 #endif /* __STDC__ */
    130 
    131 #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
    132 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
    133 #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
    134 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
    135 
    136 /*
    137  * Valid values for handle argument to dlsym(3x).
    138  */
    139 #define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
    140 #define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
    141 						/*	of current object */
    142 #define	RTLD_SELF		(void *)-3	/* look in `ourself' */
    143 #define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
    144 						/*	of current object, */
    145 						/*	using currently */
    146 						/*	loaded objects only. */
    147 /*
    148  * Valid values for mode argument to dlopen.
    149  */
    150 #define	RTLD_LAZY		0x00001		/* deferred function binding */
    151 #define	RTLD_NOW		0x00002		/* immediate function binding */
    152 #define	RTLD_NOLOAD		0x00004		/* don't load object */
    153 
    154 #define	RTLD_GLOBAL		0x00100		/* export symbols to others */
    155 #define	RTLD_LOCAL		0x00000		/* symbols are only available */
    156 						/*	to group members */
    157 #define	RTLD_PARENT		0x00200		/* add parent (caller) to */
    158 						/*	a group dependencies */
    159 #define	RTLD_GROUP		0x00400		/* resolve symbols within */
    160 						/*	members of the group */
    161 #define	RTLD_WORLD		0x00800		/* resolve symbols within */
    162 						/*	global objects */
    163 #define	RTLD_NODELETE		0x01000		/* do not remove members */
    164 #define	RTLD_FIRST		0x02000		/* only first object is */
    165 						/*	available for dlsym */
    166 #define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
    167 						/*	internal use only */
    168 
    169 /*
    170  * Valid values for flag argument to dldump.
    171  */
    172 #define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
    173 #define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
    174 						/*	bind to main */
    175 #define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
    176 						/*	bind to dependencies */
    177 #define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
    178 						/*	bind to preload objs */
    179 #define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
    180 						/*	bind to ourself */
    181 #define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
    182 						/*	even if unresolved */
    183 #define	RTLD_REL_ALL		0x00fff 	/* apply all relocs */
    184 
    185 #define	RTLD_MEMORY		0x01000		/* use memory sections */
    186 #define	RTLD_STRIP		0x02000		/* retain allocable sections */
    187 						/*	only */
    188 #define	RTLD_NOHEAP		0x04000		/* do no save any heap */
    189 #define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
    190 						/*	internal use only */
    191 
    192 /*
    193  * Valid values for dladdr1() flags.
    194  */
    195 #define	RTLD_DL_SYMENT		1		/* return symbol table entry */
    196 #define	RTLD_DL_LINKMAP		2		/* return public link-map */
    197 #define	RTLD_DL_MASK		0xffff
    198 
    199 
    200 /*
    201  * Arguments for dlinfo()
    202  */
    203 #define	RTLD_DI_LMID		1		/* obtain link-map id */
    204 #define	RTLD_DI_LINKMAP		2		/* obtain link-map */
    205 #define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
    206 #define	RTLD_DI_SERINFO		4		/* obtain search path info or */
    207 #define	RTLD_DI_SERINFOSIZE	5		/*	associated info size */
    208 #define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
    209 #define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
    210 						/*	internal use only */
    211 #define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
    212 						/*	internal use only */
    213 #define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
    214 #define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
    215 #define	RTLD_DI_ARGSINFO	11		/* get process arguments */
    216 						/*	environment and auxv */
    217 #define	RTLD_DI_MAX		11
    218 
    219 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
    220 /*
    221  * Version information for Dl_amd64_unwindinfo.dlui_version
    222  */
    223 #define	DLUI_VERS_1		1
    224 #define	DLUI_VERS_CURRENT	DLUI_VERS_1
    225 
    226 /*
    227  * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
    228  */
    229 #define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
    230 #define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
    231 						/*  matching the pc provided */
    232 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
    233 
    234 #ifdef	__cplusplus
    235 }
    236 #endif
    237 
    238 #endif	/* _DLFCN_H */
    239