blob: f150e90bc3bf88bee2b64f01d4de209ca614f9fe [file] [log] [blame]
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07001/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
Rod Evans959ee942009-02-05 11:31:08 -08005 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07007 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21/*
Garrett D'Amoreba3594b2014-08-02 18:23:32 -070022 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
Rod Evansf4417712010-05-19 22:33:49 -070023 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070024 *
25 * Copyright (c) 1989 AT&T
26 * All Rights Reserved
27 *
28 */
29
30#ifndef _DLFCN_H
31#define _DLFCN_H
32
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070033#include <sys/feature_tests.h>
34#include <sys/types.h>
rie80b8e1d2005-07-21 08:29:07 -070035#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
rie41072f32005-06-15 08:20:19 -070036#include <sys/auxv.h>
Rod Evans959ee942009-02-05 11:31:08 -080037#include <sys/mman.h>
rie80b8e1d2005-07-21 08:29:07 -070038#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070039
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/*
rie41072f32005-06-15 08:20:19 -070045 * Information structures for various dlinfo() requests.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070046 */
47#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070048typedef 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;
Rod Evans959ee942009-02-05 11:31:08 -080054typedef Dl_info Dl_info_t;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070055
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070056typedef struct dl_serpath {
57 char *dls_name; /* library search path name */
58 uint_t dls_flags; /* path information */
59} Dl_serpath;
Rod Evans959ee942009-02-05 11:31:08 -080060typedef Dl_serpath Dl_serpath_t;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070061
62typedef 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;
Rod Evans959ee942009-02-05 11:31:08 -080067typedef Dl_serinfo Dl_serinfo_t;
rie41072f32005-06-15 08:20:19 -070068
69typedef 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;
Rod Evans959ee942009-02-05 11:31:08 -080075typedef Dl_argsinfo Dl_argsinfo_t;
76
77typedef struct {
78 mmapobj_result_t *dlm_maps; /* mapping information */
79 uint_t dlm_acnt; /* number of dlm_maps mappings */
80 uint_t dlm_rcnt; /* number of returned mappings */
81} Dl_mapinfo_t;
82
83typedef struct {
84 uint_t dlui_version; /* version # */
85 uint_t dlui_flags; /* flags */
86 char *dlui_objname; /* path to object */
87 void *dlui_unwindstart; /* star of unwind hdr */
88 void *dlui_unwindend; /* end of unwind hdr */
89 void *dlui_segstart; /* start of segment described */
90 /* by unwind block */
91 void *dlui_segend; /* end of segment described */
92 /* by unwind block */
93} Dl_amd64_unwindinfo;
94typedef Dl_amd64_unwindinfo Dl_amd64_unwindinfo_t;
95
Rod Evansf4417712010-05-19 22:33:49 -070096typedef struct {
97 const char *dld_refname; /* reference name */
98 const char *dld_depname; /* new dependency name */
99} Dl_definfo_t;
100
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700101#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
102
103
104typedef ulong_t Lmid_t;
105
106/*
107 * Declarations used for dynamic linking support routines.
108 */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700109extern void *dlopen(const char *, int);
Marcel Telka6e270ca2017-07-02 04:55:09 +0200110extern void *dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700111extern int dlclose(void *);
112extern char *dlerror(void);
113#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
114extern void *dlmopen(Lmid_t, const char *, int);
115extern int dladdr(void *, Dl_info *);
116extern int dladdr1(void *, Dl_info *, void **, int);
117extern int dldump(const char *, const char *, int);
118extern int dlinfo(void *, int, void *);
119extern Dl_amd64_unwindinfo *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
120#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700121
122#pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror)
123#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
124#pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo)
125#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
126
127/*
128 * Valid values for handle argument to dlsym(3x).
129 */
130#define RTLD_NEXT (void *)-1 /* look in `next' dependency */
131#define RTLD_DEFAULT (void *)-2 /* look up symbol from scope */
132 /* of current object */
133#define RTLD_SELF (void *)-3 /* look in `ourself' */
134#define RTLD_PROBE (void *)-4 /* look up symbol from scope */
135 /* of current object, */
136 /* using currently */
137 /* loaded objects only. */
138/*
139 * Valid values for mode argument to dlopen.
140 */
141#define RTLD_LAZY 0x00001 /* deferred function binding */
142#define RTLD_NOW 0x00002 /* immediate function binding */
143#define RTLD_NOLOAD 0x00004 /* don't load object */
144
145#define RTLD_GLOBAL 0x00100 /* export symbols to others */
146#define RTLD_LOCAL 0x00000 /* symbols are only available */
147 /* to group members */
148#define RTLD_PARENT 0x00200 /* add parent (caller) to */
149 /* a group dependencies */
150#define RTLD_GROUP 0x00400 /* resolve symbols within */
151 /* members of the group */
152#define RTLD_WORLD 0x00800 /* resolve symbols within */
153 /* global objects */
154#define RTLD_NODELETE 0x01000 /* do not remove members */
155#define RTLD_FIRST 0x02000 /* only first object is */
156 /* available for dlsym */
157#define RTLD_CONFGEN 0x10000 /* crle(1) config generation */
158 /* internal use only */
159
160/*
161 * Valid values for flag argument to dldump.
162 */
163#define RTLD_REL_RELATIVE 0x00001 /* apply relative relocs */
164#define RTLD_REL_EXEC 0x00002 /* apply symbolic relocs that */
165 /* bind to main */
166#define RTLD_REL_DEPENDS 0x00004 /* apply symbolic relocs that */
167 /* bind to dependencies */
168#define RTLD_REL_PRELOAD 0x00008 /* apply symbolic relocs that */
169 /* bind to preload objs */
170#define RTLD_REL_SELF 0x00010 /* apply symbolic relocs that */
171 /* bind to ourself */
172#define RTLD_REL_WEAK 0x00020 /* apply symbolic weak relocs */
173 /* even if unresolved */
Marcel Telka6e270ca2017-07-02 04:55:09 +0200174#define RTLD_REL_ALL 0x00fff /* apply all relocs */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700175
176#define RTLD_MEMORY 0x01000 /* use memory sections */
177#define RTLD_STRIP 0x02000 /* retain allocable sections */
178 /* only */
179#define RTLD_NOHEAP 0x04000 /* do no save any heap */
180#define RTLD_CONFSET 0x10000 /* crle(1) config generation */
181 /* internal use only */
182
183/*
184 * Valid values for dladdr1() flags.
185 */
186#define RTLD_DL_SYMENT 1 /* return symbol table entry */
187#define RTLD_DL_LINKMAP 2 /* return public link-map */
188#define RTLD_DL_MASK 0xffff
189
190
191/*
192 * Arguments for dlinfo()
193 */
194#define RTLD_DI_LMID 1 /* obtain link-map id */
195#define RTLD_DI_LINKMAP 2 /* obtain link-map */
196#define RTLD_DI_CONFIGADDR 3 /* obtain config addr */
197#define RTLD_DI_SERINFO 4 /* obtain search path info or */
Rod Evansf4417712010-05-19 22:33:49 -0700198#define RTLD_DI_SERINFOSIZE 5 /* associated info size */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700199#define RTLD_DI_ORIGIN 6 /* obtain objects origin */
200#define RTLD_DI_PROFILENAME 7 /* obtain profile object name */
Rod Evansf4417712010-05-19 22:33:49 -0700201 /* internal use only */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700202#define RTLD_DI_PROFILEOUT 8 /* obtain profile output name */
Rod Evansf4417712010-05-19 22:33:49 -0700203 /* internal use only */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700204#define RTLD_DI_GETSIGNAL 9 /* get termination signal */
205#define RTLD_DI_SETSIGNAL 10 /* set termination signal */
rie41072f32005-06-15 08:20:19 -0700206#define RTLD_DI_ARGSINFO 11 /* get process arguments */
Rod Evansf4417712010-05-19 22:33:49 -0700207 /* environment and auxv */
Rod Evans959ee942009-02-05 11:31:08 -0800208#define RTLD_DI_MMAPS 12 /* obtain objects mappings or */
Rod Evansf4417712010-05-19 22:33:49 -0700209#define RTLD_DI_MMAPCNT 13 /* mapping count */
210#define RTLD_DI_DEFERRED 14 /* assign new dependency to a */
211 /* deferred dependency */
212#define RTLD_DI_DEFERRED_SYM 15 /* assign new dependency to a */
213 /* deferred dependency */
214 /* using a symbol name */
215#define RTLD_DI_MAX 15
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700216
217#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
218/*
219 * Version information for Dl_amd64_unwindinfo.dlui_version
220 */
221#define DLUI_VERS_1 1
222#define DLUI_VERS_CURRENT DLUI_VERS_1
223
224/*
225 * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
226 */
227#define DLUI_FLG_NOUNWIND 0x0001 /* object has no Unwind info */
228#define DLUI_FLG_NOOBJ 0x0002 /* no object was found */
229 /* matching the pc provided */
230#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
231
232#ifdef __cplusplus
233}
234#endif
235
236#endif /* _DLFCN_H */