00001 /*- 00002 * Portions Copyright (c) 2006 Nokia Corporation 00003 * All Rights Reserved. 00004 * 00005 * Copyright (c) 1994 00006 * The Regents of the University of California. All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. All advertising materials mentioning features or use of this software 00017 * must display the following acknowledgement: 00018 * This product includes software developed by the University of 00019 * California, Berkeley and its contributors. 00020 * 4. Neither the name of the University nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00025 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00027 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00030 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00031 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00033 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00034 * SUCH DAMAGE. 00035 * 00036 * $FreeBSD: src/include/dlfcn.h,v 1.19 2003/02/13 17:47:43 kan Exp $ 00037 */ 00038 00039 #ifndef _DLFCN_H_ 00040 #define _DLFCN_H_ 00041 00042 #include <sys/_types.h> 00043 00044 /* 00045 * Modes and flags for dlopen(). 00046 */ 00047 #define RTLD_LAZY 1 /* Bind function calls lazily. */ 00048 #define RTLD_NOW 2 /* Bind function calls immediately. */ 00049 #define RTLD_MODEMASK 0x3 00050 #define RTLD_GLOBAL 0x100 /* Make symbols globally available. */ 00051 #define RTLD_LOCAL 0 /* Opposite of RTLD_GLOBAL, and the default. */ 00052 #define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */ 00053 00054 /* 00055 * Request arguments for dlinfo(). 00056 */ 00057 #define RTLD_DI_LINKMAP 2 /* Obtain link map. */ 00058 #define RTLD_DI_SERINFO 4 /* Obtain search path info. */ 00059 #define RTLD_DI_SERINFOSIZE 5 /* ... query for required space. */ 00060 #define RTLD_DI_ORIGIN 6 /* Obtain object origin */ 00061 #define RTLD_DI_MAX RTLD_DI_ORIGIN 00062 00063 /* 00064 * Special handle arguments for dlsym()/dlinfo(). 00065 */ 00066 #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ 00067 #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ 00068 #define RTLD_SELF ((void *) -3) /* Search the caller itself. */ 00069 00070 #if __BSD_VISIBLE 00071 00072 #ifndef _SIZE_T_DECLARED 00073 typedef __size_t size_t; 00074 #define _SIZE_T_DECLARED 00075 #endif 00076 00077 /* 00078 * Structure filled in by dladdr(). 00079 */ 00080 typedef struct dl_info { 00081 const char *dli_fname; /* Pathname of shared object. */ 00082 void *dli_fbase; /* Base address of shared object. */ 00083 const char *dli_sname; /* Name of nearest symbol. */ 00084 void *dli_saddr; /* Address of nearest symbol. */ 00085 } Dl_info; 00086 00087 /*- 00088 * The actual type declared by this typedef is immaterial, provided that 00089 * it is a function pointer. Its purpose is to provide a return type for 00090 * dlfunc() which can be cast to a function pointer type without depending 00091 * on behavior undefined by the C standard, which might trigger a compiler 00092 * diagnostic. We intentionally declare a unique type signature to force 00093 * a diagnostic should the application not cast the return value of dlfunc() 00094 * appropriately. 00095 */ 00096 struct __dlfunc_arg { 00097 int __dlfunc_dummy; 00098 }; 00099 00100 typedef void (*dlfunc_t)(struct __dlfunc_arg); 00101 00102 /* 00103 * Structures, returned by the RTLD_DI_SERINFO dlinfo() request. 00104 */ 00105 typedef struct dl_serpath { 00106 char * dls_name; /* single search path entry */ 00107 unsigned int dls_flags; /* path information */ 00108 } Dl_serpath; 00109 00110 typedef struct dl_serinfo { 00111 size_t dls_size; /* total buffer size */ 00112 unsigned int dls_cnt; /* number of path entries */ 00113 Dl_serpath dls_serpath[1]; /* there may be more than one */ 00114 } Dl_serinfo; 00115 00116 #endif /* __BSD_VISIBLE */ 00117 00118 __BEGIN_DECLS 00119 /* XSI functions first. */ 00120 00121 IMPORT_C void *dlopen(const char *filename, int flag); 00122 00123 IMPORT_C void *dlsym(void *handle, const char *symbol); 00124 00125 IMPORT_C char *dlerror(void); 00126 00127 IMPORT_C int dlclose(void *handle); 00128 00129 __END_DECLS 00130 00131 #endif /* !_DLFCN_H_ */