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