2334
|
1 Copyright (c) 1992,1993,1995,1996, Jens-Uwe Mager, Helios Software GmbH |
|
2 Not derived from licensed software. |
|
3 |
|
4 Permission is granted to freely use, copy, modify, and redistribute |
|
5 this software, provided that the author is not construed to be liable |
|
6 for any results of using the software, alterations are clearly marked |
|
7 as such, and this notice is not modified. |
|
8 |
|
9 libdl.a |
|
10 ------- |
|
11 |
|
12 This is an emulation library to emulate the SunOS/System V.4 functions |
|
13 to access the runtime linker. The functions are emulated by using the |
|
14 AIX load() function and by reading the .loader section of the loaded |
|
15 module to find the exports. The to be loaded module should be linked as |
|
16 follows (if using AIX 3): |
|
17 |
|
18 cc -o module.so -bM:SRE -bE:module.exp -e _nostart $(OBJS) |
|
19 |
|
20 For AIX 4: |
|
21 |
|
22 cc -o module.so -bM:SRE -bE:module.exp -bnoentry $(OBJS) |
|
23 |
|
24 The module export file contains the symbols to be exported. Because |
|
25 this library uses the loader section, the final module.so file can be |
|
26 stripped. C++ users should build their shared objects using the script |
|
27 makeC++SharedLib (part of the IBM C++ compiler), this will make sure |
|
28 that constructors and destructors for static and global objects will be |
|
29 called upon loading and unloading the module. |
|
30 |
|
31 Usage |
|
32 ----- |
|
33 |
|
34 void *dlopen(const char *path, int mode); |
|
35 |
|
36 This routine loads the module pointed to by path and reads its export |
|
37 table. If the path does not contain a '/' character, dlopen will search |
|
38 for the module using the LIBPATH environment variable. It returns an |
|
39 opaque handle to the module or NULL on error. The mode parameter can be |
|
40 either RTLD_LAZY (for lazy function binding) or RTLD_NOW for immediate |
|
41 function binding. The AIX implementation currently does treat RTLD_NOW |
|
42 the same as RTLD_LAZY. The flag RTLD_GLOBAL might be or'ed into the |
|
43 mode parameter to allow loaded modules to bind to global variables or |
|
44 functions in other loaded modules loaded by dlopen(). If RTLD_GLOBAL is |
|
45 not specified, only globals from the main part of the executable or |
|
46 shared libraries are used to look for undefined symbols in loaded |
|
47 modules. |
|
48 |
|
49 |
|
50 void *dlsym(void *handle, const char *symbol); |
|
51 |
|
52 This routine searches for the symbol in the module referred to by |
|
53 handle and returns its address. If the symbol could not be found, the |
|
54 function returns NULL. The return value must be casted to a proper |
|
55 function pointer before it can be used. SunOS/System V.4 allows handle |
|
56 to be a NULL pointer to refer to the module the call is made from, this |
|
57 is not implemented. |
|
58 |
|
59 int dlclose(void *handle); |
|
60 |
|
61 This routine unloads the module referred to by the handle and disposes |
|
62 of any local storage. this function returns -1 on failure. |
|
63 |
|
64 char *dlerror(void); |
|
65 |
|
66 This routine can be used to retrieve a text message describing the most |
|
67 recent error that occured on on of the above routines. This function |
|
68 returns NULL if there is no error information. |
|
69 |
|
70 Initialization and termination handlers |
|
71 --------------------------------------- |
|
72 |
|
73 The emulation provides for an initialization and a termination |
|
74 handler. The dlfcn.h file contains a structure declaration named |
|
75 dl_info with following members: |
|
76 |
|
77 void (*init)(void); |
|
78 void (*fini)(void); |
|
79 |
|
80 The init function is called upon first referencing the library. The |
|
81 fini function is called at dlclose() time or when the process exits. |
|
82 The module should declare a variable named dl_info that contains this |
|
83 structure which must be exported. These functions correspond to the |
|
84 documented _init() and _fini() functions of SunOS 4.x, but these are |
|
85 appearently not implemented in SunOS. When using SunOS 5.0, these |
|
86 correspond to #pragma init and #pragma fini respectively. At the same |
|
87 time any static or global C++ object's constructors or destructors will |
|
88 be called. |
|
89 |
|
90 BUGS |
|
91 ---- |
|
92 |
|
93 Please note that there is currently a problem with implicitely loaded |
|
94 shared C++ libaries: if you refer to a shared C++ library from a loaded |
|
95 module that is not yet used by the main program, the dlopen() emulator |
|
96 does not notice this and does not call the static constructors for the |
|
97 implicitely loaded library. This can be easily demonstrated by |
|
98 referencing the C++ standard streams from a loaded module if the main |
|
99 program is a plain C program. |
|
100 |
|
101 Jens-Uwe Mager |
|
102 |
|
103 HELIOS Software GmbH |
|
104 Lavesstr. 80 |
|
105 30159 Hannover |
|
106 Germany |
|
107 |
|
108 Phone: +49 511 36482-0 |
|
109 FAX: +49 511 36482-69 |
|
110 AppleLink: helios.de/jum |
|
111 Internet: jum@helios.de |
|
112 |
|
113 Revison History |
|
114 --------------- |
|
115 |
|
116 SCCS/s.dlfcn.h: |
|
117 |
|
118 D 1.4 95/04/25 09:36:52 jum 4 3 00018/00004/00028 |
|
119 MRs: |
|
120 COMMENTS: |
|
121 added RTLD_GLOBAL, include and C++ guards |
|
122 |
|
123 D 1.3 92/12/27 20:58:32 jum 3 2 00001/00001/00031 |
|
124 MRs: |
|
125 COMMENTS: |
|
126 we always have prototypes on RS/6000 |
|
127 |
|
128 D 1.2 92/08/16 17:45:11 jum 2 1 00009/00000/00023 |
|
129 MRs: |
|
130 COMMENTS: |
|
131 added dl_info structure to implement initialize and terminate functions |
|
132 |
|
133 D 1.1 92/08/02 18:08:45 jum 1 0 00023/00000/00000 |
|
134 MRs: |
|
135 COMMENTS: |
|
136 Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum |
|
137 |
|
138 SCCS/s.dlfcn.c: |
|
139 |
|
140 D 1.10 96/02/15 17:42:44 jum 12 10 00012/00007/00521 |
|
141 MRs: |
|
142 COMMENTS: |
|
143 the C++ constructor and destructor chains are now called properly for either |
|
144 xlC 2 or xlC 3 (CSet++). |
|
145 |
|
146 D 1.9 95/09/22 11:09:38 markus 10 9 00001/00008/00527 |
|
147 MRs: |
|
148 COMMENTS: |
|
149 Fix version number |
|
150 |
|
151 D 1.8 95/09/22 10:14:34 markus 9 8 00008/00001/00527 |
|
152 MRs: |
|
153 COMMENTS: |
|
154 Added version number for dl lib |
|
155 |
|
156 D 1.7 95/08/14 19:08:38 jum 8 6 00026/00004/00502 |
|
157 MRs: |
|
158 COMMENTS: |
|
159 Integrated the fixes from Kirk Benell (kirk@rsinc.com) to allow loading of |
|
160 shared objects generated under AIX 4. Fixed bug that symbols with exactly |
|
161 8 characters would use garbage characters from the following symbol value. |
|
162 |
|
163 D 1.6 95/04/25 09:38:03 jum 6 5 00046/00006/00460 |
|
164 MRs: |
|
165 COMMENTS: |
|
166 added handling of C++ static constructors and destructors, added RTLD_GLOBAL to bind against other loaded modules |
|
167 |
|
168 D 1.5 93/02/14 20:14:17 jum 5 4 00002/00000/00464 |
|
169 MRs: |
|
170 COMMENTS: |
|
171 added path to dlopen error message to make clear where there error occured. |
|
172 |
|
173 D 1.4 93/01/03 19:13:56 jum 4 3 00061/00005/00403 |
|
174 MRs: |
|
175 COMMENTS: |
|
176 to allow calling symbols in the main module call load with L_NOAUTODEFER and |
|
177 do a loadbind later with the main module. |
|
178 |
|
179 D 1.3 92/12/27 20:59:55 jum 3 2 00066/00008/00342 |
|
180 MRs: |
|
181 COMMENTS: |
|
182 added search by L_GETINFO if module got loaded by LIBPATH |
|
183 |
|
184 D 1.2 92/08/16 17:45:43 jum 2 1 00074/00006/00276 |
|
185 MRs: |
|
186 COMMENTS: |
|
187 implemented initialize and terminate functions, added reference counting to avoid multiple loads of the same library |
|
188 |
|
189 D 1.1 92/08/02 18:08:45 jum 1 0 00282/00000/00000 |
|
190 MRs: |
|
191 COMMENTS: |
|
192 Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum |