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 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 /* 44 * Information structure for libpath dlinfo() and dlamd64getunwind() request. 45 */ 46 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 47 #ifdef __STDC__ 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 #else 55 typedef struct dl_info { 56 char *dli_fname; 57 void *dli_fbase; 58 char *dli_sname; 59 void *dli_saddr; 60 } Dl_info; 61 #endif /* __STDC__ */ 62 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 63 64 65 /* 66 * Information structure for libpath dlinfo() request. 67 */ 68 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 69 typedef struct dl_serpath { 70 char *dls_name; /* library search path name */ 71 uint_t dls_flags; /* path information */ 72 } Dl_serpath; 73 74 typedef struct dl_serinfo { 75 size_t dls_size; /* total buffer size */ 76 uint_t dls_cnt; /* number of path entries */ 77 Dl_serpath dls_serpath[1]; /* there may be more than one */ 78 } Dl_serinfo; 79 80 typedef struct { 81 uint_t dlui_version; /* version # */ 82 uint_t dlui_flags; /* flags */ 83 char *dlui_objname; /* path to object */ 84 void *dlui_unwindstart; /* star of unwind hdr */ 85 void *dlui_unwindend; /* end of unwind hdr */ 86 void *dlui_segstart; /* start of segment described */ 87 /* by unwind block */ 88 void *dlui_segend; /* end of segment described */ 89 /* by unwind block */ 90 } Dl_amd64_unwindinfo; 91 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 92 93 94 typedef ulong_t Lmid_t; 95 96 /* 97 * Declarations used for dynamic linking support routines. 98 */ 99 #ifdef __STDC__ 100 extern void *dlopen(const char *, int); 101 extern void *dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); 102 extern int dlclose(void *); 103 extern char *dlerror(void); 104 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 105 extern void *dlmopen(Lmid_t, const char *, int); 106 extern int dladdr(void *, Dl_info *); 107 extern int dladdr1(void *, Dl_info *, void **, int); 108 extern int dldump(const char *, const char *, int); 109 extern int dlinfo(void *, int, void *); 110 extern Dl_amd64_unwindinfo *dlamd64getunwind(void *, Dl_amd64_unwindinfo *); 111 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 112 #else 113 extern void *dlopen(); 114 extern void *dlsym(); 115 extern int dlclose(); 116 extern char *dlerror(); 117 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 118 extern void *dlmopen(); 119 extern int dladdr(); 120 extern int dladdr1(); 121 extern int dldump(); 122 extern int dlinfo(); 123 extern Dl_amd64_unwindinfo *dlamd64getunwind(); 124 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 125 #endif /* __STDC__ */ 126 127 #pragma unknown_control_flow(dlopen, dlsym, dlclose, dlerror) 128 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 129 #pragma unknown_control_flow(dlmopen, dladdr, dladdr1, dldump, dlinfo) 130 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 131 132 /* 133 * Valid values for handle argument to dlsym(3x). 134 */ 135 #define RTLD_NEXT (void *)-1 /* look in `next' dependency */ 136 #define RTLD_DEFAULT (void *)-2 /* look up symbol from scope */ 137 /* of current object */ 138 #define RTLD_SELF (void *)-3 /* look in `ourself' */ 139 #define RTLD_PROBE (void *)-4 /* look up symbol from scope */ 140 /* of current object, */ 141 /* using currently */ 142 /* loaded objects only. */ 143 /* 144 * Valid values for mode argument to dlopen. 145 */ 146 #define RTLD_LAZY 0x00001 /* deferred function binding */ 147 #define RTLD_NOW 0x00002 /* immediate function binding */ 148 #define RTLD_NOLOAD 0x00004 /* don't load object */ 149 150 #define RTLD_GLOBAL 0x00100 /* export symbols to others */ 151 #define RTLD_LOCAL 0x00000 /* symbols are only available */ 152 /* to group members */ 153 #define RTLD_PARENT 0x00200 /* add parent (caller) to */ 154 /* a group dependencies */ 155 #define RTLD_GROUP 0x00400 /* resolve symbols within */ 156 /* members of the group */ 157 #define RTLD_WORLD 0x00800 /* resolve symbols within */ 158 /* global objects */ 159 #define RTLD_NODELETE 0x01000 /* do not remove members */ 160 #define RTLD_FIRST 0x02000 /* only first object is */ 161 /* available for dlsym */ 162 #define RTLD_CONFGEN 0x10000 /* crle(1) config generation */ 163 /* internal use only */ 164 165 /* 166 * Valid values for flag argument to dldump. 167 */ 168 #define RTLD_REL_RELATIVE 0x00001 /* apply relative relocs */ 169 #define RTLD_REL_EXEC 0x00002 /* apply symbolic relocs that */ 170 /* bind to main */ 171 #define RTLD_REL_DEPENDS 0x00004 /* apply symbolic relocs that */ 172 /* bind to dependencies */ 173 #define RTLD_REL_PRELOAD 0x00008 /* apply symbolic relocs that */ 174 /* bind to preload objs */ 175 #define RTLD_REL_SELF 0x00010 /* apply symbolic relocs that */ 176 /* bind to ourself */ 177 #define RTLD_REL_WEAK 0x00020 /* apply symbolic weak relocs */ 178 /* even if unresolved */ 179 #define RTLD_REL_ALL 0x00fff /* apply all relocs */ 180 181 #define RTLD_MEMORY 0x01000 /* use memory sections */ 182 #define RTLD_STRIP 0x02000 /* retain allocable sections */ 183 /* only */ 184 #define RTLD_NOHEAP 0x04000 /* do no save any heap */ 185 #define RTLD_CONFSET 0x10000 /* crle(1) config generation */ 186 /* internal use only */ 187 188 /* 189 * Valid values for dladdr1() flags. 190 */ 191 #define RTLD_DL_SYMENT 1 /* return symbol table entry */ 192 #define RTLD_DL_LINKMAP 2 /* return public link-map */ 193 #define RTLD_DL_MASK 0xffff 194 195 196 /* 197 * Arguments for dlinfo() 198 */ 199 #define RTLD_DI_LMID 1 /* obtain link-map id */ 200 #define RTLD_DI_LINKMAP 2 /* obtain link-map */ 201 #define RTLD_DI_CONFIGADDR 3 /* obtain config addr */ 202 #define RTLD_DI_SERINFO 4 /* obtain search path info or */ 203 #define RTLD_DI_SERINFOSIZE 5 /* associated info size */ 204 #define RTLD_DI_ORIGIN 6 /* obtain objects origin */ 205 #define RTLD_DI_PROFILENAME 7 /* obtain profile object name */ 206 /* internal use only */ 207 #define RTLD_DI_PROFILEOUT 8 /* obtain profile output name */ 208 /* internal use only */ 209 #define RTLD_DI_GETSIGNAL 9 /* get termination signal */ 210 #define RTLD_DI_SETSIGNAL 10 /* set termination signal */ 211 #define RTLD_DI_MAX 10 212 213 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 214 /* 215 * Version information for Dl_amd64_unwindinfo.dlui_version 216 */ 217 #define DLUI_VERS_1 1 218 #define DLUI_VERS_CURRENT DLUI_VERS_1 219 220 /* 221 * Valid flags for Dl_amd64_unwindinfo.dlfi_flags 222 */ 223 #define DLUI_FLG_NOUNWIND 0x0001 /* object has no Unwind info */ 224 #define DLUI_FLG_NOOBJ 0x0002 /* no object was found */ 225 /* matching the pc provided */ 226 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 227 228 #ifdef __cplusplus 229 } 230 #endif 231 232 #endif /* _DLFCN_H */ 233