~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/backend/port/dynloader/README.dlfcn.aix

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Copyright (c) 1992,1993,1995, 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 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
 
8
not modified.
 
9
 
 
10
libdl.a
 
11
-------
 
12
 
 
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):
 
18
 
 
19
        cc -o module.so -bM:SRE -bE:module.exp -e _nostart $(OBJS)
 
20
 
 
21
For AIX 4:
 
22
 
 
23
        cc -o module.so -bM:SRE -bE:module.exp -bnoentry $(OBJS)
 
24
 
 
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.
 
31
 
 
32
Usage
 
33
-----
 
34
 
 
35
void *dlopen(const char *path, int mode);
 
36
 
 
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
 
48
modules.
 
49
 
 
50
 
 
51
void *dlsym(void *handle, const char *symbol);
 
52
 
 
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
 
58
is not implemented.
 
59
 
 
60
int dlclose(void *handle);
 
61
 
 
62
This routine unloads the module referred to by the handle and disposes
 
63
of any local storage. this function returns -1 on failure.
 
64
 
 
65
char *dlerror(void);
 
66
 
 
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.
 
70
 
 
71
Initialization and termination handlers
 
72
---------------------------------------
 
73
 
 
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:
 
77
 
 
78
        void (*init)(void);
 
79
        void (*fini)(void);
 
80
 
 
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
 
89
be called.
 
90
 
 
91
Jens-Uwe Mager
 
92
 
 
93
HELIOS Software GmbH
 
94
Lavesstr. 80
 
95
30159 Hannover
 
96
Germany
 
97
 
 
98
Phone:          +49 511 36482-0
 
99
FAX:            +49 511 36482-69
 
100
AppleLink:      helios.de       Attn: Jens-Uwe Mager
 
101
Internet:       jum@helios.de
 
102
 
 
103
Revison History
 
104
---------------
 
105
 
 
106
SCCS/s.dlfcn.h:
 
107
 
 
108
D 1.4 95/04/25 09:36:52 jum 4 3 00018/00004/00028
 
109
MRs:
 
110
COMMENTS:
 
111
added RTLD_GLOBAL, include and C++ guards
 
112
 
 
113
D 1.3 92/12/27 20:58:32 jum 3 2 00001/00001/00031
 
114
MRs:
 
115
COMMENTS:
 
116
we always have prototypes on RS/6000
 
117
 
 
118
D 1.2 92/08/16 17:45:11 jum 2 1 00009/00000/00023
 
119
MRs:
 
120
COMMENTS:
 
121
added dl_info structure to implement initialize and terminate functions
 
122
 
 
123
D 1.1 92/08/02 18:08:45 jum 1 0 00023/00000/00000
 
124
MRs:
 
125
COMMENTS:
 
126
Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum
 
127
 
 
128
SCCS/s.dlfcn.c:
 
129
 
 
130
D 1.7 95/08/14 19:08:38 jum 8 6 00026/00004/00502
 
131
MRs:
 
132
COMMENTS:
 
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.
 
136
 
 
137
D 1.6 95/04/25 09:38:03 jum 6 5 00046/00006/00460
 
138
MRs:
 
139
COMMENTS:
 
140
added handling of C++ static constructors and destructors, added RTLD_GLOBAL to bind against other loaded modules
 
141
 
 
142
D 1.5 93/02/14 20:14:17 jum 5 4 00002/00000/00464
 
143
MRs:
 
144
COMMENTS:
 
145
added path to dlopen error message to make clear where there error occured.
 
146
 
 
147
D 1.4 93/01/03 19:13:56 jum 4 3 00061/00005/00403
 
148
MRs:
 
149
COMMENTS:
 
150
to allow calling symbols in the main module call load with L_NOAUTODEFER and 
 
151
do a loadbind later with the main module.
 
152
 
 
153
D 1.3 92/12/27 20:59:55 jum 3 2 00066/00008/00342
 
154
MRs:
 
155
COMMENTS:
 
156
added search by L_GETINFO if module got loaded by LIBPATH
 
157
 
 
158
D 1.2 92/08/16 17:45:43 jum 2 1 00074/00006/00276
 
159
MRs:
 
160
COMMENTS:
 
161
implemented initialize and terminate functions, added reference counting to avoid multiple loads of the same library
 
162
 
 
163
D 1.1 92/08/02 18:08:45 jum 1 0 00282/00000/00000
 
164
MRs:
 
165
COMMENTS:
 
166
Erstellungsdatum und -uhrzeit 92/08/02 18:08:45 von jum
 
167