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