|
1 /*- |
|
2 * Portions Copyright (c) 2006 Nokia Corporation |
|
3 * All Rights Reserved. |
|
4 * |
|
5 * Copyright (c) 1994 |
|
6 * The Regents of the University of California. All rights reserved. |
|
7 * |
|
8 * Redistribution and use in source and binary forms, with or without |
|
9 * modification, are permitted provided that the following conditions |
|
10 * are met: |
|
11 * 1. Redistributions of source code must retain the above copyright |
|
12 * notice, this list of conditions and the following disclaimer. |
|
13 * 2. Redistributions in binary form must reproduce the above copyright |
|
14 * notice, this list of conditions and the following disclaimer in the |
|
15 * documentation and/or other materials provided with the distribution. |
|
16 * 4. Neither the name of the University nor the names of its contributors |
|
17 * may be used to endorse or promote products derived from this software |
|
18 * without specific prior written permission. |
|
19 * |
|
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
|
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
30 * SUCH DAMAGE. |
|
31 * |
|
32 * $FreeBSD: src/include/dlfcn.h,v 1.19 2003/02/13 17:47:43 kan Exp $ |
|
33 */ |
|
34 |
|
35 #ifndef _DLFCN_H_ |
|
36 #define _DLFCN_H_ |
|
37 |
|
38 #include <sys/_types.h> |
|
39 |
|
40 /* |
|
41 * Modes and flags for dlopen(). |
|
42 */ |
|
43 #define RTLD_LAZY 1 /* Bind function calls lazily. */ |
|
44 #define RTLD_NOW 2 /* Bind function calls immediately. */ |
|
45 #define RTLD_MODEMASK 0x3 |
|
46 #define RTLD_GLOBAL 0x100 /* Make symbols globally available. */ |
|
47 #define RTLD_LOCAL 0 /* Opposite of RTLD_GLOBAL, and the default. */ |
|
48 #define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */ |
|
49 |
|
50 /* |
|
51 * Request arguments for dlinfo(). |
|
52 */ |
|
53 #define RTLD_DI_LINKMAP 2 /* Obtain link map. */ |
|
54 #define RTLD_DI_SERINFO 4 /* Obtain search path info. */ |
|
55 #define RTLD_DI_SERINFOSIZE 5 /* ... query for required space. */ |
|
56 #define RTLD_DI_ORIGIN 6 /* Obtain object origin */ |
|
57 #define RTLD_DI_MAX RTLD_DI_ORIGIN |
|
58 |
|
59 /* |
|
60 * Special handle arguments for dlsym()/dlinfo(). |
|
61 */ |
|
62 #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ |
|
63 #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ |
|
64 #define RTLD_SELF ((void *) -3) /* Search the caller itself. */ |
|
65 |
|
66 #if __BSD_VISIBLE |
|
67 |
|
68 #ifndef _SIZE_T_DECLARED |
|
69 typedef __size_t size_t; |
|
70 #define _SIZE_T_DECLARED |
|
71 #endif |
|
72 |
|
73 /* |
|
74 * Structure filled in by dladdr(). |
|
75 */ |
|
76 typedef struct dl_info { |
|
77 const char *dli_fname; /* Pathname of shared object. */ |
|
78 void *dli_fbase; /* Base address of shared object. */ |
|
79 const char *dli_sname; /* Name of nearest symbol. */ |
|
80 void *dli_saddr; /* Address of nearest symbol. */ |
|
81 } Dl_info; |
|
82 |
|
83 /*- |
|
84 * The actual type declared by this typedef is immaterial, provided that |
|
85 * it is a function pointer. Its purpose is to provide a return type for |
|
86 * dlfunc() which can be cast to a function pointer type without depending |
|
87 * on behavior undefined by the C standard, which might trigger a compiler |
|
88 * diagnostic. We intentionally declare a unique type signature to force |
|
89 * a diagnostic should the application not cast the return value of dlfunc() |
|
90 * appropriately. |
|
91 */ |
|
92 struct __dlfunc_arg { |
|
93 int __dlfunc_dummy; |
|
94 }; |
|
95 |
|
96 typedef void (*dlfunc_t)(struct __dlfunc_arg); |
|
97 |
|
98 /* |
|
99 * Structures, returned by the RTLD_DI_SERINFO dlinfo() request. |
|
100 */ |
|
101 typedef struct dl_serpath { |
|
102 char * dls_name; /* single search path entry */ |
|
103 unsigned int dls_flags; /* path information */ |
|
104 } Dl_serpath; |
|
105 |
|
106 typedef struct dl_serinfo { |
|
107 size_t dls_size; /* total buffer size */ |
|
108 unsigned int dls_cnt; /* number of path entries */ |
|
109 Dl_serpath dls_serpath[1]; /* there may be more than one */ |
|
110 } Dl_serinfo; |
|
111 |
|
112 #endif /* __BSD_VISIBLE */ |
|
113 |
|
114 __BEGIN_DECLS |
|
115 /* XSI functions first. */ |
|
116 |
|
117 IMPORT_C void *dlopen(const char *filename, int flag); |
|
118 |
|
119 IMPORT_C void *dlsym(void *handle, const char *symbol); |
|
120 |
|
121 IMPORT_C char *dlerror(void); |
|
122 |
|
123 IMPORT_C int dlclose(void *handle); |
|
124 |
|
125 __END_DECLS |
|
126 |
|
127 #endif /* !_DLFCN_H_ */ |