1
Copyright (c) 1992,1993,1995, Jens-Uwe Mager, Helios Software GmbH
2
Not derived from licensed software.
4
Permission is granted to freely use, copy, modify, and redistribute
5
this software, provided that no attempt is made to gain profit from it,
6
the author is not construed to be liable for any results of using the
7
software, alterations are clearly marked as such, and this notice is
13
This is an emulation library to emulate the SunOS/System V.4 functions
14
to access the runtime linker. The functions are emulated by using the
15
AIX load() function and by reading the .loader section of the loaded
16
module to find the exports. The to be loaded module should be linked as
17
follows (if using AIX 3):
19
cc -o module.so -bM:SRE -bE:module.exp -e _nostart $(OBJS)
23
cc -o module.so -bM:SRE -bE:module.exp -bnoentry $(OBJS)
25
The module export file contains the symbols to be exported. Because
26
this library uses the loader section, the final module.so file can be
27
stripped. C++ users should build their shared objects using the script
28
makeC++SharedLib (part of the IBM C++ compiler), this will make sure
29
that constructors and destructors for static and global objects will be
30
called upon loading and unloading the module.
35
void *dlopen(const char *path, int mode);
37
This routine loads the module pointed to by path and reads its export
38
table. If the path does not contain a '/' character, dlopen will search
39
for the module using the LIBPATH environment variable. It returns an
40
opaque handle to the module or NULL on error. The mode parameter can be
41
either RTLD_LAZY (for lazy function binding) or RTLD_NOW for immediate
42
function binding. The AIX implementation currently behaves as RTLD_NOW
43
even if RTLD_LAZY is specified. The flag RTLD_GLOBAL might be or'ed into the
44
mode parameter to allow loaded modules to bind to global variables or
45
functions in other loaded modules loaded by dlopen(). If RTLD_GLOBAL is
46
not specified, only globals from the main part of the executable or
47
shared libraries are used to look for undefined symbols in loaded
51
void *dlsym(void *handle, const char *symbol);
53
This routine searches for the symbol in the module referred to by
54
handle and returns its address. If the symbol could not be found, the
55
function returns NULL. The return value must be casted to a proper
56
function pointer before it can be used. SunOS/System V.4 allow handle
57
to be a NULL pointer to refer to the module the call is made from, this
60
int dlclose(void *handle);
62
This routine unloads the module referred to by the handle and disposes
63
of any local storage. this function returns -1 on failure.
67
This routine can be used to retrieve a text message describing the most
68
recent error that occured on on of the above routines. This function
69
returns NULL if there is not error information.
71
Initialization and termination handlers
72
---------------------------------------
74
The emulation provides for an initialization and a termination
75
handler. The dlfcn.h file contains a structure declaration named
76
dl_info with following members:
81
The init function is called upon first referencing the library. The
82
fini function is called at dlclose() time or when the process exits.
83
The module should declare a variable named dl_info that contains this
84
structure which must be exported. These functions correspond to the
85
documented _init() and _fini() functions of SunOS 4.x, but these are
86
appearently not implemented in SunOS. When using SunOS 5.0, these
87
correspond to #pragma init and #pragma fini respectively. At the same
88
time any static or global C++ object's constructors or destructors will
98
Phone: +49 511 36482-0
100
AppleLink: helios.de Attn: Jens-Uwe Mager
101
Internet: jum@helios.de
108
D 1.4 95/04/25 09:36:52 jum 4 3 00018/00004/00028
111
added RTLD_GLOBAL, include and C++ guards
113
D 1.3 92/12/27 20:58:32 jum 3 2 00001/00001/00031
116
we always have prototypes on RS/6000
118
D 1.2 92/08/16 17:45:11 jum 2 1 00009/00000/00023
121
added dl_info structure to implement initialize and terminate functions
123
D 1.1 92/08/02 18:08:45 jum 1 0 00023/00000/00000
126
Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum
130
D 1.7 95/08/14 19:08:38 jum 8 6 00026/00004/00502
133
Integrated the fixes from Kirk Benell (kirk@rsinc.com) to allow loading of
134
shared objects generated under AIX 4. Fixed bug that symbols with exactly
135
8 characters would use garbage characters from the following symbol value.
137
D 1.6 95/04/25 09:38:03 jum 6 5 00046/00006/00460
140
added handling of C++ static constructors and destructors, added RTLD_GLOBAL to bind against other loaded modules
142
D 1.5 93/02/14 20:14:17 jum 5 4 00002/00000/00464
145
added path to dlopen error message to make clear where there error occured.
147
D 1.4 93/01/03 19:13:56 jum 4 3 00061/00005/00403
150
to allow calling symbols in the main module call load with L_NOAUTODEFER and
151
do a loadbind later with the main module.
153
D 1.3 92/12/27 20:59:55 jum 3 2 00066/00008/00342
156
added search by L_GETINFO if module got loaded by LIBPATH
158
D 1.2 92/08/16 17:45:43 jum 2 1 00074/00006/00276
161
implemented initialize and terminate functions, added reference counting to avoid multiple loads of the same library
163
D 1.1 92/08/02 18:08:45 jum 1 0 00282/00000/00000
166
Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum