author | Claus Gittinger <cg@exept.de> |
Thu, 01 Oct 1998 15:21:33 +0200 | |
changeset 784 | c8742d9efcb6 |
parent 782 | 3d075581fbb0 |
child 790 | 5ee8cd853bbb |
permissions | -rw-r--r-- |
0 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
45 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Object subclass:#ObjectFileLoader |
|
174 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'MySymbolTable Verbose LastError LinkErrorMessage NextHandleID |
|
149
3dc42a5ab417
default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
LoadedObjects PreviouslyLoadedObjects ActuallyLoadedObjects |
759 | 17 |
SearchedLibraries LibPath LoadLibraryPath ErrorPrinting |
18 |
LinkCommand LinkArgs' |
|
174 | 19 |
poolDictionaries:'' |
20 |
category:'System-Compiler' |
|
47 | 21 |
! |
22 |
||
53 | 23 |
!ObjectFileLoader primitiveDefinitions! |
0 | 24 |
%{ |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
25 |
|
15 | 26 |
/* |
27 |
* by default, use whatever the system provides |
|
28 |
*/ |
|
95 | 29 |
#ifdef sunos /* sunos (pre 5.4) dlopen interface */ |
15 | 30 |
# define SUN_DL |
20 | 31 |
# define HAS_DL |
15 | 32 |
#endif |
33 |
||
95 | 34 |
#ifdef NeXT /* next rld interface */ |
15 | 35 |
# define NEXT_DL |
20 | 36 |
# define HAS_DL |
15 | 37 |
#endif |
38 |
||
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
39 |
#if defined(SYSV4) || defined(HAS_DLOPEN) /* sys5.4 dlopen interface */ |
15 | 40 |
# define SYSV4_DL |
20 | 41 |
# define HAS_DL |
15 | 42 |
#endif |
43 |
||
523 | 44 |
#if defined(hpux10) |
45 |
# undef SYSV4_DL |
|
46 |
# define HPUX10_DL |
|
741 | 47 |
# define HAS_DL |
523 | 48 |
#endif |
49 |
||
587 | 50 |
#if defined(alpha) && defined(__osf__) |
51 |
# define SYSV4_DL |
|
52 |
# define HAS_DL |
|
53 |
#endif |
|
54 |
||
609 | 55 |
#ifdef __VMS__ |
56 |
# undef __new |
|
57 |
# define VMS_DL |
|
58 |
#endif |
|
59 |
||
95 | 60 |
#ifdef DL1_6 /* dl1.6 COFF loader */ |
61 |
# define HAS_DL |
|
62 |
#endif |
|
63 |
||
98 | 64 |
#ifdef _AIX |
97 | 65 |
# define AIX_DL |
66 |
# define HAS_DL |
|
67 |
#endif |
|
68 |
||
15 | 69 |
/* |
20 | 70 |
* but GNU_DL overwrites this - its better |
15 | 71 |
*/ |
95 | 72 |
#ifdef GNU_DL /* dld2.3.x interface */ |
20 | 73 |
# define HAS_DL |
15 | 74 |
# undef SYSV4_DL |
75 |
# undef NEXT_DL |
|
76 |
# undef SUN_DL |
|
95 | 77 |
# undef DL1_6 |
15 | 78 |
#endif |
79 |
||
20 | 80 |
#include <stdio.h> |
81 |
||
175
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
82 |
#if defined(WIN32) |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
83 |
# undef COFF |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
84 |
# undef ELF |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
85 |
# undef A_DOT_OUT |
180 | 86 |
# define HAS_DL |
87 |
# define WIN_DL |
|
175
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
88 |
#endif |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
89 |
|
20 | 90 |
/* |
95 | 91 |
* if no dynamic link facilities, try it the hard way ... |
20 | 92 |
*/ |
175
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
93 |
#if !defined(HAS_DL) |
20 | 94 |
|
95 |
# ifdef A_DOT_OUT |
|
96 |
# include <a.out.h> |
|
97 |
# ifndef N_MAGIC |
|
98 |
# if defined(sinix) && defined(BSD) |
|
99 |
# define N_MAGIC(hdr) (hdr.a_magic & 0xFFFF) |
|
100 |
# else |
|
101 |
# define N_MAGIC(hdr) (hdr.a_magic) |
|
102 |
# endif |
|
103 |
# endif |
|
104 |
# endif /* a.out */ |
|
105 |
||
106 |
# ifdef COFF |
|
107 |
# ifdef mips |
|
108 |
# include <sys/exec.h> |
|
109 |
# else |
|
110 |
# include <a.out.h> |
|
111 |
# endif |
|
112 |
# endif /* coff */ |
|
113 |
||
114 |
# ifdef ELF |
|
115 |
# include <elf.h> |
|
116 |
# endif /* elf */ |
|
117 |
||
118 |
#endif /* not HAS_DL */ |
|
119 |
||
95 | 120 |
#ifdef NEXT_DL |
121 |
# ifndef _RLD_H_ |
|
122 |
# define _RLD_H_ |
|
125 | 123 |
# ifdef NEXT3 |
124 |
# include <mach-o/rld.h> |
|
125 |
# else |
|
126 |
# include <rld.h> |
|
127 |
# endif |
|
95 | 128 |
# endif |
129 |
#endif /* NEXT_DL */ |
|
130 |
||
28 | 131 |
#ifdef SYSV4_DL |
132 |
# include <dlfcn.h> |
|
133 |
# define dlcfn_h |
|
134 |
#endif |
|
135 |
||
45 | 136 |
#ifdef GNU_DL |
137 |
# ifndef dld_h |
|
138 |
# include "dld.h" |
|
139 |
# define dld_h |
|
140 |
# endif |
|
141 |
#endif |
|
95 | 142 |
|
143 |
#ifdef DL1_6 |
|
144 |
# ifndef dl_h |
|
145 |
# include "dl.h" |
|
146 |
# define dl_h |
|
147 |
# endif |
|
148 |
#endif |
|
149 |
||
97 | 150 |
#ifdef AIX_DL |
151 |
# include <nlist.h> |
|
100 | 152 |
# include <sys/ldr.h> |
153 |
# include <errno.h> |
|
97 | 154 |
#endif |
180 | 155 |
|
523 | 156 |
#ifdef HPUX10_DL |
157 |
# include <dl.h> |
|
524 | 158 |
# include <errno.h> |
523 | 159 |
#endif |
160 |
||
180 | 161 |
#ifdef WIN_DL |
162 |
||
163 |
# ifdef WIN32 |
|
729 | 164 |
# undef INT |
165 |
# undef Array |
|
166 |
# undef Number |
|
167 |
# undef Method |
|
168 |
# undef Block |
|
169 |
||
170 |
# ifdef i386 |
|
171 |
# ifndef _X86_ |
|
172 |
# define _X86_ |
|
180 | 173 |
# endif |
729 | 174 |
# endif |
175 |
||
176 |
# ifdef __BORLANDC__ |
|
177 |
# define NOATOM |
|
178 |
# define NOUSER |
|
179 |
# define NOGDI |
|
180 |
# define NOGDICAPMASKS |
|
181 |
# define NOMETAFILE |
|
182 |
# define NOMINMAX |
|
183 |
# define NOMSG |
|
184 |
# define NOOPENFILE |
|
185 |
# define NORASTEROPS |
|
186 |
# define NOSCROLL |
|
187 |
# define NOSOUND |
|
188 |
# define NOSYSMETRICS |
|
189 |
# define NOTEXTMETRIC |
|
190 |
# define NOWH |
|
191 |
# define NOCOMM |
|
192 |
# define NOKANJI |
|
193 |
# define NOCRYPT |
|
194 |
# define NOMCX |
|
195 |
# define WIN32_LEAN_AND_MEAN |
|
196 |
# include <windows.h> /* */ |
|
197 |
# else |
|
180 | 198 |
/* # include <windows.h> /* */ |
729 | 199 |
# endif |
180 | 200 |
# include <windef.h> /* */ |
201 |
# include <winbase.h> /* */ |
|
202 |
||
729 | 203 |
# ifdef __DEF_Array |
204 |
# define Array __DEF_Array |
|
205 |
# endif |
|
206 |
# ifdef __DEF_Number |
|
207 |
# define Number __DEF_Number |
|
208 |
# endif |
|
209 |
# ifdef __DEF_Method |
|
210 |
# define Method __DEF_Method |
|
211 |
# endif |
|
212 |
# ifdef __DEF_Block |
|
213 |
# define Block __DEF_Block |
|
214 |
# endif |
|
180 | 215 |
# endif |
216 |
||
729 | 217 |
#endif /* WIN_DL */ |
0 | 218 |
%} |
20 | 219 |
! ! |
220 |
||
369 | 221 |
!ObjectFileLoader class methodsFor:'documentation'! |
141 | 222 |
|
223 |
copyright |
|
224 |
" |
|
225 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
226 |
All Rights Reserved |
|
227 |
||
228 |
This software is furnished under a license and may be used |
|
229 |
only in accordance with the terms of that license and with the |
|
230 |
inclusion of the above copyright notice. This software may not |
|
231 |
be provided or otherwise made available to, or used by, any |
|
232 |
other person. No title to or ownership of the software is |
|
233 |
hereby transferred. |
|
234 |
" |
|
235 |
! |
|
236 |
||
237 |
documentation |
|
238 |
" |
|
239 |
This class knowns how to dynamically load in external object-modules. |
|
240 |
||
241 |
WARNING: |
|
242 |
As to date, this is completely experimental and WITHOUT ANY WARRANTY. |
|
243 |
It is still being developed and the code below needs cleanup and more |
|
244 |
robustness. |
|
245 |
||
246 |
There are basically two totally different mechanisms to do this: |
|
468 | 247 |
a) if there exists some dynamic-link facility such as: |
248 |
GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT), |
|
249 |
this is used |
|
250 |
b) if no such facility exists, the normal linker is used to |
|
251 |
link the module to text/data address as previously malloced, |
|
252 |
and the object file loaded into that space. |
|
141 | 253 |
|
254 |
Currently, not all mechanisms work fully satisfying. |
|
255 |
For example, the sun dl*-functions do an exit on link-errors (which |
|
256 |
is certainly not what we want here :-(; the NeXT mechanism does not |
|
257 |
allow for selective unloading (only all or last). |
|
258 |
||
259 |
The only really useful packages are the GNU-dl package and the SGI/Unixware |
|
260 |
sys5.4 libdl packages. |
|
261 |
The GNU-dl package is only available for a.out file formats; |
|
262 |
i.e. only (a subset of) linux people can use it at this time. |
|
263 |
For the above reasons, dynamic object loading is currently only |
|
264 |
officially released for SYS5.4 and LINUX systems. |
|
265 |
||
266 |
Once stable, the functionality contained herein will be moved into |
|
267 |
the VM. |
|
268 |
(It is needed there, to allow reloading of objectfiles upon |
|
269 |
image restart; i.e. before any class is reinitialilized). |
|
263 | 270 |
|
271 |
[author:] |
|
468 | 272 |
Claus Gittinger |
141 | 273 |
" |
274 |
! ! |
|
275 |
||
369 | 276 |
!ObjectFileLoader class methodsFor:'initialization'! |
0 | 277 |
|
278 |
initialize |
|
317 | 279 |
|systemType| |
0 | 280 |
|
759 | 281 |
OperatingSystem isMSDOSlike ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
282 |
"/ default setup for msc |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
283 |
OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
284 |
LinkCommand isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
285 |
LinkCommand := 'tlink32'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
286 |
LinkCommand := 'ilink32'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
287 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
288 |
LinkArgs isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
289 |
LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ..\libbc\librun.lib'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
290 |
LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
291 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
292 |
] ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
293 |
LinkCommand isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
294 |
LinkCommand := 'link' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
295 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
296 |
LinkArgs isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
297 |
LinkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
298 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
299 |
]. |
759 | 300 |
]. |
301 |
||
201 | 302 |
MySymbolTable isNil ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
303 |
Verbose := false. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
304 |
NextHandleID := 1. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
305 |
ObjectMemory addDependent:self. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
306 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
307 |
OperatingSystem isMSDOSlike ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
308 |
SearchedLibraries := #( |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
309 |
'import32.lib' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
310 |
). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
311 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
312 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
313 |
OperatingSystem isUNIXlike ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
314 |
systemType := OperatingSystem getOSType. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
315 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
316 |
"/ name of object file, where initial symbol table is found |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
317 |
"/ not req'd for all architectures. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
318 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
319 |
MySymbolTable := 'stx'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
320 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
321 |
"/ default set of libraries to be considered when |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
322 |
"/ unresolved symbols are encountered during the load. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
323 |
"/ Only req'd for linux and sunos non-ELF systems. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
324 |
"/ Can (should) be set in the smalltalk.rc file. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
325 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
326 |
SearchedLibraries := #(). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
327 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
328 |
(systemType = 'linux' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
329 |
or:[systemType = 'sunos']) ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
330 |
'/usr/lib/libc.a' asFilename isReadable ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
331 |
SearchedLibraries := #('/usr/lib/libc.a') |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
332 |
] ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
333 |
'/lib/libc.a' asFilename isReadable ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
334 |
SearchedLibraries := #('/lib/libc.a') |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
335 |
] |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
336 |
] |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
337 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
338 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
339 |
"/ default libraryPath where shared objects are searched for |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
340 |
"/ when a dynamic library is loaded without an explicit path. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
341 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
342 |
LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
343 |
LoadLibraryPath isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
344 |
LoadLibraryPath := #('.' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
345 |
'lib' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
346 |
'/usr/local/smalltalk/lib' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
347 |
'/usr/local/lib' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
348 |
'/usr/lib' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
349 |
'/lib' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
350 |
) asOrderedCollection. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
351 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
352 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
353 |
"/ default libraryPath where shared objects are expected |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
354 |
"/ when a sharedObject load requires other objects to be loaded. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
355 |
"/ Only req'd for aix. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
356 |
"/ For more compatibility with ELF systems, look for a shell variable |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
357 |
"/ named LD_LIBRARY_PATH, and - if present - take that instead if a default. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
358 |
"/ Can (should) be set in the smalltalk.rc file. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
359 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
360 |
systemType = 'aix' ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
361 |
LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
362 |
LibPath isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
363 |
LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
364 |
] |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
365 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
366 |
] |
201 | 367 |
] |
107 | 368 |
|
369 |
" |
|
370 |
ObjectFileLoader initialize |
|
371 |
" |
|
316
ee3426730cfc
on sunos: link dynamic objects against libc.a for unresolved symbols.
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
372 |
|
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
373 |
"Modified: / 30.9.1998 / 17:28:24 / cg" |
0 | 374 |
! |
375 |
||
141 | 376 |
lastError |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
377 |
^ LastError ? 'unknown error' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
378 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
379 |
"Modified: / 30.9.1998 / 17:21:23 / cg" |
141 | 380 |
! |
381 |
||
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
382 |
libPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
383 |
"see comment in #libPath:" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
384 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
385 |
^ LibPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
386 |
! |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
387 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
388 |
libPath:aSharedLibraryPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
389 |
"set the pathnames of directories, where other shared objects |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
390 |
are searched, in case a loaded module requires another module shared |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
391 |
library object to be loaded. |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
392 |
Currently, this is only required to be set for AIX systems; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
393 |
ELF based linux and solaris systems specify the libPath in the |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
394 |
LD_LIBRARY_PATH environment variable." |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
395 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
396 |
LibPath := aSharedLibraryPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
397 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
398 |
" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
399 |
ObjectFileLoader libPath:'.:/usr/lib:/usr/local/lib' |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
400 |
" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
401 |
! |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
402 |
|
141 | 403 |
linkErrorMessage |
404 |
^ LinkErrorMessage |
|
405 |
! |
|
406 |
||
407 |
searchedLibraries |
|
408 |
"see comment in #searchedLibraries:" |
|
409 |
||
410 |
^ SearchedLibraries |
|
411 |
! |
|
412 |
||
125 | 413 |
searchedLibraries:aCollectionOfArchivePathNames |
414 |
"set the pathnames of archives which are to be searched |
|
415 |
when unresolved references occur while loading in an object |
|
416 |
file. On systems which support shared libraries (all SYS5.4 based |
|
417 |
systems), this is usually not required. Instead, modules which are to |
|
418 |
be filed in (.so files) are to be prelinked with the appropriate |
|
419 |
shared libraries. The dynamic loader then cares about loading those |
|
420 |
modules (keeping track of which modules are already loaded). |
|
421 |
Only systems in which the dynamic load is done 'manually' by st/x |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
422 |
(i.e. currently only linux and a.out-sunos) need to set this." |
125 | 423 |
|
424 |
SearchedLibraries := aCollectionOfArchivePathNames |
|
425 |
! |
|
426 |
||
741 | 427 |
verbose |
428 |
"return true, if debug traces are turned on" |
|
429 |
||
430 |
^ Verbose |
|
431 |
! |
|
432 |
||
0 | 433 |
verbose:aBoolean |
434 |
"turn on/off debug traces" |
|
435 |
||
10 | 436 |
Verbose := aBoolean |
0 | 437 |
|
438 |
"ObjectFileLoader verbose:true" |
|
439 |
! ! |
|
440 |
||
369 | 441 |
!ObjectFileLoader class methodsFor:'change & update'! |
291 | 442 |
|
443 |
update:something with:aParameter from:changedObject |
|
107 | 444 |
"sent, when image is saved or restarted" |
445 |
||
446 |
(something == #aboutToSnapshot) ifTrue:[ |
|
468 | 447 |
self invalidateAndRememberAllObjectFiles |
125 | 448 |
]. |
449 |
(something == #finishedSnapshot) ifTrue:[ |
|
468 | 450 |
self revalidateAllObjectFiles |
107 | 451 |
]. |
226
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
452 |
"/ (something == #restarted) ifTrue:[ |
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
453 |
"/ self reloadAllRememberedObjectFiles |
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
454 |
"/ ]. |
125 | 455 |
|
456 |
"Modified: 5.10.1995 / 15:49:14 / claus" |
|
226
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
457 |
"Modified: 8.3.1996 / 23:34:29 / cg" |
291 | 458 |
"Created: 21.6.1996 / 19:50:01 / cg" |
107 | 459 |
! ! |
460 |
||
369 | 461 |
!ObjectFileLoader class methodsFor:'defaults'! |
115 | 462 |
|
141 | 463 |
hasValidBinaryExtension:aFilename |
464 |
"return true, if aFilename looks ok for binary loading. |
|
465 |
This checks only the extension - not its contents. |
|
466 |
(So an attempt to load the file may fail due to format errors or unresolved symbols) |
|
467 |
This is very machine specific." |
|
468 |
||
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
469 |
|fn| |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
470 |
|
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
471 |
fn := aFilename asFilename. |
141 | 472 |
self validBinaryExtensions do:[:ext | |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
473 |
(fn hasSuffix:ext) ifTrue:[^ true]. |
141 | 474 |
]. |
475 |
^ false |
|
476 |
||
477 |
" |
|
478 |
ObjectFileLoader hasValidBinaryExtension:'foo.st' |
|
516 | 479 |
ObjectFileLoader hasValidBinaryExtension:'foo.o' |
141 | 480 |
ObjectFileLoader hasValidBinaryExtension:'foo.so' |
516 | 481 |
ObjectFileLoader hasValidBinaryExtension:'foo.dll' |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
482 |
ObjectFileLoader hasValidBinaryExtension:'foo.DLL' |
516 | 483 |
ObjectFileLoader hasValidBinaryExtension:'foo.obj' |
741 | 484 |
ObjectFileLoader hasValidBinaryExtension:'foo.sl' |
141 | 485 |
" |
516 | 486 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
487 |
"Modified: / 1.10.1998 / 12:47:01 / cg" |
141 | 488 |
! |
489 |
||
759 | 490 |
linkArgs |
491 |
^ LinkArgs ? '' "/ that default is ok for Unix |
|
492 |
||
493 |
"Created: / 12.8.1998 / 21:41:16 / cg" |
|
494 |
"Modified: / 12.8.1998 / 21:42:50 / cg" |
|
495 |
! |
|
496 |
||
497 |
linkArgs:anArgString |
|
498 |
LinkArgs := anArgString |
|
499 |
||
500 |
" |
|
501 |
MSC: |
|
778 | 502 |
LinkCommand := 'link32'. |
503 |
LinkArgs := ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def' |
|
759 | 504 |
|
505 |
Borland: |
|
778 | 506 |
LinkCommand := 'ilink32'. |
507 |
LinkArgs := '-ap -E0 -Tpd -s -c -L\Programme\Borland\CBuilder3\lib -L..\libbc librun.lib import32.lib' |
|
759 | 508 |
' |
509 |
'/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def' |
|
510 |
||
511 |
Unix: |
|
778 | 512 |
LinkCommand := 'ld' |
513 |
LinkArgs := '-shared' |
|
759 | 514 |
" |
515 |
||
516 |
"Created: / 12.8.1998 / 21:43:16 / cg" |
|
771 | 517 |
"Modified: / 4.9.1998 / 00:33:46 / cg" |
759 | 518 |
! |
519 |
||
520 |
linkCommand |
|
521 |
^ LinkCommand ? 'ld' "/ that default is ok for Unix |
|
522 |
||
523 |
"Created: / 12.8.1998 / 21:41:16 / cg" |
|
524 |
! |
|
525 |
||
526 |
linkCommand:aCommand |
|
527 |
LinkCommand := aCommand |
|
528 |
||
529 |
"Created: / 12.8.1998 / 21:40:44 / cg" |
|
530 |
! |
|
531 |
||
188 | 532 |
loadableBinaryObjectFormat |
533 |
"return a symbol describing the expected binary format |
|
534 |
for object files to be loadable. |
|
535 |
This is very machine specific." |
|
536 |
||
537 |
%{ /* NOCONTEXT */ |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
538 |
|
188 | 539 |
#ifdef HAS_DL |
540 |
# if defined(SYSV4) || defined(ELF) |
|
541 |
RETURN ( @symbol(elf)); |
|
542 |
# endif |
|
590 | 543 |
# if defined(alpha) && defined(__osf__) |
544 |
RETURN ( @symbol(coff)); |
|
545 |
# endif |
|
188 | 546 |
# if defined(GNU_DL) |
547 |
RETURN ( @symbol(aout)); |
|
548 |
# endif |
|
549 |
# if defined(AIX_DL) |
|
550 |
RETURN ( @symbol(xcoff)); |
|
551 |
# endif |
|
523 | 552 |
# if defined(HPUX10_DL) |
553 |
RETURN ( @symbol(hpcoff)); |
|
554 |
# endif |
|
188 | 555 |
# if defined(DL1_6) |
556 |
RETURN ( @symbol(coff)); |
|
557 |
# endif |
|
558 |
# if defined(WIN_DL) |
|
559 |
RETURN ( @symbol(dll)); |
|
560 |
# endif |
|
609 | 561 |
# if defined(__VMS__) |
562 |
RETURN ( @symbol(exe)); |
|
563 |
# endif |
|
188 | 564 |
#endif |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
565 |
|
188 | 566 |
%}. |
567 |
^ nil |
|
568 |
||
569 |
" |
|
570 |
ObjectFileLoader loadableBinaryObjectFormat |
|
571 |
" |
|
572 |
! |
|
573 |
||
141 | 574 |
nm:file |
403 | 575 |
"this should return a string to list the namelist of file. |
576 |
The output of the command should be one line for each symbol, |
|
577 |
formatted as: |
|
741 | 578 |
addr segment name |
403 | 579 |
This is parsed and read by #namesMatching:segment:in:. |
580 |
||
581 |
If your default nm command cannot produce this, write a little |
|
582 |
shell or awk script, to generate this and return a corresponding command |
|
521 | 583 |
below. |
584 |
This entry is obsolete (no longer req'd) and will vanish." |
|
141 | 585 |
|
586 |
|os| |
|
587 |
||
521 | 588 |
os := OperatingSystem getOSType. |
702
80f90a274837
more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
589 |
(os = 'irix' or:[os = 'osf']) ifTrue:[ |
741 | 590 |
^ 'nm -B ' , file |
403 | 591 |
]. |
592 |
(os = 'solaris') ifTrue:[ |
|
741 | 593 |
^ 'nm -p ' , file |
141 | 594 |
]. |
595 |
^ 'nm ' , file |
|
403 | 596 |
|
702
80f90a274837
more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
597 |
"Modified: / 4.5.1998 / 12:18:47 / cg" |
141 | 598 |
! |
599 |
||
741 | 600 |
objectFileExtension |
601 |
"return the fileName extension used for objects, |
|
602 |
as generated by myself (output of cc). |
|
115 | 603 |
This is very machine specific." |
604 |
||
605 |
|os| |
|
606 |
||
521 | 607 |
OperatingSystem isMSDOSlike ifTrue:[ |
741 | 608 |
"/ includes all of win32s, win95, winNT & os/2 |
609 |
^ '.obj' |
|
521 | 610 |
]. |
609 | 611 |
OperatingSystem isVMSlike ifTrue:[ |
741 | 612 |
^ '.obj' |
613 |
]. |
|
614 |
||
615 |
^ '.o' |
|
616 |
||
617 |
" |
|
618 |
ObjectFileLoader objectFileExtension |
|
619 |
" |
|
620 |
||
621 |
"Modified: / 4.5.1998 / 12:17:34 / cg" |
|
622 |
! |
|
623 |
||
624 |
sharedLibraryExtension |
|
625 |
"return the fileName extension used for dynamic loadable objects, |
|
626 |
as generated by myself (output of linker). |
|
627 |
This is very machine specific." |
|
628 |
||
629 |
|os| |
|
630 |
||
631 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
632 |
"/ includes all of win32s, win95, winNT & os/2 |
|
633 |
^ '.dll' |
|
634 |
]. |
|
635 |
OperatingSystem isVMSlike ifTrue:[ |
|
636 |
^ '.exe' |
|
609 | 637 |
]. |
521 | 638 |
|
115 | 639 |
os := OperatingSystem getSystemType. |
125 | 640 |
(os = 'sys5_4') ifTrue:[^ '.so']. |
115 | 641 |
(os = 'iris') ifTrue:[^ '.so']. |
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
642 |
(os = 'linux') ifTrue:[ |
741 | 643 |
self loadableBinaryObjectFormat == #aout ifTrue:[ |
644 |
"/ not really shared, but loadable |
|
645 |
^ '.o' |
|
646 |
]. |
|
647 |
^ '.so' |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
648 |
]. |
404 | 649 |
(os = 'solaris') ifTrue:[^ '.so' ]. |
702
80f90a274837
more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
650 |
(os = 'osf') ifTrue:[^ '.so' ]. |
115 | 651 |
(os = 'aix') ifTrue:[^ '.so']. |
652 |
(os = 'hpux') ifTrue:[^ '.sl']. |
|
119 | 653 |
|
654 |
"/ mhmh what is a useful default ? |
|
655 |
||
656 |
^ '.o' |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
657 |
|
741 | 658 |
" |
659 |
ObjectFileLoader sharedLibraryExtension |
|
660 |
" |
|
661 |
||
702
80f90a274837
more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
662 |
"Modified: / 4.5.1998 / 12:17:34 / cg" |
115 | 663 |
! |
0 | 664 |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
665 |
validBinaryExtensions |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
666 |
"return a collection of valid filename extension for binary files. |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
667 |
This is very machine specific." |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
668 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
669 |
|os| |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
670 |
|
521 | 671 |
OperatingSystem isMSDOSlike ifTrue:[ |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
672 |
"/ includes all of win32s, win95, winNT & os/2 |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
673 |
^ #('dll') |
521 | 674 |
]. |
609 | 675 |
OperatingSystem isVMSlike ifTrue:[ |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
676 |
^ #('exe') |
609 | 677 |
]. |
521 | 678 |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
679 |
os := OperatingSystem getSystemType. |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
680 |
(os = 'sys5_4') ifTrue:[^ #('so') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
681 |
(os = 'iris') ifTrue:[^ #('so') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
682 |
(os = 'osf') ifTrue:[^ #('so') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
683 |
(os = 'solaris') ifTrue:[^ #('so') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
684 |
(os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
685 |
(os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ]. |
504 | 686 |
(os = 'linux') ifTrue:[ |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
687 |
self loadableBinaryObjectFormat == #aout ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
688 |
^ #('o' 'obj' 'a') |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
689 |
]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
690 |
^ #('so' 'o' 'obj' ) |
504 | 691 |
]. |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
692 |
(os = 'aix') ifTrue:[^ #('o' 'so') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
693 |
(os = 'hpux') ifTrue:[^ #(" 'o' " 'sl') ]. |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
694 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
695 |
"/ mhmh what is a useful default ? |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
696 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
697 |
^ #('o') |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
698 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
699 |
" |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
700 |
ObjectFileLoader validBinaryExtensions |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
701 |
" |
403 | 702 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
703 |
"Modified: / 1.10.1998 / 12:46:03 / cg" |
141 | 704 |
! ! |
705 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
706 |
!ObjectFileLoader class methodsFor:'dynamic object loading'! |
141 | 707 |
|
708 |
loadCPlusPlusObjectFile:aFileName |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
709 |
"load a c++ object file (.o-file) into the image. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
710 |
This method is not maintained (name mangling and static |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
711 |
initialization is so different among systems ...)" |
141 | 712 |
|
713 |
|handle initAddr list| |
|
714 |
||
715 |
handle := self loadDynamicObject:aFileName. |
|
716 |
handle isNil ifTrue:[ |
|
524 | 717 |
Transcript showCR:('failed to load: ' , aFileName). |
718 |
('ObjectFileLoader [warning]: ' |
|
719 |
, aFileName |
|
720 |
, ' failed. (' |
|
721 |
, LinkErrorMessage |
|
722 |
, ')') errorPrintCR. |
|
634 | 723 |
^ nil |
141 | 724 |
]. |
725 |
||
609 | 726 |
list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName. |
141 | 727 |
list size == 1 ifTrue:[ |
728 |
"/ (self isCPlusPlusObject:handle) ifTrue:[ |
|
634 | 729 |
Verbose ifTrue:[ |
730 |
'a c++ object file' infoPrintCR. |
|
731 |
]. |
|
732 |
" |
|
733 |
what I would like to get is the CTOR_LIST, |
|
734 |
and call each function. |
|
735 |
But dld cannot (currently) handle SET-type symbols, therefore |
|
736 |
we search (using nm) for all __GLOBAL_$I* syms, get their values |
|
737 |
and call them each |
|
738 |
" |
|
609 | 739 |
"/ list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName. |
141 | 740 |
|
741 |
"/ initAddr := self getFunction:'__CTOR_LIST__' from:handle. |
|
742 |
"/ Verbose ifTrue:[ |
|
478 | 743 |
"/ ('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintCR |
141 | 744 |
"/ ]. |
745 |
||
634 | 746 |
initAddr := self getFunction:list first from:handle. |
747 |
initAddr isNil ifTrue:[ |
|
748 |
" |
|
749 |
try with added underscore |
|
750 |
" |
|
751 |
initAddr := self getFunction:('_' , list first) from:handle. |
|
752 |
]. |
|
753 |
(initAddr isNil and:[list first startsWith:'_']) ifTrue:[ |
|
754 |
" |
|
755 |
try with removed underscore |
|
756 |
" |
|
757 |
initAddr := self getFunction:(list first copyFrom:2) from:handle. |
|
758 |
]. |
|
759 |
initAddr isNil ifTrue:[ |
|
760 |
Verbose ifTrue:[ |
|
761 |
('no CTOR-func found (' , list first , ')') infoPrintCR. |
|
762 |
]. |
|
763 |
self unloadDynamicObject:aFileName. |
|
764 |
^ nil |
|
765 |
]. |
|
766 |
Verbose ifTrue:[ |
|
767 |
('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintCR |
|
768 |
]. |
|
769 |
self callInitFunctionAt:initAddr |
|
770 |
specialInit:false |
|
771 |
forceOld:false |
|
772 |
interruptable:false |
|
773 |
argument:0 |
|
774 |
identifyAs:nil |
|
775 |
returnsObject:false. |
|
776 |
||
777 |
Verbose ifTrue:[ |
|
778 |
'done with CTORs.' infoPrintNL |
|
779 |
]. |
|
780 |
||
781 |
" |
|
782 |
cannot create a CPlusPlus class automatically (there could be more than |
|
783 |
one classes in it too ...) |
|
784 |
" |
|
785 |
^ handle |
|
141 | 786 |
]. |
787 |
||
788 |
||
789 |
Verbose ifTrue:[ |
|
634 | 790 |
'unknown object file' infoPrintNL |
141 | 791 |
]. |
792 |
self unloadDynamicObject:aFileName. |
|
793 |
^ nil |
|
272 | 794 |
|
478 | 795 |
"Modified: 10.1.1997 / 19:11:57 / cg" |
141 | 796 |
! |
797 |
||
798 |
loadClass:aClassName fromObjectFile:aFileName |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
799 |
"load a compiled class (.o-file) into the image. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
800 |
Returns the class or nil." |
141 | 801 |
|
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
802 |
|handle initAddr symName newClass moreHandles info status |
141 | 803 |
otherClass knownToBeOk| |
804 |
||
805 |
handle := self loadDynamicObject:aFileName. |
|
806 |
handle isNil ifTrue:[ |
|
634 | 807 |
Transcript showCR:('failed to load: ' , aFileName). |
808 |
('ObjectFileLoader [warning]: ' |
|
809 |
, aFileName |
|
810 |
, ' failed. (' |
|
811 |
, LinkErrorMessage |
|
812 |
, ')') errorPrintCR. |
|
813 |
^ nil |
|
141 | 814 |
]. |
815 |
||
816 |
" |
|
817 |
get the Init-function; let the class install itself |
|
818 |
" |
|
819 |
symName := '_' , aClassName , '_Init'. |
|
820 |
initAddr := self getFunction:symName from:handle. |
|
821 |
initAddr isNil ifTrue:[ |
|
634 | 822 |
"try with added underscore" |
823 |
symName := '__' , aClassName , '_Init'. |
|
824 |
initAddr := self getFunction:symName from:handle. |
|
141 | 825 |
]. |
826 |
||
827 |
knownToBeOk := true. |
|
828 |
||
829 |
"/ knownToBeOk ifFalse:[ |
|
468 | 830 |
"/ |list| |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
831 |
"/ |
141 | 832 |
"/ Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
833 |
"/ 'looking for undefs ...' infoPrintCR. |
141 | 834 |
"/ ]. |
835 |
"/ |
|
836 |
"/ " |
|
837 |
"/ if there are any undefined symbols, we may have to load more |
|
838 |
"/ files (libs, other modules) |
|
839 |
"/ " |
|
840 |
"/ list := self getListOfUndefinedSymbolsFrom:handle. |
|
841 |
"/ list notNil ifTrue:[ |
|
842 |
"/ moreHandles := self loadModulesFromListOfUndefined:list. |
|
843 |
"/ |
|
844 |
"/ " |
|
845 |
"/ now, try again |
|
846 |
"/ " |
|
847 |
"/ symName := '_' , aClassName , '_Init'. |
|
848 |
"/ initAddr := self getFunction:symName from:handle. |
|
849 |
"/ initAddr isNil ifTrue:[ |
|
850 |
"/ "try with added underscore" |
|
851 |
"/ symName := '__' , aClassName , '_Init'. |
|
852 |
"/ initAddr := self getFunction:symName from:handle. |
|
853 |
"/ ]. |
|
854 |
"/ ] |
|
855 |
"/ ]. |
|
856 |
||
857 |
initAddr notNil ifTrue:[ |
|
634 | 858 |
Verbose ifTrue:[ |
859 |
('calling init at: ' , (initAddr printStringRadix:16)) infoPrintCR. |
|
860 |
]. |
|
861 |
info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle. |
|
862 |
status := info at:1. |
|
863 |
" |
|
864 |
if any classes are missing ... |
|
865 |
" |
|
866 |
(status == #missingClass) ifTrue:[ |
|
867 |
" |
|
868 |
... and we are loading a module ... |
|
869 |
" |
|
870 |
Transcript showCR:'try for missing class in same object ...'. |
|
871 |
Verbose ifTrue:[ |
|
872 |
'try for missing class:' infoPrint. (info at:2) infoPrintCR. |
|
873 |
]. |
|
874 |
otherClass := self loadClass:(info at:2) fromObjectFile:aFileName. |
|
875 |
otherClass notNil ifTrue:[ |
|
876 |
" |
|
877 |
try again ... |
|
878 |
" |
|
879 |
Transcript showCR:'missing class is here; try again ...'. |
|
880 |
info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle. |
|
881 |
status := info at:1. |
|
882 |
] |
|
883 |
]. |
|
884 |
||
885 |
Verbose ifTrue:[ |
|
886 |
'done init status=' infoPrint. info infoPrintCR. |
|
887 |
]. |
|
888 |
(status == #unregisteredSuperclass) ifTrue:[ |
|
889 |
Transcript showCR:'superclass is not registered'. |
|
890 |
]. |
|
891 |
||
892 |
(Symbol hasInterned:aClassName) ifTrue:[ |
|
893 |
newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil]. |
|
894 |
Verbose ifTrue:[ |
|
895 |
'newClass is: ' infoPrint. newClass infoPrintCR |
|
896 |
]. |
|
897 |
newClass notNil ifTrue:[ |
|
898 |
Verbose ifTrue:[ |
|
899 |
'initialize newClass ...' infoPrintCR |
|
900 |
]. |
|
901 |
newClass initialize. |
|
902 |
"force cache flush" |
|
903 |
Smalltalk at:aClassName asSymbol put:newClass. |
|
904 |
Smalltalk isInitialized ifTrue:[ |
|
905 |
Smalltalk changed. |
|
906 |
] |
|
907 |
]. |
|
908 |
] ifFalse:[ |
|
909 |
'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint. |
|
910 |
' did not define itself' errorPrintCR |
|
911 |
" |
|
912 |
do not unload - could have installed other classes/methods ... |
|
913 |
" |
|
914 |
]. |
|
915 |
Smalltalk flushCachedClasses. |
|
916 |
^ newClass |
|
141 | 917 |
]. |
918 |
||
919 |
Verbose ifTrue:[ |
|
634 | 920 |
('no symbol: ', symName,' in ',aFileName) infoPrintCR. |
141 | 921 |
]. |
922 |
||
923 |
" |
|
924 |
unload |
|
925 |
" |
|
926 |
Verbose ifTrue:[ |
|
634 | 927 |
'unloading due to init failure:' infoPrint. handle pathName infoPrintCR. |
141 | 928 |
]. |
929 |
||
930 |
moreHandles notNil ifTrue:[ |
|
634 | 931 |
moreHandles do:[:aHandle | |
932 |
Verbose ifTrue:[ |
|
933 |
('unloading: ', aHandle printString) infoPrintCR. |
|
934 |
]. |
|
935 |
self unloadDynamicObject:handle. |
|
936 |
] |
|
141 | 937 |
]. |
938 |
||
939 |
Verbose ifTrue:[ |
|
634 | 940 |
('unloading: ', handle printString) infoPrintCR. |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
941 |
]. |
141 | 942 |
self unloadDynamicObject:handle. |
943 |
^ nil |
|
944 |
||
945 |
" |
|
946 |
ObjectFileLoader loadClass:'Tetris' fromObjectFile:'../clients/Tetris/Tetris.o' |
|
947 |
ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o' |
|
948 |
ObjectFileLoader loadClass:'Foo' fromObjectFile:'classList.o' |
|
949 |
" |
|
272 | 950 |
|
582
9a00e2dbdc97
must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents:
580
diff
changeset
|
951 |
"Modified: 6.7.1997 / 12:34:48 / cg" |
141 | 952 |
! |
953 |
||
504 | 954 |
loadLibrary:aLibraryFileName |
955 |
"load a library; search in some standard places and using |
|
956 |
standard suffixes (i.e. no suffix should be given in the arg). |
|
957 |
Returns a handle or nil. |
|
958 |
Use this to attach C-libraries." |
|
959 |
||
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
960 |
|s suffixes handle libFilename| |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
961 |
|
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
962 |
libFilename := aLibraryFileName asFilename. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
963 |
(s := libFilename suffix) isEmpty ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
964 |
suffixes := self validBinaryExtensions |
504 | 965 |
] ifFalse:[ |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
966 |
suffixes := #('') |
504 | 967 |
]. |
968 |
||
969 |
"/ try each suffix ... |
|
970 |
suffixes do:[:aSuffix | |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
971 |
|fn f| |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
972 |
|
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
973 |
fn := aLibraryFileName , '.' , aSuffix. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
974 |
|
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
975 |
(libFilename isAbsolute |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
976 |
or:[(aLibraryFileName startsWith:'./') |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
977 |
or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
978 |
f := fn asFilename. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
979 |
f exists ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
980 |
handle := self loadObjectFile:fn. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
981 |
handle notNil ifTrue:[^ handle]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
982 |
] |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
983 |
] ifFalse:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
984 |
"/ try each directory |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
985 |
|
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
986 |
(LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
987 |
do:[:aDir | |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
988 |
f := aDir asFilename construct:fn. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
989 |
f exists ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
990 |
handle := self loadObjectFile:f pathName. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
991 |
handle notNil ifTrue:[^ handle]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
992 |
] |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
993 |
] |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
994 |
] |
504 | 995 |
]. |
996 |
||
997 |
^ nil |
|
998 |
||
999 |
" |
|
1000 |
ObjectFileLoader loadLibrary:'libjpeg' |
|
1001 |
" |
|
1002 |
||
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1003 |
"Modified: / 1.10.1998 / 14:38:18 / cg" |
504 | 1004 |
! |
1005 |
||
174 | 1006 |
loadMethodObjectFile:aFileName |
1007 |
"load an object file (.o-file) for a single method into the image; |
|
1008 |
This does a slightly different initialization. |
|
1009 |
Return an object handle; nil on error" |
|
1010 |
||
346 | 1011 |
|handle initAddr initName m| |
174 | 1012 |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1013 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1014 |
"/ load the objectfile |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1015 |
"/ |
174 | 1016 |
handle := self loadDynamicObject:aFileName. |
1017 |
handle isNil ifTrue:[ |
|
634 | 1018 |
^ nil |
174 | 1019 |
]. |
1020 |
||
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1021 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1022 |
"/ find the entry function |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1023 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1024 |
initName := aFileName asFilename withoutSuffix baseName. |
174 | 1025 |
|
1026 |
initAddr := self getFunction:'__' , initName , '_Init' from:handle. |
|
1027 |
initAddr isNil ifTrue:[ |
|
634 | 1028 |
initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
1029 |
initAddr isNil ifTrue:[ |
|
1030 |
(self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[ |
|
1031 |
self listUndefinedSymbolsIn:handle. |
|
1032 |
'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR. |
|
1033 |
] ifFalse:[ |
|
1034 |
('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR |
|
1035 |
]. |
|
1036 |
||
1037 |
"/ |
|
1038 |
"/ not found - unload |
|
1039 |
"/ |
|
1040 |
self unloadDynamicObject:handle. |
|
1041 |
^ nil |
|
1042 |
] |
|
174 | 1043 |
]. |
1044 |
||
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1045 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1046 |
"/ call it - it returns the new method object |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1047 |
"/ |
174 | 1048 |
m := self |
634 | 1049 |
callInitFunctionAt:initAddr |
1050 |
specialInit:true |
|
1051 |
forceOld:true |
|
1052 |
interruptable:false |
|
1053 |
argument:2 |
|
1054 |
identifyAs:handle |
|
1055 |
returnsObject:true. |
|
174 | 1056 |
|
1057 |
handle method:m. |
|
1058 |
^ handle |
|
1059 |
||
1060 |
"Created: 5.12.1995 / 20:59:46 / cg" |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1061 |
"Modified: 10.1.1997 / 17:58:15 / cg" |
174 | 1062 |
! |
1063 |
||
141 | 1064 |
loadObjectFile:aFileName |
1065 |
"load an object file (.o-file) into the image; |
|
1066 |
the class name is not needed (multiple definitions may be in the file). |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1067 |
This may be either a smalltalk object or a C-object file. |
472 | 1068 |
The object files init function (if any) is called, and the module |
1069 |
is unloaded if it returns failure (use lowLevel load, to load a file |
|
1070 |
without automatic initialization). |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1071 |
Return nil on error, an objectFile handle if ok." |
141 | 1072 |
|
346 | 1073 |
|handle initAddr className initNames didInit info status |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1074 |
dummyHandle msg isCModule| |
141 | 1075 |
|
1076 |
handle := self loadDynamicObject:aFileName. |
|
1077 |
handle isNil ifTrue:[ |
|
524 | 1078 |
Transcript showCR:('failed to load: ' , aFileName). |
1079 |
('ObjectFileLoader [warning]: ' |
|
1080 |
, aFileName |
|
1081 |
, ' failed. (' |
|
1082 |
, LinkErrorMessage |
|
1083 |
, ')') errorPrintCR. |
|
634 | 1084 |
^ nil |
141 | 1085 |
]. |
1086 |
||
1087 |
didInit := false. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1088 |
isCModule := false. |
141 | 1089 |
|
1090 |
"/ with dld, load may have worked, even if undefined symbols |
|
1091 |
"/ are to be resolved. If thats the case, load all libraries ... |
|
1092 |
||
1093 |
SearchedLibraries notNil ifTrue:[ |
|
634 | 1094 |
(self hasUndefinedSymbolsIn:handle) ifTrue:[ |
1095 |
self initializeLoader. |
|
1096 |
||
1097 |
SearchedLibraries do:[:libName | |
|
1098 |
(self hasUndefinedSymbolsIn:handle) ifTrue:[ |
|
1099 |
Transcript showCR:' ... trying ' , libName , ' to resolve undefined symbols ...'. |
|
1100 |
dummyHandle := Array new:4. |
|
1101 |
dummyHandle := self primLoadDynamicObject:libName into:dummyHandle. |
|
228
be9939d96cfe
removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents:
227
diff
changeset
|
1102 |
"/ dummyHandle isNil ifTrue:[ |
272 | 1103 |
"/ Transcript showCR:' ... load of library ' , libName , ' failed.'. |
228
be9939d96cfe
removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents:
227
diff
changeset
|
1104 |
"/ ] |
634 | 1105 |
] |
1106 |
]. |
|
1107 |
(self hasUndefinedSymbolsIn:handle) isNil ifTrue:[ |
|
1108 |
Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.'). |
|
1109 |
]. |
|
1110 |
] |
|
141 | 1111 |
]. |
1112 |
||
1113 |
" |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1114 |
first, expect the classes-name to be the fileNames-baseName |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1115 |
(if its not, it may be a method or function module; |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1116 |
in this case, the Init function is supposed to use that naming |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1117 |
scheme as well) |
141 | 1118 |
" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1119 |
className := self initFunctionBasenameForFile:aFileName. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1120 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1121 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1122 |
"/ look for explicit init (xxx_Init) function |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1123 |
"/ This is used in ST object files |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1124 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1125 |
initAddr := self findInitFunction:className in:handle. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1126 |
|
141 | 1127 |
initAddr notNil ifTrue:[ |
634 | 1128 |
Verbose ifTrue:[ |
1129 |
('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR. |
|
1130 |
]. |
|
1131 |
info := self performModuleInitAt:initAddr for:nil identifyAs:handle. |
|
1132 |
status := info at:1. |
|
1133 |
status == #ok ifTrue:[ |
|
1134 |
didInit := true. |
|
1135 |
] |
|
141 | 1136 |
] ifFalse:[ |
634 | 1137 |
"/ |
1138 |
"/ look for explicit C-init (xxx__Init) function |
|
1139 |
"/ This is used in C object files |
|
1140 |
"/ |
|
1141 |
initAddr := self findFunction:className suffix:'__Init' in:handle. |
|
1142 |
initAddr notNil ifTrue:[ |
|
1143 |
isCModule := true. |
|
1144 |
(self callInitFunctionAt:initAddr |
|
1145 |
specialInit:false |
|
1146 |
forceOld:true |
|
1147 |
interruptable:false |
|
1148 |
argument:0 |
|
1149 |
identifyAs:handle |
|
1150 |
returnsObject:false) < 0 ifTrue:[ |
|
1151 |
||
1152 |
Verbose ifTrue:[ |
|
1153 |
'init function return failure ... unload' infoPrintCR. |
|
1154 |
]. |
|
1155 |
status := #initFailed. |
|
1156 |
] ifFalse:[ |
|
1157 |
didInit := true. |
|
1158 |
] |
|
1159 |
] ifFalse:[ |
|
1160 |
status := #noInitFunction. |
|
1161 |
||
1162 |
" |
|
1163 |
look for any init-function(s); call them all |
|
1164 |
" |
|
1165 |
Verbose ifTrue:[ |
|
1166 |
'no good init functions found; looking for candidates ...' infoPrintCR. |
|
1167 |
]. |
|
1168 |
initNames := self namesMatching:'*_Init' segment:'[tT?]' in:aFileName. |
|
1169 |
initNames notNil ifTrue:[ |
|
1170 |
initNames do:[:aName | |
|
1171 |
initAddr := self getFunction:aName from:handle. |
|
1172 |
initAddr isNil ifTrue:[ |
|
1173 |
(aName startsWith:'_') ifTrue:[ |
|
1174 |
initAddr := self getFunction:(aName copyFrom:2) from:handle. |
|
1175 |
]. |
|
1176 |
]. |
|
1177 |
initAddr isNil ifTrue:[ |
|
1178 |
Transcript showCR:('no symbol: ',aName,' in ',aFileName). |
|
1179 |
] ifFalse:[ |
|
1180 |
Verbose ifTrue:[ |
|
1181 |
('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR |
|
1182 |
]. |
|
1183 |
self performModuleInitAt:initAddr for:nil identifyAs:handle. |
|
1184 |
didInit := true. |
|
1185 |
] |
|
1186 |
]. |
|
1187 |
]. |
|
1188 |
] |
|
141 | 1189 |
]. |
1190 |
||
1191 |
didInit ifFalse:[ |
|
634 | 1192 |
status == #noInitFunction ifTrue:[ |
1193 |
msg := 'LOADER: no init function; assume load ok' |
|
1194 |
] ifFalse:[ |
|
1195 |
||
1196 |
status == #registrationFailed ifTrue:[ |
|
1197 |
Transcript showCR:'LOADER:incompatible object (recompile without commonSymbols ?)' |
|
1198 |
]. |
|
1199 |
status ~~ #initFailed ifTrue:[ |
|
1200 |
self listUndefinedSymbolsIn:handle. |
|
1201 |
]. |
|
1202 |
||
1203 |
Verbose ifTrue:[ |
|
1204 |
'unloading, since init failed ...' infoPrintCR. |
|
1205 |
]. |
|
1206 |
self unloadDynamicObject:handle. |
|
1207 |
handle := nil. |
|
1208 |
||
1209 |
status == #initFailed ifTrue:[ |
|
1210 |
msg := 'LOADER: module not loaded (init function signalled failure).' |
|
1211 |
] ifFalse:[ |
|
1212 |
(self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:aFileName) notNil ifTrue:[ |
|
1213 |
msg := 'LOADER: module not loaded (no _Init entry - looks like an incomplete sepInitCode object).' |
|
1214 |
] ifFalse:[ |
|
1215 |
msg := 'LOADER: module not loaded (no _Init entry in object file ?).' |
|
1216 |
]. |
|
1217 |
]. |
|
1218 |
]. |
|
1219 |
Transcript showCR:msg |
|
141 | 1220 |
]. |
1221 |
||
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1222 |
isCModule ifFalse:[ |
634 | 1223 |
Smalltalk isInitialized ifTrue:[ |
1224 |
" |
|
1225 |
really dont know, if it has changed ... |
|
1226 |
" |
|
1227 |
Smalltalk changed. |
|
1228 |
] |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
1229 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1230 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1231 |
|
472 | 1232 |
"Modified: 8.1.1997 / 18:28:12 / cg" |
141 | 1233 |
! |
1234 |
||
1235 |
unloadAllObsoleteObjectFiles |
|
1236 |
"unload all dynamically loaded object files for which the classes/method |
|
1237 |
has been already garbage collected." |
|
1238 |
||
1239 |
LoadedObjects notNil ifTrue:[ |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1240 |
LoadedObjects keys copy do:[:name | |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1241 |
|handle| |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1242 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1243 |
handle := LoadedObjects at:name ifAbsent:nil. |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1244 |
(handle notNil and:[handle isObsolete]) ifTrue:[ |
141 | 1245 |
self unloadObjectFile:name |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1246 |
] |
141 | 1247 |
] |
1248 |
]. |
|
1249 |
||
1250 |
" |
|
1251 |
ObjectFileLoader unloadAllObsoleteObjectFiles |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1252 |
" |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1253 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1254 |
"Modified: 5.12.1995 / 18:16:52 / cg" |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1255 |
! |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1256 |
|
141 | 1257 |
unloadObjectFile:aFileName |
1258 |
"unload an object file (.o-file) from the image. |
|
1259 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1260 |
objects of this module exist - in future versions, the system will keep |
|
1261 |
track of these. For now, use at your own risk. |
|
1262 |
(especially critical are blocks-functions)." |
|
1263 |
||
1264 |
|handle| |
|
1265 |
||
1266 |
LoadedObjects notNil ifTrue:[ |
|
153 | 1267 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
141 | 1268 |
]. |
1269 |
handle isNil ifTrue:[ |
|
153 | 1270 |
'OBJFLOADER: oops file to be unloaded was not loaded dynamically (', aFileName , ')'. |
141 | 1271 |
^ self |
1272 |
]. |
|
1273 |
||
1274 |
"/ call the modules deInit-function ... |
|
1275 |
||
1276 |
"/ unload ... |
|
1277 |
||
1278 |
self unloadDynamicObject:handle |
|
634 | 1279 |
! |
1280 |
||
1281 |
unloadObjectFileAndRemoveClasses:aFileName |
|
1282 |
"unload an object file (.o-file) from the image and remove all |
|
1283 |
corresponding classes from the system. |
|
1284 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1285 |
objects of this module exist - in future versions, the system will keep |
|
1286 |
track of these. For now, use at your own risk. |
|
1287 |
(especially critical are blocks-functions)." |
|
1288 |
||
1289 |
|handle| |
|
1290 |
||
1291 |
LoadedObjects notNil ifTrue:[ |
|
1292 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
|
1293 |
]. |
|
1294 |
handle isNil ifTrue:[ |
|
1295 |
'OBJFLOADER: oops file to be unloaded was not loaded dynamically (', aFileName , ')'. |
|
1296 |
^ self |
|
1297 |
]. |
|
1298 |
handle isClassLibHandle ifFalse:[ |
|
1299 |
self warn:'module is not a classLib module'. |
|
1300 |
^ self |
|
1301 |
]. |
|
1302 |
||
1303 |
"/ remove the classes ... |
|
1304 |
||
1305 |
Class withoutUpdatingChangesDo:[ |
|
1306 |
handle classes do:[:aClass | |
|
1307 |
aClass isMeta ifFalse:[ |
|
638 | 1308 |
aClass removeFromSystem |
634 | 1309 |
] |
1310 |
] |
|
1311 |
]. |
|
1312 |
||
1313 |
"/ call the modules deInit-function ... |
|
1314 |
||
1315 |
"/ unload ... |
|
1316 |
||
1317 |
self unloadDynamicObject:handle |
|
1318 |
||
1319 |
"Modified: / 12.12.1997 / 22:12:28 / cg" |
|
141 | 1320 |
! ! |
1321 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1322 |
!ObjectFileLoader class methodsFor:'dynamic object queries'! |
141 | 1323 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1324 |
findFunction:functionName suffix:suffix in:handle |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1325 |
"look for the init function and returns its address" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1326 |
|
609 | 1327 |
|initAddr className nm| |
1328 |
||
1329 |
"/ care for colons, as found in nameSpace classes ... |
|
747 | 1330 |
nm := functionName asString copyReplaceAll:$: with:$_. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1331 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1332 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1333 |
look for explicit init function |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1334 |
" |
609 | 1335 |
initAddr := self getFunction:(nm , suffix) from:handle. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1336 |
initAddr notNil ifTrue:[^ initAddr]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1337 |
|
609 | 1338 |
initAddr := self getFunction:('_' , nm , suffix) from:handle. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1339 |
initAddr notNil ifTrue:[^ initAddr]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1340 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1341 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1342 |
"/ special for broken ultrix nlist |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1343 |
"/ (will not find symbol with single underscore) |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1344 |
"/ workaround: add another underscore and retry |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1345 |
"/ |
609 | 1346 |
initAddr := self getFunction:('__' , nm , suffix) from:handle. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1347 |
initAddr notNil ifTrue:[^ initAddr]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1348 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1349 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1350 |
look for reverse abbreviation |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1351 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1352 |
className := Smalltalk classNameForFile:functionName. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1353 |
className notNil ifTrue:[ |
759 | 1354 |
initAddr := self getFunction:(className , suffix) from:handle. |
1355 |
initAddr notNil ifTrue:[^ initAddr]. |
|
1356 |
||
1357 |
initAddr := self getFunction:('_' , className , suffix) from:handle. |
|
1358 |
initAddr isNil ifTrue:[ |
|
1359 |
"/ |
|
1360 |
"/ special for broken ultrix nlist |
|
1361 |
"/ (will not find symbol with single underscore) |
|
1362 |
"/ workaround: add another underscore and retry |
|
1363 |
"/ |
|
1364 |
initAddr := self getFunction:('__' , className , suffix) from:handle. |
|
1365 |
]. |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1366 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1367 |
^ initAddr |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1368 |
|
747 | 1369 |
"Created: / 13.7.1996 / 00:38:01 / cg" |
1370 |
"Modified: / 18.7.1998 / 22:59:12 / cg" |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1371 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1372 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1373 |
findInitFunction:functionName in:handle |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1374 |
"look for the init function and returns its address" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1375 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1376 |
^ self findFunction:functionName suffix:'_Init' in:handle |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1377 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1378 |
"Modified: 13.7.1996 / 00:38:33 / cg" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1379 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1380 |
|
141 | 1381 |
getFunction:aString from:handle |
1382 |
"return the address of a function from a dynamically loaded object file. |
|
1383 |
Handle must be the one returned previously from loadDynamicObject. |
|
1384 |
Return the address of the function, or nil on any error." |
|
1385 |
||
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1386 |
^ self getSymbol:aString function:true from:handle |
141 | 1387 |
! |
1388 |
||
1389 |
getListOfUndefinedSymbolsFrom:aHandle |
|
1390 |
"return a collection of undefined symbols in a dynamically loaded object file. |
|
1391 |
Handle must be the one returned previously from loadDynamicObject. |
|
1392 |
Not all systems allow an object with undefined symbols to be |
|
1393 |
loaded (actually, only dld does)." |
|
1394 |
||
1395 |
|list| |
|
1396 |
||
1397 |
%{ /* STACK: 20000 */ |
|
1398 |
#ifdef GNU_DL |
|
1399 |
void (*func)(); |
|
1400 |
unsigned long addr; |
|
1401 |
char *name; |
|
1402 |
int nMax; |
|
1403 |
char **undefNames; |
|
1404 |
||
1405 |
undefNames = dld_list_undefined_sym(); |
|
1406 |
if (dld_undefined_sym_count > 0) { |
|
1407 |
char **nm; |
|
1408 |
int index; |
|
1409 |
int count = dld_undefined_sym_count; |
|
1410 |
||
1411 |
if (count > 100) count = 100; |
|
1412 |
list = __ARRAY_NEW_INT(count); |
|
1413 |
if (list) { |
|
1414 |
nm = undefNames; |
|
1415 |
for (index = 0; index < count; index++) { |
|
1416 |
OBJ s; |
|
1417 |
||
238 | 1418 |
s = __MKSTRING(*nm); |
1419 |
__ArrayInstPtr(list)->a_element[index] = s; |
|
141 | 1420 |
__STORE(list, s); |
1421 |
nm++; |
|
1422 |
} |
|
1423 |
free(undefNames); |
|
1424 |
} |
|
1425 |
} |
|
1426 |
#endif |
|
1427 |
||
1428 |
#ifdef DL1_6 |
|
1429 |
/* |
|
1430 |
* dont know how to do it |
|
1431 |
*/ |
|
1432 |
#endif |
|
1433 |
||
1434 |
#ifdef SYSV4_DL |
|
1435 |
/* |
|
1436 |
* dont know how to do it |
|
1437 |
*/ |
|
1438 |
#endif |
|
1439 |
||
1440 |
#ifdef SUN_DL |
|
1441 |
/* |
|
1442 |
* dont know how to do it |
|
1443 |
*/ |
|
1444 |
#endif |
|
1445 |
||
1446 |
#ifdef NEXT_DL |
|
1447 |
/* |
|
1448 |
* dont know how to do it |
|
1449 |
*/ |
|
1450 |
#endif |
|
180 | 1451 |
|
1452 |
#ifdef WIN_DL |
|
1453 |
/* |
|
1454 |
* dont know how to do it |
|
1455 |
*/ |
|
1456 |
#endif |
|
1457 |
||
141 | 1458 |
%}. |
1459 |
^ list |
|
1460 |
! |
|
1461 |
||
1462 |
getSymbol:aString function:isFunction from:aHandle |
|
1463 |
"return the address of a symbol/function from a dynamically loaded object file. |
|
1464 |
Handle must be the one returned previously from loadDynamicObject. |
|
1465 |
Return the address of the symbol, or nil on any error." |
|
1466 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1467 |
|sysHandle1 sysHandle2 pathName address| |
141 | 1468 |
|
1469 |
sysHandle1 := aHandle sysHandle1. |
|
1470 |
sysHandle2 := aHandle sysHandle2. |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1471 |
pathName := aHandle pathName. |
141 | 1472 |
|
1473 |
%{ /* STACK: 20000 */ |
|
1474 |
||
1475 |
#ifdef GNU_DL |
|
1476 |
{ |
|
1477 |
void (*func)(); |
|
1478 |
unsigned long addr; |
|
1479 |
char *name; |
|
1480 |
||
1481 |
if (__isString(aString)) { |
|
1482 |
name = (char *) __stringVal(aString); |
|
1483 |
if (isFunction == false) { |
|
1484 |
addr = dld_get_symbol(name); |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1485 |
if (addr) { |
592 | 1486 |
if (@global(Verbose) == true) { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1487 |
printf("addr of %s = %x\n", name, addr); |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1488 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1489 |
address = __MKUINT( addr ); |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1490 |
} |
141 | 1491 |
} else { |
1492 |
func = (void (*) ()) dld_get_func(name); |
|
1493 |
if (func) { |
|
592 | 1494 |
if (@global(Verbose) == true) { |
141 | 1495 |
printf("addr of %s = %x\n", name, (INT)func); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1496 |
} |
141 | 1497 |
if (dld_function_executable_p(name)) { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1498 |
address = __MKUINT( (INT)func ); |
141 | 1499 |
} else { |
1500 |
char **undefNames; |
|
1501 |
char **nm; |
|
1502 |
int i; |
|
1503 |
||
592 | 1504 |
if (@global(Verbose) == true) { |
141 | 1505 |
printf ("function %s not executable\n", name); |
1506 |
dld_perror("not executable"); |
|
1507 |
||
1508 |
printf("undefined:\n"); |
|
1509 |
nm = undefNames = dld_list_undefined_sym(); |
|
1510 |
for (i=dld_undefined_sym_count; i; i--) { |
|
1511 |
printf(" %s\n", *nm++); |
|
1512 |
} |
|
1513 |
free(undefNames); |
|
1514 |
} |
|
1515 |
} |
|
1516 |
} else { |
|
592 | 1517 |
if (@global(Verbose) == true) { |
141 | 1518 |
printf ("function %s not found\n", name); |
1519 |
dld_perror("get_func"); |
|
1520 |
} |
|
1521 |
} |
|
1522 |
} |
|
1523 |
} |
|
1524 |
} |
|
1525 |
#endif /* GNU_DL */ |
|
1526 |
||
180 | 1527 |
#ifdef WIN_DL |
1528 |
{ |
|
1529 |
void *h; |
|
1530 |
void *addr; |
|
701 | 1531 |
INT val; |
180 | 1532 |
FARPROC entry; |
1533 |
HMODULE handle; |
|
1534 |
||
1535 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1536 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1537 |
handle = (HMODULE)(val); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1538 |
if (__isString(aString)) { |
592 | 1539 |
if (@global(Verbose) == true) |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1540 |
printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1541 |
entry = GetProcAddress(handle, (char *) __stringVal(aString)); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1542 |
if (entry != NULL) { |
180 | 1543 |
addr = (void *)entry; |
592 | 1544 |
if (@global(Verbose) == true) { |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1545 |
printf("GetProcAddr %s ok; addr = %x\n", __stringVal(aString), addr); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1546 |
} |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1547 |
address = __MKUINT( (int)addr ); |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1548 |
} else { |
592 | 1549 |
if (@global(Verbose) == true) { |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1550 |
printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError()); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1551 |
} |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1552 |
} |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1553 |
} |
180 | 1554 |
} |
1555 |
} |
|
1556 |
#endif |
|
1557 |
||
141 | 1558 |
#ifdef DL1_6 |
1559 |
{ |
|
1560 |
void *h; |
|
1561 |
void *addr; |
|
701 | 1562 |
INT val; |
141 | 1563 |
|
1564 |
if (__isString(aString)) { |
|
1565 |
if (__isString(sysHandle1)) { |
|
592 | 1566 |
if (@global(Verbose) == true) |
141 | 1567 |
printf("get sym <%s> handle = %x\n", |
1568 |
__stringVal(aString), __stringVal(sysHandle1)); |
|
1569 |
addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString)); |
|
1570 |
if (addr) { |
|
592 | 1571 |
if (@global(Verbose) == true) |
141 | 1572 |
printf("addr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1573 |
address = __MKUINT( (int)addr ); |
141 | 1574 |
} else { |
592 | 1575 |
if (@global(Verbose) == true) |
141 | 1576 |
printf("dl_getsymbol %s failed\n", __stringVal(aString)); |
1577 |
} |
|
1578 |
} |
|
1579 |
} |
|
1580 |
} |
|
1581 |
#endif |
|
1582 |
||
1583 |
#ifdef SYSV4_DL |
|
1584 |
{ |
|
1585 |
void *h; |
|
1586 |
void *addr; |
|
701 | 1587 |
INT val; |
141 | 1588 |
OBJ low = sysHandle1, hi = sysHandle2; |
701 | 1589 |
extern void *dlsym(); |
141 | 1590 |
|
1591 |
if (__bothSmallInteger(low, hi)) { |
|
701 | 1592 |
#ifdef alpha64 |
1593 |
val = (__intVal(hi) << 32) + __intVal(low); |
|
1594 |
#else |
|
1595 |
val = (__intVal(hi) << 16) + __intVal(low); |
|
1596 |
#endif |
|
141 | 1597 |
h = (void *)(val); |
1598 |
if (__isString(aString)) { |
|
592 | 1599 |
if (@global(Verbose) == true) { |
141 | 1600 |
printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1601 |
} |
141 | 1602 |
addr = dlsym(h, (char *) __stringVal(aString)); |
1603 |
if (addr) { |
|
592 | 1604 |
if (@global(Verbose) == true) { |
141 | 1605 |
printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr); |
1606 |
} |
|
701 | 1607 |
address = __MKUINT( (INT)addr ); |
141 | 1608 |
} else { |
592 | 1609 |
if (@global(Verbose) == true) { |
141 | 1610 |
printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
1611 |
} |
|
1612 |
} |
|
1613 |
} |
|
1614 |
} |
|
1615 |
} |
|
1616 |
#endif |
|
1617 |
||
523 | 1618 |
#ifdef HPUX10_DL |
1619 |
{ |
|
1620 |
void *h; |
|
1621 |
void *addr; |
|
701 | 1622 |
INT val, ret; |
523 | 1623 |
OBJ low = sysHandle1, hi = sysHandle2; |
1624 |
||
1625 |
if (__bothSmallInteger(low, hi)) { |
|
1626 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
1627 |
h = (void *)(val); |
|
1628 |
if (__isString(aString)) { |
|
592 | 1629 |
if (@global(Verbose) == true) { |
523 | 1630 |
printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
1631 |
} |
|
1632 |
ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr); |
|
1633 |
if (ret != 0) { |
|
592 | 1634 |
if (@global(Verbose) == true) { |
523 | 1635 |
printf("dlsym %s error\n", __stringVal(aString)); |
1636 |
} |
|
1637 |
} else { |
|
592 | 1638 |
if (@global(Verbose) == true) { |
523 | 1639 |
printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr); |
1640 |
} |
|
701 | 1641 |
address = __MKUINT( (INT)addr ); |
523 | 1642 |
} |
1643 |
} |
|
1644 |
} |
|
1645 |
} |
|
1646 |
#endif |
|
1647 |
||
1648 |
||
141 | 1649 |
#ifdef AIX_DL |
1650 |
{ |
|
1651 |
void *h; |
|
1652 |
void *addr; |
|
1653 |
int val; |
|
1654 |
struct nlist nl[2]; |
|
1655 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1656 |
char nameBuffer[256]; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1657 |
static struct funcDescriptor { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1658 |
unsigned vaddr; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1659 |
unsigned long2; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1660 |
unsigned long3; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1661 |
} descriptor; |
141 | 1662 |
|
1663 |
if (__bothSmallInteger(low, hi) |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1664 |
&& __isString(aString) && __isString(pathName)) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1665 |
val = (__intVal(hi) << 16) + __intVal(low); |
141 | 1666 |
h = (void *)(val); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1667 |
|
592 | 1668 |
if (@global(Verbose) == true) { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1669 |
printf("get sym <%s> handle = %x path= %s\n", |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1670 |
__stringVal(aString), h, __stringVal(pathName)); |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1671 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1672 |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1673 |
#define USE_ENTRY |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1674 |
#ifdef USE_ENTRY |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1675 |
/* |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1676 |
* only works, if the entry-function is the Init function |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1677 |
* (i.e. linked with -e _xxx_Init) |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1678 |
*/ |
592 | 1679 |
if (@global(Verbose) == true) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1680 |
printf("return handle as addr = %x\n", h); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1681 |
} |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1682 |
address = __MKUINT( (int)(h) ); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1683 |
#else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1684 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1685 |
# ifdef USE_DESCRIPTOR |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1686 |
if (isFunction == true) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1687 |
# else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1688 |
if (0) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1689 |
# endif |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1690 |
nameBuffer[0] = '.'; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1691 |
strcpy(nameBuffer+1, aString); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1692 |
nl[0].n_name = nameBuffer; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1693 |
} else { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1694 |
nl[0].n_name = __stringVal(aString); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1695 |
} |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1696 |
nl[1].n_name = ""; |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1697 |
|
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1698 |
if (nlist(__stringVal(pathName), &nl) == -1) { |
592 | 1699 |
if (@global(Verbose) == true) { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1700 |
printf("nlist error\n"); |
141 | 1701 |
} |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1702 |
} else { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1703 |
addr = (void *)((unsigned)nl[0].n_value + (unsigned)h); |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1704 |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1705 |
if (isFunction == true) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1706 |
# ifdef USE_DESCRIPTOR |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1707 |
printf("daddr = %x\n", addr); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1708 |
printf("daddr[0] = %x\n", ((long *)addr)[0]); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1709 |
printf("daddr[1] = %x\n", ((long *)addr)[1]); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1710 |
printf("daddr[2] = %x\n", ((long *)addr)[2]); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1711 |
# endif |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1712 |
} |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1713 |
|
592 | 1714 |
if (@global(Verbose) == true) { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1715 |
printf("value=%x section=%d type=%x sclass=%d\n", |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1716 |
nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1717 |
printf("vaddr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1718 |
} |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1719 |
# ifdef DOES_NOT_WORK |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1720 |
address = __MKUINT( (int)addr ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1721 |
# else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1722 |
descriptor.vaddr = (unsigned) addr; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1723 |
descriptor.long2 = 0; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1724 |
descriptor.long3 = 0; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1725 |
address = __MKUINT( (int)(&descriptor) ); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1726 |
# endif |
141 | 1727 |
} |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1728 |
#endif /* dont USE_ENTRY */ |
141 | 1729 |
} |
1730 |
} |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1731 |
#endif /* AIX_DL */ |
141 | 1732 |
|
523 | 1733 |
|
141 | 1734 |
#ifdef SUN_DL |
1735 |
{ |
|
1736 |
void *h; |
|
1737 |
void *addr; |
|
1738 |
int val; |
|
1739 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
1740 |
||
1741 |
if (__bothSmallInteger(low, hi)) { |
|
1742 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
1743 |
h = (void *)(val); |
|
1744 |
if (__isString(aString)) { |
|
592 | 1745 |
if (@global(Verbose) == true) { |
141 | 1746 |
printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1747 |
} |
141 | 1748 |
addr = dlsym(h, __stringVal(aString)); |
1749 |
if (addr) { |
|
592 | 1750 |
if (@global(Verbose) == true) { |
141 | 1751 |
printf("addr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1752 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1753 |
address = __MKUINT( (int)addr ); |
141 | 1754 |
} else { |
592 | 1755 |
if (@global(Verbose) == true) { |
141 | 1756 |
printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1757 |
} |
141 | 1758 |
} |
1759 |
} |
|
1760 |
} |
|
1761 |
} |
|
1762 |
#endif |
|
1763 |
||
523 | 1764 |
|
141 | 1765 |
#ifdef NEXT_DL |
1766 |
{ |
|
1767 |
unsigned long addr; |
|
1768 |
long result; |
|
1769 |
NXStream *errOut; |
|
1770 |
||
1771 |
if (__isString(aString)) { |
|
592 | 1772 |
if (@global(Verbose) == true) { |
141 | 1773 |
printf("get sym <%s>\n", __stringVal(aString)); |
468 | 1774 |
} |
141 | 1775 |
errOut = NXOpenFile(2, 2); |
1776 |
result = rld_lookup(errOut, |
|
1777 |
(char *) __stringVal(aString), |
|
1778 |
&addr); |
|
1779 |
NXClose(errOut); |
|
1780 |
if (result) { |
|
592 | 1781 |
if (@global(Verbose) == true) { |
141 | 1782 |
printf("addr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1783 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1784 |
address = __MKUINT( (int)addr ); |
141 | 1785 |
} |
1786 |
} |
|
1787 |
} |
|
1788 |
#endif |
|
180 | 1789 |
|
141 | 1790 |
%}. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1791 |
^ address |
141 | 1792 |
! |
1793 |
||
1794 |
hasUndefinedSymbolsIn:handle |
|
259 | 1795 |
"return true, if a module has undefined symbols in it. |
1796 |
This is only possible if the system supports loading |
|
1797 |
modules with undefined things in it - most do not" |
|
1798 |
||
141 | 1799 |
^ (self getListOfUndefinedSymbolsFrom:handle) size > 0 |
259 | 1800 |
|
1801 |
"Modified: 25.4.1996 / 09:47:27 / cg" |
|
141 | 1802 |
! |
1803 |
||
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1804 |
initFunctionBasenameForFile:aFileName |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1805 |
"return the expected initFunctions name, given a fileName" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1806 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1807 |
|name suffixLen| |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1808 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1809 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1810 |
first, expect the classes-name to be the fileName-base |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1811 |
" |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1812 |
name := aFileName asFilename. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1813 |
suffixLen := 0. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1814 |
self validBinaryExtensions do:[:suffix | |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1815 |
suffixLen == 0 ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1816 |
(name hasSuffix:suffix) ifTrue:[ |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1817 |
suffixLen := suffix size + 1 |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1818 |
] |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1819 |
] |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1820 |
]. |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1821 |
name := name baseName. |
403 | 1822 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1823 |
suffixLen ~~ 0 ifTrue:[ |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1824 |
name := name copyWithoutLast:suffixLen |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1825 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1826 |
^ name. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1827 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1828 |
" |
514 | 1829 |
ObjectFileLoader initFunctionBasenameForFile:'libbasic.so' |
1830 |
ObjectFileLoader initFunctionBasenameForFile:'demo.so' |
|
1831 |
ObjectFileLoader initFunctionBasenameForFile:'demo.o' |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1832 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1833 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1834 |
"Created: / 13.7.1996 / 00:01:54 / cg" |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1835 |
"Modified: / 1.10.1998 / 12:47:50 / cg" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1836 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1837 |
|
141 | 1838 |
isCPlusPlusObject:handle |
259 | 1839 |
"return true, if the loaded object is a c++ object module. |
1840 |
This is not yet fully implemented/supported." |
|
141 | 1841 |
|
1842 |
(self getSymbol:'__gnu_compiled_cplusplus' function:true from:handle) notNil ifTrue:[^ true]. |
|
1843 |
(self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true]. |
|
1844 |
(self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true]. |
|
1845 |
(self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true]. |
|
6 | 1846 |
^ false |
259 | 1847 |
|
1848 |
"Modified: 25.4.1996 / 09:48:19 / cg" |
|
0 | 1849 |
! |
1850 |
||
141 | 1851 |
isObjectiveCObject:handle |
259 | 1852 |
"return true, if the loaded object is an objective-C object module. |
1853 |
This is not yet implemented/supported" |
|
141 | 1854 |
|
1855 |
^ false |
|
259 | 1856 |
|
1857 |
"Modified: 25.4.1996 / 09:47:59 / cg" |
|
141 | 1858 |
! |
1859 |
||
1860 |
isSmalltalkObject:handle |
|
1861 |
"return true, if the loaded object is a smalltalk object module" |
|
1862 |
||
1863 |
"not yet implemented - stc_compiled_smalltalk is a static symbol, |
|
1864 |
not found in list - need nm-interface, or nlist-walker |
|
1865 |
" |
|
1866 |
^ true. |
|
1867 |
||
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
1868 |
"/ (self getSymbol:'__stc_compiled_smalltalk' function:true from:handle) notNil ifTrue:[^ true]. |
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
1869 |
"/ (self getSymbol:'__stc_compiled_smalltalk' function:false from:handle) notNil ifTrue:[^ true]. |
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
1870 |
"/ ^ false |
141 | 1871 |
! |
1872 |
||
1873 |
listUndefinedSymbolsIn:handle |
|
259 | 1874 |
"list undefined objects in a module on the transcript" |
1875 |
||
141 | 1876 |
|undefinedNames| |
1877 |
||
1878 |
undefinedNames := self getListOfUndefinedSymbolsFrom:handle. |
|
1879 |
undefinedNames size > 0 ifTrue:[ |
|
468 | 1880 |
Transcript showCR:'undefined:'. |
1881 |
undefinedNames do:[:aName | |
|
1882 |
Transcript showCR:' ' , aName |
|
1883 |
] |
|
141 | 1884 |
]. |
259 | 1885 |
|
272 | 1886 |
"Modified: 18.5.1996 / 15:43:45 / cg" |
141 | 1887 |
! |
1888 |
||
1889 |
namesMatching:aPattern segment:segmentPattern in:aFileName |
|
521 | 1890 |
"search for entries which match a pattern. |
1891 |
This is obsolete & rubbish - it will vanish soon" |
|
141 | 1892 |
|
1893 |
|p l s addr segment name entry| |
|
1894 |
||
766 | 1895 |
OperatingSystem isVMSlike ifTrue:[ |
1896 |
"/ no nm command |
|
1897 |
^ nil |
|
1898 |
]. |
|
1899 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
759 | 1900 |
"/ no nm command |
1901 |
^ nil |
|
609 | 1902 |
]. |
521 | 1903 |
OperatingSystem getOSType = 'aix' ifTrue:[ |
759 | 1904 |
"/ no useful nm info |
1905 |
^ nil |
|
749 | 1906 |
]. |
141 | 1907 |
|
1908 |
l := OrderedCollection new. |
|
1909 |
p := PipeStream readingFrom:(self nm:aFileName). |
|
1910 |
p isNil ifTrue:[ |
|
759 | 1911 |
('ObjectFileLoader [info]: cannot read names from ' , aFileName) infoPrintCR. |
1912 |
^ nil |
|
141 | 1913 |
]. |
1914 |
[p atEnd] whileFalse:[ |
|
759 | 1915 |
entry := p nextLine. |
1916 |
Verbose ifTrue:[ |
|
1917 |
entry infoPrintCR. |
|
1918 |
]. |
|
1919 |
entry notNil ifTrue:[ |
|
1920 |
s := ReadStream on:entry. |
|
1921 |
addr := s nextAlphaNumericWord. |
|
1922 |
segment := s nextAlphaNumericWord. |
|
1923 |
name := s upToEnd withoutSeparators. |
|
1924 |
(addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[ |
|
1925 |
(aPattern match:name) ifTrue:[ |
|
1926 |
(segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[ |
|
1927 |
l add:name. |
|
1928 |
Verbose ifTrue:[ |
|
1929 |
('found name: ' , name) infoPrintCR. |
|
1930 |
] |
|
1931 |
] ifFalse:[ |
|
1932 |
Verbose ifTrue:[ |
|
1933 |
name infoPrint. ' segment mismatch ' infoPrint. |
|
1934 |
segmentPattern infoPrint. ' ' infoPrint. segment infoPrintCR. |
|
1935 |
] |
|
1936 |
] |
|
1937 |
] |
|
1938 |
] |
|
1939 |
] |
|
0 | 1940 |
]. |
141 | 1941 |
p close. |
1942 |
^ l |
|
225 | 1943 |
|
749 | 1944 |
"Modified: / 27.7.1998 / 20:10:57 / cg" |
141 | 1945 |
! |
1946 |
||
1947 |
releaseSymbolTable |
|
1948 |
"this is needed on NeXT to forget loaded names. If this wasnt done, |
|
1949 |
the same class could not be loaded in again due to multiple defines. |
|
1950 |
On other architectures, this is not needed and therefore a noop." |
|
1951 |
||
1952 |
%{ |
|
1953 |
#ifdef NEXT_DL |
|
1954 |
NXStream *errOut; |
|
1955 |
||
1956 |
errOut = NXOpenFile(2, 2); |
|
1957 |
rld_unload_all(errOut, (long)0); |
|
1958 |
rld_load_basefile(errOut, "smalltalk"); |
|
1959 |
NXClose(errOut); |
|
1960 |
#endif |
|
1961 |
%} |
|
303 | 1962 |
! ! |
1963 |
||
369 | 1964 |
!ObjectFileLoader class methodsFor:'image save/restart'! |
303 | 1965 |
|
1966 |
invalidateAndRememberAllObjectFiles |
|
1967 |
"invalidate code refs into all dynamically loaded object files. |
|
1968 |
Required before writing a snapshot image." |
|
1969 |
||
1970 |
LoadedObjects notNil ifTrue:[ |
|
468 | 1971 |
ActuallyLoadedObjects := LoadedObjects. |
1972 |
self rememberAllObjectFiles. |
|
1973 |
ActuallyLoadedObjects keys do:[:aFileName | |
|
1974 |
|handle| |
|
1975 |
||
1976 |
handle := ActuallyLoadedObjects at:aFileName. |
|
1977 |
handle isNil ifTrue:[ |
|
1978 |
self error:'oops, no handle'. |
|
1979 |
] ifFalse:[ |
|
1980 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
1981 |
self invalidateModule:handle |
|
1982 |
] |
|
1983 |
] |
|
1984 |
]. |
|
1985 |
LoadedObjects := nil. |
|
303 | 1986 |
]. |
1987 |
||
1988 |
"Created: 5.10.1995 / 15:48:56 / claus" |
|
1989 |
"Modified: 5.10.1995 / 16:48:51 / claus" |
|
1990 |
"Modified: 12.7.1996 / 17:13:45 / cg" |
|
28 | 1991 |
! |
6 | 1992 |
|
303 | 1993 |
reloadAllRememberedObjectFiles |
1994 |
"reload all object modules as were loaded when the image was saved. |
|
1995 |
Some care has to be taken, if files are missing or otherwise corrupted." |
|
1996 |
||
406
6a4f1e3800af
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
405
diff
changeset
|
1997 |
|oldDummyMethod who m newHandle |
303 | 1998 |
savedOldClasses savedByteCodeMethods savedMethods |
638 | 1999 |
functions newFunction |
2000 |
saveOldMethodsPerClass| |
|
303 | 2001 |
|
2002 |
PreviouslyLoadedObjects notNil ifTrue:[ |
|
741 | 2003 |
PreviouslyLoadedObjects do:[:entry | |
2004 |
|fileName handle cls sel| |
|
2005 |
||
2006 |
fileName := entry key. |
|
2007 |
handle := entry value. |
|
2008 |
handle moduleID:nil. |
|
2009 |
||
2010 |
handle isClassLibHandle ifTrue:[ |
|
2011 |
('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR. |
|
2012 |
||
2013 |
"/ |
|
2014 |
"/ remember all byteCode methods (as added in the session) |
|
2015 |
"/ |
|
2016 |
savedByteCodeMethods := Dictionary new. |
|
2017 |
savedOldClasses := IdentitySet new. |
|
2018 |
saveOldMethodsPerClass := Dictionary new. |
|
2019 |
||
2020 |
handle classes do:[:aClass | |
|
2021 |
|clsName mthdDict| |
|
2022 |
||
2023 |
(aClass notNil and:[aClass ~~ 0]) ifTrue:[ |
|
2024 |
clsName := aClass name. |
|
2025 |
mthdDict := aClass methodDictionary. |
|
2026 |
saveOldMethodsPerClass at:clsName put:mthdDict copy. |
|
2027 |
savedMethods := IdentityDictionary new. |
|
2028 |
savedOldClasses add:aClass. |
|
2029 |
mthdDict keysAndValuesDo:[:sel :m | |
|
2030 |
m byteCode notNil ifTrue:[ |
|
2031 |
"/ an interpreted method - must be preserved |
|
2032 |
savedMethods at:sel put:m |
|
2033 |
] |
|
2034 |
]. |
|
2035 |
savedMethods notEmpty ifTrue:[ |
|
2036 |
savedByteCodeMethods at:clsName put:savedMethods |
|
2037 |
]. |
|
2038 |
] |
|
2039 |
]. |
|
2040 |
"/ |
|
2041 |
"/ load the class binary |
|
2042 |
"/ |
|
2043 |
self loadObjectFile:fileName. |
|
2044 |
||
2045 |
"/ after reloading of the objectFile, |
|
2046 |
"/ some of the changes made in the previous life have to be |
|
2047 |
"/ redone here - otherwise, we will be left with the |
|
2048 |
"/ state contained in the loaded objectModule - instead of |
|
2049 |
"/ what we had when saving the image ... |
|
2050 |
||
2051 |
"/ |
|
2052 |
"/ reinstall the byteCode methods |
|
2053 |
"/ |
|
2054 |
savedByteCodeMethods keysAndValuesDo:[:nm :savedMethods | |
|
2055 |
|cls| |
|
2056 |
||
2057 |
cls := Smalltalk classNamed:nm. |
|
2058 |
savedMethods keysAndValuesDo:[:sel :m | |
|
2059 |
cls primAddSelector:sel withMethod:m. |
|
474 | 2060 |
"/ ('preserved ' , cls name , '>>' , sel) printCR. |
741 | 2061 |
] |
2062 |
]. |
|
2063 |
||
2064 |
"/ |
|
2065 |
"/ re-remove removed methods |
|
2066 |
"/ and re-change method categories |
|
2067 |
"/ |
|
2068 |
savedOldClasses do:[:oldClass | |
|
2069 |
|newClass oldMethods newMethodDict oldMthd newMthd |
|
2070 |
oldCat oldClassVarString oldClassCategory| |
|
2071 |
||
2072 |
newClass := Smalltalk classNamed:(oldClass name). |
|
2073 |
newClass notNil ifTrue:[ |
|
2074 |
oldClassVarString := oldClass classVariableString. |
|
2075 |
newClass classVariableString ~= oldClassVarString ifTrue:[ |
|
2076 |
"/ there is no need to recreate the variable |
|
2077 |
"/ (its in the smalltalk dictionary) |
|
2078 |
newClass setClassVariableString:oldClassVarString |
|
2079 |
]. |
|
2080 |
newClass isMeta ifFalse:[ |
|
2081 |
oldClassCategory := oldClass category. |
|
2082 |
newClass category ~= oldClassCategory ifTrue:[ |
|
2083 |
newClass category:oldClassCategory |
|
2084 |
] |
|
2085 |
]. |
|
2086 |
oldMethods := saveOldMethodsPerClass at:oldClass name. |
|
2087 |
newMethodDict := newClass methodDictionary. |
|
2088 |
newMethodDict keys copy do:[:newSelector | |
|
2089 |
(oldMethods includesKey:newSelector) ifFalse:[ |
|
638 | 2090 |
"/ ('ObjectFileLoader [info]: remove method #' , newSelector , ' from reloaded ' , oldClass name , '.') infoPrintCR. |
741 | 2091 |
newMethodDict removeKey:newSelector |
2092 |
] ifTrue:[ |
|
2093 |
oldMthd := oldMethods at:newSelector. |
|
2094 |
newMthd := newMethodDict at:newSelector. |
|
2095 |
(oldCat := oldMthd category) ~= newMthd category ifTrue:[ |
|
638 | 2096 |
"/ ('ObjectFileLoader [info]: change category of method #' , newSelector , ' in ' , oldClass name , '.') infoPrintCR. |
741 | 2097 |
newMthd category:oldCat |
2098 |
] |
|
2099 |
] |
|
2100 |
] |
|
2101 |
] |
|
2102 |
]. |
|
2103 |
||
2104 |
"/ |
|
2105 |
"/ validate old-classes vs. new classes. |
|
2106 |
"/ and if things look ok, get rid of old stuff |
|
2107 |
"/ and make instances become instances of the new class |
|
2108 |
"/ |
|
638 | 2109 |
"/ ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR. |
2110 |
||
741 | 2111 |
savedOldClasses do:[:oldClass | |
2112 |
|newClass oldCat oldCVars| |
|
2113 |
||
2114 |
newClass := Smalltalk classNamed:(oldClass name). |
|
2115 |
newClass == oldClass ifTrue:[ |
|
474 | 2116 |
"/ ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR. |
741 | 2117 |
] ifFalse:[ |
2118 |
(newClass isNil or:[newClass == oldClass]) ifTrue:[ |
|
2119 |
('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR. |
|
2120 |
] ifFalse:[ |
|
303 | 2121 |
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print. |
2122 |
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR. |
|
2123 |
||
741 | 2124 |
oldClass instSize ~~ newClass instSize ifTrue:[ |
2125 |
('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR. |
|
2126 |
] ifFalse:[ |
|
2127 |
oldClass class instSize ~~ newClass class instSize ifTrue:[ |
|
2128 |
('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR. |
|
2129 |
] ifFalse:[ |
|
638 | 2130 |
"/ ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR. |
741 | 2131 |
(oldCat := oldClass category) ~= newClass category ifTrue:[ |
2132 |
newClass category:oldCat. |
|
2133 |
]. |
|
2134 |
(oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[ |
|
2135 |
newClass setClassVariableString:oldCVars |
|
2136 |
]. |
|
2137 |
oldClass becomeSameAs:newClass |
|
638 | 2138 |
"/ oldClass become:newClass |
741 | 2139 |
] |
2140 |
] |
|
2141 |
] |
|
2142 |
] |
|
2143 |
] |
|
2144 |
||
2145 |
] ifFalse:[ |
|
2146 |
handle isMethodHandle ifTrue:[ |
|
2147 |
oldDummyMethod := handle method. |
|
2148 |
(oldDummyMethod isKindOf:Method) ifFalse:[ |
|
2149 |
('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR |
|
2150 |
] ifTrue:[ |
|
2151 |
('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR. |
|
2152 |
who := oldDummyMethod who. |
|
2153 |
newHandle := self loadMethodObjectFile:fileName. |
|
2154 |
newHandle isNil ifTrue:[ |
|
2155 |
('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR. |
|
2156 |
handle moduleID:nil. |
|
2157 |
] ifFalse:[ |
|
2158 |
m := newHandle method. |
|
2159 |
oldDummyMethod sourceFilename notNil ifTrue:[ |
|
2160 |
m sourceFilename:(oldDummyMethod sourceFilename) |
|
2161 |
position:(oldDummyMethod sourcePosition). |
|
2162 |
] ifFalse:[ |
|
2163 |
m source:(oldDummyMethod source). |
|
2164 |
]. |
|
2165 |
m package:(oldDummyMethod package). |
|
2166 |
who notNil ifTrue:[ |
|
2167 |
cls := who methodClass. |
|
2168 |
sel := who methodSelector. |
|
2169 |
m == (cls compiledMethodAt:sel) ifFalse:[ |
|
2170 |
'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR. |
|
2171 |
] ifTrue:[ |
|
303 | 2172 |
"/ cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod). |
741 | 2173 |
] |
2174 |
]. |
|
2175 |
] |
|
2176 |
] |
|
2177 |
] ifFalse:[ |
|
2178 |
handle isFunctionObjectHandle ifTrue:[ |
|
2179 |
functions := handle functions. |
|
2180 |
functions isEmpty ifTrue:[ |
|
2181 |
('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR |
|
2182 |
] ifFalse:[ |
|
2183 |
newHandle := self loadDynamicObject:fileName. |
|
2184 |
newHandle isNil ifTrue:[ |
|
2185 |
('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR. |
|
2186 |
handle moduleID:nil. |
|
2187 |
] ifFalse:[ |
|
2188 |
('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR. |
|
2189 |
functions do:[:oldFunction | |
|
2190 |
newFunction := newHandle getFunction:(oldFunction name). |
|
2191 |
newFunction isNil ifTrue:[ |
|
2192 |
('ObjectFileLoader [info]: function: ''' , oldFunction name , ''' no longer present.') errorPrintCR. |
|
2193 |
oldFunction code:nil. |
|
2194 |
oldFunction setName:oldFunction name moduleHandle:nil. |
|
2195 |
] ifFalse:[ |
|
2196 |
oldFunction code:(newFunction code). |
|
2197 |
oldFunction setName:oldFunction name moduleHandle:newHandle. |
|
2198 |
('ObjectFileLoader [info]: rebound function: ''' , oldFunction name , '''.') infoPrintCR. |
|
2199 |
] |
|
2200 |
]. |
|
2201 |
handle becomeSameAs:newHandle. "/ the old handle is now void |
|
2202 |
] |
|
2203 |
] |
|
2204 |
] ifFalse:[ |
|
2205 |
('ObjectFileLoader [info]: ignored invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR. |
|
2206 |
] |
|
2207 |
] |
|
2208 |
] |
|
2209 |
]. |
|
2210 |
PreviouslyLoadedObjects := nil |
|
303 | 2211 |
] |
2212 |
||
716
3c0668dceb1e
dont try to set a metaclasses category when reloading obj-modules.
Claus Gittinger <cg@exept.de>
parents:
706
diff
changeset
|
2213 |
"Modified: / 16.5.1998 / 14:23:12 / cg" |
303 | 2214 |
! |
2215 |
||
2216 |
rememberAllObjectFiles |
|
2217 |
"remember all loaded objectModules in the |
|
2218 |
PreviouslyLoadedObjects classVariable. |
|
2219 |
Called when an image is restarted to reload all modules which |
|
2220 |
were loaded in the previous life" |
|
2221 |
||
2222 |
LoadedObjects notNil ifTrue:[ |
|
741 | 2223 |
PreviouslyLoadedObjects := OrderedCollection new. |
2224 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
2225 |
handle isForCollectedObject ifTrue:[ |
|
2226 |
('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR |
|
2227 |
] ifFalse:[ |
|
2228 |
PreviouslyLoadedObjects add:(name -> handle) |
|
2229 |
] |
|
2230 |
]. |
|
2231 |
PreviouslyLoadedObjects sort:[:a :b | |
|
2232 |
|h1 h2| |
|
2233 |
||
2234 |
h1 := a value moduleID. |
|
2235 |
h2 := b value moduleID. |
|
2236 |
h1 isNil |
|
2237 |
ifTrue:[true] |
|
2238 |
ifFalse:[ |
|
2239 |
h2 isNil |
|
2240 |
ifTrue:[false] |
|
2241 |
ifFalse:[ |
|
2242 |
h1 < h2 |
|
2243 |
] |
|
2244 |
] |
|
2245 |
]. |
|
303 | 2246 |
] |
2247 |
||
2248 |
"Created: 5.12.1995 / 20:51:07 / cg" |
|
474 | 2249 |
"Modified: 10.1.1997 / 15:06:25 / cg" |
303 | 2250 |
! |
2251 |
||
2252 |
revalidateAllObjectFiles |
|
2253 |
"revalidate code refs into all dynamically loaded object files. |
|
2254 |
Required after writing a snapshot image." |
|
2255 |
||
2256 |
ActuallyLoadedObjects notNil ifTrue:[ |
|
468 | 2257 |
ActuallyLoadedObjects keys do:[:aFileName | |
2258 |
|handle| |
|
2259 |
||
2260 |
handle := ActuallyLoadedObjects at:aFileName. |
|
2261 |
handle isNil ifTrue:[ |
|
2262 |
self error:'oops, no handle'. |
|
2263 |
] ifFalse:[ |
|
2264 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
2265 |
self revalidateModule:handle |
|
2266 |
] |
|
2267 |
] |
|
2268 |
]. |
|
2269 |
LoadedObjects := ActuallyLoadedObjects. |
|
2270 |
ActuallyLoadedObjects := PreviouslyLoadedObjects := nil. |
|
28 | 2271 |
]. |
141 | 2272 |
|
303 | 2273 |
"Created: 5.10.1995 / 15:49:08 / claus" |
2274 |
"Modified: 5.10.1995 / 16:49:18 / claus" |
|
2275 |
"Modified: 12.7.1996 / 17:14:48 / cg" |
|
2276 |
! |
|
2277 |
||
2278 |
unloadAllObjectFiles |
|
2279 |
"unload all dynamically loaded object files from the image. |
|
2280 |
see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:" |
|
2281 |
||
2282 |
LoadedObjects notNil ifTrue:[ |
|
2283 |
LoadedObjects keys copy do:[:aFileName | |
|
2284 |
self unloadObjectFile:aFileName |
|
2285 |
] |
|
2286 |
]. |
|
2287 |
||
2288 |
" |
|
2289 |
ObjectFileLoader unloadAllObjectFiles |
|
2290 |
" |
|
2291 |
! |
|
2292 |
||
2293 |
unloadAndRememberAllObjectFiles |
|
2294 |
"remember all modules and unload them" |
|
2295 |
||
2296 |
LoadedObjects notNil ifTrue:[ |
|
468 | 2297 |
self rememberAllObjectFiles. |
2298 |
self unloadAllObjectFiles |
|
303 | 2299 |
] |
2300 |
||
2301 |
"Modified: 25.4.1996 / 09:46:27 / cg" |
|
0 | 2302 |
! ! |
2303 |
||
369 | 2304 |
!ObjectFileLoader class methodsFor:'linking objects'! |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2305 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2306 |
createLoadableObjectFor:baseFileName |
259 | 2307 |
"given an oFile, arrange for it to be loadable. |
2308 |
On ELF systems, this means that it has to be linked with the |
|
2309 |
-shared option into a .so file; |
|
2310 |
DLD based loaders (linux a.out) can directly load a .o file; |
|
2311 |
Other systems may require more ..." |
|
2312 |
||
513 | 2313 |
|osType oFileName soFileName expFileName librunExpFileName |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2314 |
needSharedObject ld ldArg expFile ok outfile output| |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2315 |
|
750
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2316 |
osType := OperatingSystem getOSType. |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2317 |
|
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2318 |
osType = 'win32' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2319 |
self activityNotification:'create def file'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2320 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2321 |
"/ create a .def file. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2322 |
expFileName := '.\' , baseFileName , '.def'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2323 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2324 |
expFile := expFileName asFilename writeStream. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2325 |
expFile notNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2326 |
OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2327 |
expFile nextPutLine:'LIBRARY ' , baseFileName. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2328 |
expFile nextPutLine:'SEGMENTS'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2329 |
expFile nextPutLine:' INITCODE PRELOAD SHARED'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2330 |
"/ expFile nextPutLine:' INITDATA READ WRITE'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2331 |
expFile nextPutLine:'EXPORTS'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2332 |
expFile nextPutLine:' __' , baseFileName , '_Init'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2333 |
] ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2334 |
expFile nextPutLine:'LIBRARY ' , baseFileName. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2335 |
expFile nextPutLine:'CODE EXECUTE READ SHARED'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2336 |
expFile nextPutLine:'DATA READ WRITE'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2337 |
expFile nextPutLine:'SECTIONS'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2338 |
expFile nextPutLine:' INITCODE READ EXECUTE SHARED'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2339 |
expFile nextPutLine:' INITDATA READ WRITE'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2340 |
expFile nextPutLine:' RODATA READ SHARED'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2341 |
expFile nextPutLine:'EXPORTS'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2342 |
expFile nextPutLine:' _' , baseFileName , '_Init'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2343 |
expFile nextPutLine:'IMPORTS'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2344 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2345 |
expFile close. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2346 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2347 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2348 |
self activityNotification:'generating shared object'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2349 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2350 |
LinkArgs isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2351 |
ld := LinkCommand , ' ' , baseFileName , '.obj'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2352 |
ld := ld |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2353 |
, ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2354 |
, ' /OUT:' , baseFileName , '.dll ' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2355 |
, ' /DEF:' , baseFileName , '.def'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2356 |
] ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2357 |
OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2358 |
ld := LinkCommand , ' ' , (LinkArgs bindWith:baseFileName). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2359 |
ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2360 |
ld := ld , ',' , baseFileName , '.dll,,..\libbc\librun.lib '. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2361 |
ld := ld , (SearchedLibraries asStringCollection asStringWith: $ ). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2362 |
ld := ld , ' stxc32i.lib,,'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2363 |
] ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2364 |
self halt. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2365 |
] |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2366 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2367 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2368 |
outfile := (baseFileName , '.out'). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2369 |
ok := OperatingSystem executeCommand:(ld , ' >' , outfile). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2370 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2371 |
ok ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2372 |
output := (baseFileName , '.out') asFilename contents asString. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2373 |
Transcript showCR:output; endEntry. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2374 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2375 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2376 |
(baseFileName , '.out') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2377 |
(baseFileName , '.tds') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2378 |
(baseFileName , '.ilc') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2379 |
(baseFileName , '.ild') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2380 |
(baseFileName , '.ilf') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2381 |
(baseFileName , '.ils') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2382 |
(baseFileName , '.lib') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2383 |
(baseFileName , '.map') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2384 |
(baseFileName , '.def') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2385 |
(baseFileName , '.obj') asFilename delete. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2386 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2387 |
ok ifFalse:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2388 |
"/ self halt. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2389 |
LastError := output. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2390 |
^ nil |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2391 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2392 |
oFileName := (Filename currentDirectory construct:(baseFileName , self sharedLibraryExtension)) name. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2393 |
^ oFileName |
750
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2394 |
]. |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2395 |
|
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2396 |
"/ UNIX systems |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2397 |
|
324 | 2398 |
ld := 'ld'. |
188 | 2399 |
needSharedObject := false. |
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2400 |
|
513 | 2401 |
osType = 'irix' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2402 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2403 |
link it to a shared object with 'ld -shared' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2404 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2405 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2406 |
ldArg := '-shared'. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2407 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2408 |
|
513 | 2409 |
osType = 'sys5_4' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2410 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2411 |
link it to a shared object with 'ld -G' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2412 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2413 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2414 |
ldArg := '-G'. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2415 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2416 |
|
698 | 2417 |
osType = 'osf' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2418 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2419 |
link it to a shared object with 'ld -shared' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2420 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2421 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2422 |
ldArg := '-shared'. |
698 | 2423 |
]. |
2424 |
||
513 | 2425 |
osType = 'linux' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2426 |
ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2427 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2428 |
link it to a shared object with 'ld -shared' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2429 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2430 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2431 |
ldArg := '-shared'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2432 |
] |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2433 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2434 |
|
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2435 |
osType = 'solaris' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2436 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2437 |
link it to a shared object with 'ld -G -B dynamic' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2438 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2439 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2440 |
ldArg := '-G -B dynamic'. |
741 | 2441 |
]. |
2442 |
||
2443 |
osType = 'hpux' ifTrue:[ |
|
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2444 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2445 |
link it to a shared object with 'ld -b -B immediate' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2446 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2447 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2448 |
ldArg := '-b -B immediate'. |
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2449 |
]. |
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2450 |
|
513 | 2451 |
osType = 'aix' ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2452 |
self activityNotification:'create export file'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2453 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2454 |
"/ create an exports file. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2455 |
expFileName := './' , baseFileName , '.exp'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2456 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2457 |
expFile := expFileName asFilename writeStream. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2458 |
expFile notNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2459 |
expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2460 |
expFile cr. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2461 |
expFile nextPutAll:'_' , baseFileName , '_Init'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2462 |
expFile close. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2463 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2464 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2465 |
self activityNotification:'generating shared object'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2466 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2467 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2468 |
link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2469 |
" |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2470 |
needSharedObject := true. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2471 |
ld := 'cc'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2472 |
librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2473 |
librunExpFileName isNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2474 |
LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2475 |
^ nil |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2476 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2477 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2478 |
ldArg := '-bI:' , librunExpFileName , |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2479 |
' -bE:' , baseFileName , '.exp' , |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2480 |
' -bM:SRE -e _' , baseFileName , '_Init'. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2481 |
]. |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2482 |
|
741 | 2483 |
oFileName := './' , baseFileName , (self objectFileExtension). |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2484 |
needSharedObject ifTrue:[ |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2485 |
self activityNotification:'generating shared object'. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2486 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2487 |
soFileName := './' , baseFileName , (self sharedLibraryExtension). |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2488 |
OperatingSystem removeFile:soFileName. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2489 |
Verbose ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2490 |
'linking with:' infoPrintCR. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2491 |
' ' infoPrint. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2492 |
(ld , ' ' , ldArg , ' -o ' , soFileName , ' ' , oFileName) infoPrintCR. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2493 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2494 |
OperatingSystem executeCommand: |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2495 |
ld , ' ' , ldArg , ' ', |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2496 |
(SearchedLibraries asStringCollection asStringWith: $ ), |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2497 |
' -o ' , soFileName , ' ' , oFileName. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2498 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2499 |
OperatingSystem removeFile:oFileName. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2500 |
expFileName notNil ifTrue:[ |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2501 |
OperatingSystem removeFile:expFileName |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2502 |
]. |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2503 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2504 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2505 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2506 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2507 |
assume we can load an ordinary binary |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2508 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2509 |
^ oFileName |
698 | 2510 |
|
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
2511 |
"Modified: / 30.9.1998 / 18:13:46 / cg" |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2512 |
! ! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2513 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2514 |
!ObjectFileLoader class methodsFor:'lowlevel object loading'! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2515 |
|
633 | 2516 |
initializeLoader |
2517 |
"initialize dynamic loader if required" |
|
2518 |
||
2519 |
|stxName stxPathName| |
|
2520 |
||
2521 |
stxPathName := OperatingSystem pathOfSTXExecutable. |
|
2522 |
%{ |
|
2523 |
#ifdef GNU_DL |
|
2524 |
{ |
|
2525 |
static alreadyInitialized = 0; |
|
2526 |
extern dld_ignore_redefinitions; |
|
2527 |
||
2528 |
if (! alreadyInitialized) { |
|
2529 |
alreadyInitialized = 1; |
|
2530 |
||
2531 |
if (@global(Verbose) == true) { |
|
2532 |
printf ("dld_init(%s)\n", __stringVal(stxPathName)); |
|
2533 |
} |
|
2534 |
/* |
|
2535 |
* dld requires the running executables name, |
|
2536 |
* to resolve symbols. |
|
2537 |
*/ |
|
2538 |
(void) dld_init (__stringVal(stxPathName)); |
|
2539 |
dld_ignore_redefinitions = 1; |
|
2540 |
} |
|
2541 |
} |
|
2542 |
#endif |
|
2543 |
%}. |
|
2544 |
! |
|
2545 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2546 |
loadDynamicObject:pathName |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2547 |
"load an object-file (load/map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2548 |
Return a non-nil handle if ok, nil otherwise. |
472 | 2549 |
No bindings or automatic initializations are done |
2550 |
- only a pure (low-level) load is performed. |
|
2551 |
For class-files or C-objects to be loaded with this method, |
|
2552 |
it is your responsibility to fetch any init-functions and |
|
2553 |
call them as appropriate. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2554 |
This function is not supported on all architectures. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2555 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2556 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2557 |
|handle buffer| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2558 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2559 |
Verbose ifTrue:[ |
634 | 2560 |
('loadDynamic: ' , pathName , ' ...') infoPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2561 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2562 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2563 |
"/ already loaded ? |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2564 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2565 |
LoadedObjects notNil ifTrue:[ |
634 | 2566 |
handle := LoadedObjects at:pathName ifAbsent:nil. |
2567 |
handle notNil ifTrue:[ |
|
2568 |
Verbose ifTrue:[ |
|
2569 |
('... ' , pathName , ' already loaded.') infoPrintCR. |
|
2570 |
]. |
|
2571 |
^ handle |
|
2572 |
]. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2573 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2574 |
|
759 | 2575 |
Verbose ifTrue:[ |
2576 |
('initializeLoader...') infoPrintCR |
|
2577 |
]. |
|
589
ee0cc3ae769a
care for stx's path; req'd for dld if stx is not found in the current dir.
Claus Gittinger <cg@exept.de>
parents:
587
diff
changeset
|
2578 |
self initializeLoader. |
ee0cc3ae769a
care for stx's path; req'd for dld if stx is not found in the current dir.
Claus Gittinger <cg@exept.de>
parents:
587
diff
changeset
|
2579 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2580 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2581 |
"/ the 1st two entries are system dependent; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2582 |
"/ entry 3 is the pathName |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2583 |
"/ entry 4 is a unique ID |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2584 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2585 |
buffer := Array new:4. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2586 |
buffer at:3 put:pathName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2587 |
buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2588 |
|
759 | 2589 |
Verbose ifTrue:[ |
2590 |
('primLoadDynamicObject...') infoPrintCR |
|
2591 |
]. |
|
2592 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2593 |
buffer := self primLoadDynamicObject:pathName into:buffer. |
759 | 2594 |
Verbose ifTrue:[ |
2595 |
('done') infoPrintCR |
|
2596 |
]. |
|
2597 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2598 |
buffer isNil ifTrue:[ |
634 | 2599 |
LastError == #notImplemented ifTrue:[ |
2600 |
'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR. |
|
2601 |
] ifFalse:[ |
|
2602 |
LastError == #linkError ifTrue:[ |
|
2603 |
LinkErrorMessage notNil ifTrue:[ |
|
2604 |
('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR. |
|
2605 |
] ifFalse:[ |
|
2606 |
('ObjectFileLoader [warning]: load error') infoPrintCR. |
|
2607 |
]. |
|
2608 |
]. |
|
2609 |
^ nil |
|
2610 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2611 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2612 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2613 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2614 |
remember loaded object for later unloading |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2615 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2616 |
handle := ObjectFileHandle new. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2617 |
handle sysHandle1:(buffer at:1). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2618 |
handle sysHandle2:(buffer at:2). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2619 |
handle pathName:(buffer at:3). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2620 |
handle moduleID:(buffer at:4). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2621 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2622 |
LoadedObjects isNil ifTrue:[ |
634 | 2623 |
LoadedObjects := Dictionary new. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2624 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2625 |
LoadedObjects at:pathName put:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2626 |
Smalltalk flushCachedClasses. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2627 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2628 |
Verbose ifTrue:[ |
634 | 2629 |
('loadDynamic ok; handle is: ' , handle printString) infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2630 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2631 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2632 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2633 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2634 |
"sys5.4: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2635 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2636 |
handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2637 |
ObjectFileLoader getFunction:'module1' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2638 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2639 |
"next: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2640 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2641 |
handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2642 |
ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2643 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2644 |
"GLD: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2645 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2646 |
handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2647 |
ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2648 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2649 |
|
525 | 2650 |
"Modified: 16.5.1997 / 12:56:33 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2651 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2652 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2653 |
loadModulesFromListOfUndefined:list |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2654 |
"try to figure out what has to be loaded to resolve symbols from list. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2655 |
return a list of handles of loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2656 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2657 |
|inits classNames| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2658 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2659 |
inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2660 |
inits notNil ifTrue:[ |
634 | 2661 |
classNames := inits collect:[:symbol | |
2662 |
(symbol startsWith:'___') ifTrue:[ |
|
2663 |
symbol copyFrom:4 to:(symbol size - 5) |
|
2664 |
] ifFalse:[ |
|
2665 |
(symbol startsWith:'__') ifTrue:[ |
|
2666 |
symbol copyFrom:3 to:(symbol size - 5) |
|
2667 |
] ifFalse:[ |
|
2668 |
(symbol startsWith:'_') ifTrue:[ |
|
2669 |
symbol copyFrom:2 to:(symbol size - 5) |
|
2670 |
] ifFalse:[ |
|
2671 |
symbol |
|
2672 |
] |
|
2673 |
] |
|
2674 |
] |
|
2675 |
]. |
|
2676 |
" |
|
2677 |
autoload those classes |
|
2678 |
" |
|
2679 |
classNames do:[:aClassName | |
|
2680 |
|cls| |
|
2681 |
||
2682 |
(cls := Smalltalk classNamed:aClassName) notNil ifTrue:[ |
|
2683 |
'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR. |
|
2684 |
cls autoload |
|
2685 |
] |
|
2686 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2687 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2688 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2689 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2690 |
"Modified: 10.1.1997 / 17:58:23 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2691 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2692 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2693 |
primLoadDynamicObject:pathName into:anInfoBuffer |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2694 |
"load an object-file (map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2695 |
Return an OS-handle (whatever that is) - where some space |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2696 |
(a 3-element array) has to be passed in for this. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2697 |
The first two entries are used in a machine dependent way, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2698 |
and callers may not depend on what is found there |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2699 |
(instead, only pass around handles transparently). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2700 |
This function is not supported on all architectures." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2701 |
|
759 | 2702 |
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2703 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2704 |
if (! __isArray(anInfoBuffer) |
646
02b5ea95f888
eliminated some single-underscore macro refs (stringSize, arraySize ...)
Claus Gittinger <cg@exept.de>
parents:
645
diff
changeset
|
2705 |
|| (__arraySize(anInfoBuffer) < 3)) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2706 |
return nil; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2707 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2708 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2709 |
#ifdef GNU_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2710 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2711 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2712 |
if (dld_link(__stringVal(pathName))) { |
592 | 2713 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2714 |
printf ("link file %s failed\n", __stringVal(pathName)); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2715 |
} |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2716 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2717 |
dld_perror("ObjectFileLoader - DLD error cant link"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2718 |
} |
592 | 2719 |
@global(LastError) = @symbol(linkError); |
2720 |
@global(LinkErrorMessage) = __MKSTRING("DLD error"); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2721 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2722 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2723 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2724 |
__STORE(anInfoBuffer, pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2725 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2726 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2727 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2728 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2729 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2730 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2731 |
#ifdef WIN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2732 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2733 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2734 |
int err; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2735 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2736 |
if (__isString(pathName)) { |
760 | 2737 |
if (@global(Verbose) == true) { |
778 | 2738 |
__win32_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName)); |
2739 |
__win32_fflush(stderr); |
|
759 | 2740 |
} |
2741 |
handle = LoadLibrary(__stringVal(pathName)); |
|
760 | 2742 |
if (@global(Verbose) == true) { |
778 | 2743 |
__win32_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle); |
2744 |
__win32_fflush(stderr); |
|
759 | 2745 |
} |
2746 |
if (handle == NULL) { |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2747 |
err = GetLastError(); |
778 | 2748 |
if ((@global(ErrorPrinting) == true) |
2749 |
|| (@global(Verbose) == true)) { |
|
2750 |
__win32_fprintf (stderr, |
|
2751 |
"ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n", |
|
2752 |
__stringVal(pathName), err); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2753 |
} |
779
9301641eafbc
set lastErrorNumber if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
2754 |
@global(LastError) = @symbol(loadError);; |
9301641eafbc
set lastErrorNumber if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
2755 |
@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err)); |
592 | 2756 |
@global(LinkErrorMessage) = __MKSTRING("LoadLibrary error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2757 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2758 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2759 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2760 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2761 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2762 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2763 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2764 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2765 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2766 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2767 |
#ifdef DL1_6 |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2768 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2769 |
extern char *__myName__; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2770 |
char *ldname; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2771 |
OBJ tmpName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2772 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2773 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2774 |
if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) { |
592 | 2775 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2776 |
printf ("link file %s failed\n", __stringVal(pathName)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2777 |
} |
592 | 2778 |
@global(LinkErrorMessage) = __MKSTRING("dl_load error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2779 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2780 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2781 |
/* |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2782 |
* returns the name of the temporary ld-file |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2783 |
* use that as handle ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2784 |
*/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2785 |
tmpName = __MKSTRING(ldname); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2786 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2787 |
__STORE(anInfoBuffer, tmpName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2788 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2789 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2790 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2791 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2792 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2793 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2794 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2795 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2796 |
char *objName, *libPath; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2797 |
int *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2798 |
extern errno; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2799 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2800 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2801 |
objName = __stringVal(pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2802 |
|
592 | 2803 |
if (__isString(@global(LibPath))) { |
2804 |
libPath = __stringVal(@global(LibPath)); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2805 |
} else { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2806 |
libPath = (char *)0; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2807 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2808 |
if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) { |
592 | 2809 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2810 |
char *messages[64]; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2811 |
int i; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2812 |
|
778 | 2813 |
fprintf (stderr, |
2814 |
"ObjectFileLoader [info]: load file %s failed errno=%d\n", |
|
2815 |
objName, errno); |
|
2816 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2817 |
switch (errno) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2818 |
case ENOEXEC: |
778 | 2819 |
fprintf(stderr, " load messages:\n"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2820 |
loadquery(L_GETMESSAGES, messages, sizeof(messages)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2821 |
for (i=0; messages[i]; i++) { |
782 | 2822 |
fprintf(stderr, " %s\n", messages[i]); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2823 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2824 |
break; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2825 |
} |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2826 |
} else { |
634 | 2827 |
if (@global(ErrorPrinting) == true) { |
778 | 2828 |
fprintf (stderr, |
2829 |
"ObjectFileLoader [warning]: load file %s failed errno=%d\n", |
|
2830 |
objName, errno); |
|
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2831 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2832 |
} |
592 | 2833 |
@global(LinkErrorMessage) = __MKSTRING("load error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2834 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2835 |
} |
592 | 2836 |
if (@global(Verbose) == true) { |
778 | 2837 |
fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2838 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2839 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2840 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2841 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2842 |
RETURN (anInfoBuffer); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2843 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2844 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2845 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2846 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2847 |
|
523 | 2848 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2849 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2850 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2851 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2852 |
char *nm; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2853 |
char *errMsg; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2854 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2855 |
if ((pathName == nil) || __isString(pathName)) { |
701 | 2856 |
INT lowHandle, hiHandle; |
2857 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2858 |
handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2859 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2860 |
if (! handle) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2861 |
errMsg = (char *) dlerror(); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2862 |
if (@global(ErrorPrinting) == true) { |
778 | 2863 |
fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName)); |
634 | 2864 |
fprintf(stderr, " <%s>\n", errMsg); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2865 |
} |
592 | 2866 |
@global(LastError) = @symbol(linkError); |
2867 |
@global(LinkErrorMessage) = __MKSTRING(errMsg); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2868 |
RETURN (nil); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2869 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2870 |
|
592 | 2871 |
if (@global(Verbose) == true) { |
778 | 2872 |
fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %x\n", __stringVal(pathName), handle); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2873 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2874 |
|
701 | 2875 |
#ifdef alpha64 |
2876 |
lowHandle = (INT)handle & 0xFFFFFFFFL; |
|
2877 |
hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL; |
|
2878 |
#else |
|
2879 |
lowHandle = (INT)handle & 0xFFFF; |
|
2880 |
hiHandle = ((INT)handle >> 16) & 0xFFFF; |
|
2881 |
#endif |
|
2882 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle); |
|
2883 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2884 |
RETURN (anInfoBuffer); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2885 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2886 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2887 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2888 |
|
523 | 2889 |
|
2890 |
#ifdef HPUX10_DL |
|
2891 |
{ |
|
2892 |
void *handle; |
|
2893 |
char *nm; |
|
2894 |
char *errMsg; |
|
2895 |
||
2896 |
if (__isString(pathName)) { |
|
634 | 2897 |
handle = (void *)shl_load(__stringVal(pathName), |
523 | 2898 |
BIND_IMMEDIATE, 0L /* address */); |
2899 |
||
634 | 2900 |
if (! handle) { |
523 | 2901 |
if (@global(ErrorPrinting) == true) { |
634 | 2902 |
fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName)); |
2903 |
} |
|
592 | 2904 |
@global(LastError) = @symbol(linkError); |
524 | 2905 |
switch (errno) { |
2906 |
case ENOEXEC: |
|
2907 |
errMsg = "not a shared library"; |
|
2908 |
break; |
|
2909 |
case ENOSYM: |
|
2910 |
errMsg = "undefined symbols"; |
|
2911 |
break; |
|
2912 |
case ENOMEM: |
|
2913 |
errMsg = "out of memory"; |
|
2914 |
break; |
|
2915 |
case ENOENT: |
|
2916 |
errMsg = "non existing library"; |
|
2917 |
break; |
|
2918 |
case EACCES: |
|
2919 |
errMsg = "permission denied"; |
|
2920 |
break; |
|
2921 |
default: |
|
2922 |
errMsg = "unspecified error"; |
|
2923 |
break; |
|
2924 |
} |
|
592 | 2925 |
@global(LinkErrorMessage) = __MKSTRING(errMsg); |
634 | 2926 |
RETURN (nil); |
2927 |
} |
|
2928 |
||
2929 |
if (@global(Verbose) == true) { |
|
2930 |
printf("open %s handle = %x\n", __stringVal(pathName), handle); |
|
2931 |
} |
|
523 | 2932 |
|
2933 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF); |
|
2934 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
|
2935 |
RETURN (anInfoBuffer); |
|
2936 |
} |
|
2937 |
} |
|
2938 |
#endif |
|
2939 |
||
2940 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2941 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2942 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2943 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2944 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2945 |
if ((pathName == nil) || __isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2946 |
if (pathName == nil) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2947 |
handle = dlopen((char *)0, 1); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2948 |
else |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2949 |
handle = dlopen(__stringVal(pathName), 1); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2950 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2951 |
if (! handle) { |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2952 |
if (@global(ErrorPrinting) == true) { |
634 | 2953 |
fprintf(stderr, "dlopen %s error: <%s>\n", |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2954 |
__stringVal(pathName), dlerror()); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2955 |
} |
592 | 2956 |
@global(LastError) = @symbol(linkError); |
2957 |
@global(LinkErrorMessage) = __MKSTRING("dlopen error"); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2958 |
RETURN (nil); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2959 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2960 |
|
592 | 2961 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2962 |
printf("open %s handle = %x\n", __stringVal(pathName), handle); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2963 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2964 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2965 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2966 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2967 |
RETURN (anInfoBuffer); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2968 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2969 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2970 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2971 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2972 |
#ifdef NEXT_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2973 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2974 |
long result; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2975 |
char *files[2]; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2976 |
NXStream *errOut; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2977 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2978 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2979 |
files[0] = (char *) __stringVal(pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2980 |
files[1] = (char *) 0; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2981 |
errOut = NXOpenFile(2, 2); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2982 |
result = rld_load(errOut, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2983 |
(struct mach_header **)0, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2984 |
files, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2985 |
(char *)0); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2986 |
NXClose(errOut); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2987 |
if (! result) { |
592 | 2988 |
@global(LinkErrorMessage) = __MKSTRING("rld_load error"); |
2989 |
@global(LastError) = @symbol(linkError); |
|
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2990 |
if (@global(ErrorPrinting) == true) { |
634 | 2991 |
fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName)); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2992 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2993 |
RETURN (nil); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2994 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2995 |
|
592 | 2996 |
if (@global(Verbose) == true) |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2997 |
printf("rld_load %s ok\n", __stringVal(pathName)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2998 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2999 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3000 |
__STORE(anInfoBuffer, pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3001 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3002 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3003 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3004 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3005 |
%}. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3006 |
LastError := #notImplemented. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3007 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3008 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3009 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3010 |
primUnloadDynamicObject:aHandle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3011 |
"unload an object-file (unmap from my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3012 |
This is a low-level entry, which does not care if there are |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3013 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3014 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3015 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3016 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3017 |
|sysHandle1 sysHandle2| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3018 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3019 |
sysHandle1 := aHandle sysHandle1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3020 |
sysHandle2 := aHandle sysHandle2. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3021 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3022 |
%{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3023 |
#ifdef GNU_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3024 |
if (__isString(sysHandle1)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3025 |
if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) { |
592 | 3026 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3027 |
printf ("unlink file %s failed\n", __stringVal(sysHandle1)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3028 |
dld_perror("cant unlink"); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3029 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3030 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3031 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3032 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3033 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3034 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3035 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3036 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3037 |
#ifdef WIN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3038 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3039 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3040 |
int err; |
771 | 3041 |
jmp_buf exitJmpBuf; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3042 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3043 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3044 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3045 |
handle = (HINSTANCE)(val); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3046 |
|
771 | 3047 |
if (setjmp(exitJmpBuf)) { |
778 | 3048 |
__setAtExitLongJmp(exitJmpBuf); |
771 | 3049 |
if (FreeLibrary(handle) != TRUE) { |
778 | 3050 |
__setAtExitLongJmp(0); |
3051 |
err = GetLastError(); |
|
3052 |
if (@global(Verbose) == true) { |
|
3053 |
__win32_fprintf (stderr, |
|
3054 |
"ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n", |
|
3055 |
__stringVal(sysHandle1), err); |
|
3056 |
} |
|
779
9301641eafbc
set lastErrorNumber if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
3057 |
@global(LastErrorNumber) = __WIN32_ERR(err); |
778 | 3058 |
RETURN (false); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3059 |
} |
771 | 3060 |
} else { |
778 | 3061 |
__setAtExitLongJmp(0); |
3062 |
fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n"); |
|
771 | 3063 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3064 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3065 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3066 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3067 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3068 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3069 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3070 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3071 |
void *h; |
701 | 3072 |
INT val; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3073 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3074 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3075 |
if (__bothSmallInteger(low, hi)) { |
701 | 3076 |
#ifdef alpha64 |
3077 |
val = (__intVal(hi) << 32) + __intVal(low); |
|
3078 |
#else |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3079 |
val = (_intVal(hi) << 16) + _intVal(low); |
701 | 3080 |
#endif |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3081 |
h = (void *)(val); |
592 | 3082 |
if (@global(Verbose) == true) |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3083 |
printf("close handle = %x\n", h); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3084 |
if (dlclose(h) != 0) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3085 |
fprintf(stderr, "dlclose failed with:<%s>\n", dlerror()); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3086 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3087 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3088 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3089 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3090 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3091 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3092 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3093 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3094 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3095 |
void *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3096 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3097 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3098 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3099 |
if (__bothSmallInteger(low, hi)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3100 |
val = (_intVal(hi) << 16) + _intVal(low); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3101 |
h = (void *)(val); |
592 | 3102 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3103 |
printf("close handle = %x\n", h); |
523 | 3104 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3105 |
dlclose(h); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3106 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3107 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3108 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3109 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3110 |
|
523 | 3111 |
#ifdef HPUX10_DL |
3112 |
{ |
|
3113 |
int *h; |
|
3114 |
int val; |
|
3115 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
3116 |
||
3117 |
if (__bothSmallInteger(low, hi)) { |
|
3118 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
3119 |
h = (void *)(val); |
|
592 | 3120 |
if (@global(Verbose) == true) { |
523 | 3121 |
printf("unload handle = %x\n", h); |
3122 |
} |
|
3123 |
shl_unload(h); |
|
3124 |
RETURN (true); |
|
3125 |
} |
|
3126 |
} |
|
3127 |
#endif |
|
3128 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3129 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3130 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3131 |
int *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3132 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3133 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3134 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3135 |
if (__bothSmallInteger(low, hi)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3136 |
val = (_intVal(hi) << 16) + _intVal(low); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3137 |
h = (int *)(val); |
592 | 3138 |
if (@global(Verbose) == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3139 |
printf("unload handle = %x\n", h); |
523 | 3140 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3141 |
if ( unload(h) != 0) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3142 |
fprintf(stderr, "unload failed\n"); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3143 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3144 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3145 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3146 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3147 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3148 |
#endif |
529
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3149 |
|
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3150 |
#ifdef NEXT_DL |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3151 |
{ |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3152 |
fprintf(stderr, "ObjectFileLoader [warning]: Sorry, NeXTStep does not support selective unloading\n"); |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3153 |
} |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3154 |
#endif |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3155 |
%}. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3156 |
^ false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3157 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3158 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3159 |
unloadDynamicObject:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3160 |
"close an object-file (unmap from my address space) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3161 |
and remove the entry from the remembered object file set. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3162 |
This is a low-level entry, which does not care if there are |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3163 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3164 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3165 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3166 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3167 |
|key fileName functionName deInitAddr m| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3168 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3169 |
Verbose ifTrue:[ |
634 | 3170 |
'unload module name=' infoPrint. handle pathName infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3171 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3172 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3173 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3174 |
"/ fixup |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3175 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3176 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3177 |
handle isFunctionObjectHandle ifTrue:[ |
634 | 3178 |
handle functions do:[:f | |
3179 |
f notNil ifTrue:[ |
|
3180 |
f code:0 |
|
3181 |
] |
|
3182 |
]. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3183 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3184 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3185 |
(handle isClassLibHandle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3186 |
or:[handle isMethodHandle]) ifTrue:[ |
634 | 3187 |
self deinitializeClassesFromModule:handle. |
3188 |
self unregisterModule:handle. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3189 |
] ifFalse:[ |
634 | 3190 |
fileName := handle pathName asFilename baseName. |
3191 |
functionName := self initFunctionBasenameForFile:fileName. |
|
3192 |
||
3193 |
deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle. |
|
3194 |
deInitAddr notNil ifTrue:[ |
|
3195 |
self callInitFunctionAt:deInitAddr |
|
3196 |
specialInit:false |
|
3197 |
forceOld:true |
|
3198 |
interruptable:false |
|
3199 |
argument:0 |
|
3200 |
identifyAs:handle |
|
3201 |
returnsObject:false. |
|
3202 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3203 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3204 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3205 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3206 |
"/ now, really unload |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3207 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3208 |
(self primUnloadDynamicObject:handle) ifFalse:[ |
634 | 3209 |
^ self error:'unloadDynamic failed' |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3210 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3211 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3212 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3213 |
"/ remove from loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3214 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3215 |
LoadedObjects notNil ifTrue:[ |
634 | 3216 |
key := LoadedObjects keyAtEqualValue:handle. |
3217 |
key notNil ifTrue:[ |
|
3218 |
LoadedObjects removeKey:key |
|
3219 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3220 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3221 |
Smalltalk flushCachedClasses. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3222 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3223 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3224 |
for individual methods, we keep the methodObject, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3225 |
but make it unexecutable. Its still visible in the browser. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3226 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3227 |
handle isMethodHandle ifTrue:[ |
634 | 3228 |
((m := handle method) notNil |
3229 |
and:[m ~~ 0]) ifTrue:[ |
|
3230 |
m makeUnloaded. |
|
3231 |
ObjectMemory flushCaches. |
|
3232 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3233 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3234 |
|
474 | 3235 |
"Modified: 10.1.1997 / 15:08:26 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3236 |
! ! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3237 |
|
369 | 3238 |
!ObjectFileLoader class methodsFor:'queries'! |
141 | 3239 |
|
3240 |
canLoadObjectFiles |
|
259 | 3241 |
"return true, if dynamic loading is possible. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3242 |
Currently, only ELF based systems, AIX and linux a.out can do this." |
141 | 3243 |
|
3244 |
self primCanLoadObjectFiles ifTrue:[^true]. |
|
3245 |
||
3246 |
"/ can add a return true here, if I ever get manual loading to work |
|
3247 |
"/ for some specific machine |
|
3248 |
^ false |
|
259 | 3249 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3250 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3251 |
ObjectFileLoader canLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3252 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3253 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3254 |
"Modified: 8.1.1997 / 18:13:01 / cg" |
141 | 3255 |
! |
3256 |
||
3257 |
loadedObjectFiles |
|
3258 |
"return a collection containing the names of all |
|
3259 |
dynamically loaded objects." |
|
3260 |
||
3261 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
3262 |
^ LoadedObjects keys copy |
|
3263 |
||
3264 |
" |
|
3265 |
ObjectFileLoader loadedObjectFiles |
|
3266 |
" |
|
3267 |
! |
|
3268 |
||
3269 |
loadedObjectHandles |
|
3270 |
"return a collection of all handles" |
|
3271 |
||
3272 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
3273 |
^ LoadedObjects |
|
3274 |
||
3275 |
" |
|
3276 |
ObjectFileLoader loadedObjectHandles |
|
3277 |
" |
|
3278 |
||
3279 |
"Created: 17.9.1995 / 14:28:55 / claus" |
|
3280 |
"Modified: 17.9.1995 / 16:13:48 / claus" |
|
3281 |
! |
|
3282 |
||
3283 |
loadedObjectHandlesDo:aBlock |
|
3284 |
"enumerate all handles" |
|
3285 |
||
3286 |
LoadedObjects notNil ifTrue:[ |
|
3287 |
LoadedObjects copy do:aBlock. |
|
3288 |
]. |
|
3289 |
||
3290 |
" |
|
3291 |
ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL] |
|
3292 |
" |
|
3293 |
||
3294 |
"Created: 14.9.1995 / 22:03:13 / claus" |
|
3295 |
"Modified: 14.9.1995 / 22:32:48 / claus" |
|
3296 |
! |
|
3297 |
||
3298 |
pathNameFromID:id |
|
3299 |
"given an id, return the pathName, or nil for static modules" |
|
3300 |
||
3301 |
LoadedObjects notNil ifTrue:[ |
|
3302 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
3303 |
handle moduleID == id ifTrue:[ |
|
3304 |
^ handle pathName |
|
3305 |
] |
|
3306 |
]. |
|
3307 |
]. |
|
3308 |
^ nil |
|
3309 |
||
3310 |
" |
|
3311 |
ObjectFileLoader pathNameFromID:1 |
|
3312 |
" |
|
3313 |
||
3314 |
"Modified: 28.8.1995 / 18:08:28 / claus" |
|
3315 |
! |
|
3316 |
||
3317 |
primCanLoadObjectFiles |
|
3318 |
"return true, if loading is possible using a standard mechanism" |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3319 |
|
141 | 3320 |
%{ /* NOCONTEXT */ |
3321 |
#ifdef HAS_DL |
|
3322 |
# if !defined(OS_DEFINE) || defined(unknownOS) |
|
3323 |
fprintf(stderr, "*** OS_DEFINE not correct\n"); |
|
3324 |
# else |
|
3325 |
# if !defined(CPU_DEFINE) || defined(unknownCPU) |
|
3326 |
fprintf(stderr, "*** CPU_DEFINE not correct\n"); |
|
3327 |
# else |
|
3328 |
RETURN (true); |
|
3329 |
# endif |
|
3330 |
# endif |
|
3331 |
#endif |
|
3332 |
%}. |
|
3333 |
^ false |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3334 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3335 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3336 |
ObjectFileLoader primCanLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3337 |
" |
20 | 3338 |
! ! |
3339 |
||
369 | 3340 |
!ObjectFileLoader class methodsFor:'st object file handling'! |
303 | 3341 |
|
3342 |
callInitFunctionAt:address specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject |
|
3343 |
"call a function at address - a very dangerous operation. |
|
3344 |
This is needed to call the classes init-function after loading in a |
|
3345 |
class-object file or to call the CTORS when c++ modules are loaded. |
|
3346 |
ForceOld (if true) will have the memory manager |
|
3347 |
allocate things in oldSpace instead of newSpace. |
|
3348 |
If special is true, this is a smalltalk moduleInit (i.e. pass the vm-entries table); |
|
3349 |
otherwise, its called without arguments. |
|
3350 |
If its a smalltalk-moduleInit, it may be either for a classPackage (which should |
|
3351 |
install all of its classes) or for a single incrementally compiled methdod |
|
3352 |
(it should then NOT install it, but return the method object instead). |
|
3353 |
||
3354 |
DANGER: Internal & highly specialized. Dont use in your programs. |
|
468 | 3355 |
This interface may change without notice." |
303 | 3356 |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3357 |
|moduleID retVal| |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3358 |
|
303 | 3359 |
handle notNil ifTrue:[ |
468 | 3360 |
moduleID := handle moduleID |
303 | 3361 |
]. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3362 |
|
303 | 3363 |
%{ /* CALLSSTACK: 32000 */ |
3364 |
OBJ (*addr)(); |
|
3365 |
int savInt; |
|
3366 |
int prevSpace, force; |
|
591 | 3367 |
INT arg = 0, ret = 0; |
303 | 3368 |
int wasBlocked = 1; |
3369 |
extern int __oldSpaceSize(), __oldSpaceUsed(); |
|
3370 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3371 |
if (__isInteger(address)) { |
468 | 3372 |
if (_isSmallInteger(argument)) { |
3373 |
arg = __intVal(argument); |
|
3374 |
||
591 | 3375 |
addr = (OBJFUNC)(__longIntVal(address)); |
468 | 3376 |
|
3377 |
/* |
|
3378 |
* allow function to be interrupted |
|
3379 |
*/ |
|
3380 |
if (interruptable != true) { |
|
3381 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
|
3382 |
} |
|
3383 |
||
3384 |
force = (forceOld == true); |
|
3385 |
if (force) { |
|
3386 |
if ((__oldSpaceSize() - __oldSpaceUsed()) < (256*1024)) { |
|
3387 |
__moreOldSpace(__thisContext, 256*1024); |
|
3388 |
} |
|
3389 |
prevSpace = __allocForceSpace(OLDSPACE); |
|
3390 |
} |
|
3391 |
||
759 | 3392 |
#ifdef alpha |
3393 |
if (@global(Verbose) == true) |
|
3394 |
printf("calling initfunc %lx ...\n", addr); |
|
3395 |
#else |
|
3396 |
if (@global(Verbose) == true) |
|
3397 |
printf("calling initfunc %x ...\n", addr); |
|
3398 |
#endif |
|
468 | 3399 |
if (special == true) { |
3400 |
if (__isSmallInteger(moduleID)) { |
|
3401 |
__SET_MODULE_ID(__intVal(moduleID)); |
|
3402 |
} |
|
3403 |
retVal = (*addr)(arg, __pRT__); |
|
3404 |
__SET_MODULE_ID(0); |
|
3405 |
if (returnsObject != true) { |
|
3406 |
retVal = nil; |
|
3407 |
} |
|
3408 |
} else { |
|
3409 |
if (returnsObject == true) { |
|
3410 |
retVal = (*addr)(arg); |
|
3411 |
} else { |
|
3412 |
ret = (int) ((*addr)(arg)); |
|
3413 |
retVal = __MKSMALLINT(ret); |
|
3414 |
} |
|
3415 |
} |
|
3416 |
||
3417 |
if (force) { |
|
3418 |
__allocForceSpace(prevSpace); |
|
3419 |
} |
|
3420 |
||
3421 |
if (! wasBlocked) { |
|
3422 |
__UNBLOCKINTERRUPTS(); |
|
3423 |
} |
|
3424 |
RETURN (retVal); |
|
3425 |
} |
|
303 | 3426 |
} |
3427 |
%}. |
|
3428 |
self primitiveFailed |
|
3429 |
! |
|
3430 |
||
3431 |
deinitializeClassesFromModule:handle |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
3432 |
"send #deinitialize and an #aboutToUnload notification |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
3433 |
to all classes of a module." |
303 | 3434 |
|
3435 |
|classes| |
|
3436 |
||
3437 |
classes := handle classes. |
|
3438 |
classes notNil ifTrue:[ |
|
634 | 3439 |
classes do:[:aClass | |
3440 |
aClass notNil ifTrue:[ |
|
3441 |
aClass isMeta ifFalse:[ |
|
3442 |
Verbose ifTrue:[ |
|
3443 |
'send #deinitialize to:' infoPrint. aClass name infoPrintCR. |
|
3444 |
]. |
|
3445 |
aClass deinitialize. |
|
3446 |
aClass update:#aboutToUnload with:nil from:self |
|
3447 |
] |
|
3448 |
] |
|
3449 |
] |
|
303 | 3450 |
] |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
3451 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3452 |
"Modified: 10.1.1997 / 17:56:50 / cg" |
303 | 3453 |
! |
3454 |
||
3455 |
invalidateModule:handle |
|
3456 |
"invalidate all of the classes code objects ..." |
|
3457 |
||
3458 |
|id| |
|
3459 |
||
3460 |
Verbose ifTrue:[ |
|
634 | 3461 |
'invalidate module; name=' infoPrint. handle pathName infoPrint. |
3462 |
' id=' infoPrint. handle moduleID infoPrintCR. |
|
303 | 3463 |
]. |
3464 |
||
3465 |
id := handle moduleID. |
|
3466 |
%{ |
|
3467 |
__INVALIDATE_BY_ID(__intVal(id)); |
|
3468 |
%} |
|
3469 |
! |
|
3470 |
||
3471 |
loadStatusFor:className |
|
3472 |
"ask VM if class-hierarchy has been completely loaded, and return the status." |
|
3473 |
||
3474 |
|checker checkSymbol statusCode status badClassName| |
|
3475 |
||
3476 |
checker := self. |
|
3477 |
checkSymbol := #'superClassCheck:'. |
|
3478 |
||
3479 |
%{ /* NOREGISTER */ |
|
3480 |
char *badName; |
|
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
3481 |
char *interestingClassName; |
303 | 3482 |
|
3483 |
if (__isString(className) || __isSymbol(className)) { |
|
587 | 3484 |
interestingClassName = (char *)__stringVal(className); |
303 | 3485 |
} else { |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
3486 |
interestingClassName = (char *)0; |
303 | 3487 |
} |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
3488 |
statusCode = __MKSMALLINT(__check_registration__(interestingClassName, |
303 | 3489 |
&checker, &checkSymbol, &badName)); |
3490 |
if (badName) { |
|
3491 |
badClassName = __MKSTRING(badName); |
|
3492 |
} |
|
3493 |
%}. |
|
3494 |
statusCode == 0 ifTrue:[ |
|
3495 |
status := #ok |
|
3496 |
] ifFalse:[ |
|
3497 |
statusCode == -1 ifTrue:[ |
|
3498 |
status := #missingClass |
|
3499 |
] ifFalse:[ |
|
3500 |
statusCode == -2 ifTrue:[ |
|
3501 |
status := #versionMismatch |
|
3502 |
] ifFalse:[ |
|
3503 |
statusCode == -3 ifTrue:[ |
|
3504 |
status := #unregisteredSuperclass |
|
3505 |
] ifFalse:[ |
|
3506 |
status := #loadFailed |
|
3507 |
] |
|
3508 |
] |
|
3509 |
] |
|
3510 |
]. |
|
3511 |
^ Array with:status with:badClassName. |
|
3512 |
! |
|
3513 |
||
3514 |
moduleInit:phase forceOld:forceOld interruptable:interruptable |
|
3515 |
"initialization phases after registration. |
|
3516 |
DANGER: Pure magic; internal only -> dont use in your programs." |
|
3517 |
||
3518 |
%{ |
|
3519 |
int savInt; |
|
3520 |
int prevSpace, force; |
|
3521 |
int arg = 0; |
|
3522 |
int wasBlocked = 1; |
|
3523 |
||
3524 |
if (_isSmallInteger(phase)) { |
|
3525 |
if (interruptable != true) { |
|
3526 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
|
3527 |
} |
|
3528 |
||
3529 |
force = (forceOld == true); |
|
3530 |
if (force) { |
|
3531 |
prevSpace = __allocForceSpace(OLDSPACE); |
|
3532 |
} |
|
3533 |
||
345
3727b0b6f62f
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
339
diff
changeset
|
3534 |
__init_registered_modules__(__intVal(phase)); |
303 | 3535 |
|
3536 |
if (force) { |
|
3537 |
__allocForceSpace(prevSpace); |
|
3538 |
} |
|
3539 |
||
3540 |
if (! wasBlocked) { |
|
3541 |
__UNBLOCKINTERRUPTS(); |
|
3542 |
} |
|
3543 |
RETURN (self); |
|
3544 |
} |
|
3545 |
%}. |
|
3546 |
self primitiveFailed |
|
3547 |
! |
|
3548 |
||
3549 |
performModuleInitAt:initAddr for:className identifyAs:handle |
|
3550 |
"Initialize a loaded smalltalk module." |
|
3551 |
||
3552 |
|status badClassName infoCollection info classNames classes| |
|
3553 |
||
3554 |
" |
|
3555 |
need 4 passes to init: 0: let module register itself & create its pools/globals |
|
634 | 3556 |
0b check if modules superclasses are all loaded |
3557 |
1: let it get var-refs to other pools/globals |
|
3558 |
2: let it install install class, methods and literals |
|
3559 |
3: let it send #initialize to its class object |
|
303 | 3560 |
" |
3561 |
||
3562 |
"/ |
|
3563 |
"/ let it register itself |
|
3564 |
"/ and define its globals |
|
3565 |
"/ |
|
3566 |
Verbose ifTrue:[ |
|
634 | 3567 |
'phase 0 ...' infoPrintCR |
303 | 3568 |
]. |
3569 |
self callInitFunctionAt:initAddr |
|
634 | 3570 |
specialInit:true |
3571 |
forceOld:true |
|
3572 |
interruptable:false |
|
3573 |
argument:0 |
|
3574 |
identifyAs:handle |
|
3575 |
returnsObject:false. |
|
303 | 3576 |
|
3577 |
"/ |
|
3578 |
"/ check if superclasses are present |
|
3579 |
"/ |
|
3580 |
info := self loadStatusFor:className. |
|
3581 |
status := info at:1. |
|
3582 |
badClassName := info at:2. |
|
3583 |
||
3584 |
Verbose ifTrue:[ |
|
634 | 3585 |
'... status is ' infoPrint. info infoPrintCR |
303 | 3586 |
]. |
3587 |
||
3588 |
(status ~~ #ok) ifTrue:[ |
|
634 | 3589 |
(status == #missingClass) ifTrue:[ |
3590 |
('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR. |
|
3591 |
^ info |
|
3592 |
]. |
|
3593 |
(status == #versionMismatch) ifTrue:[ |
|
3594 |
('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR. |
|
3595 |
^ info |
|
3596 |
]. |
|
3597 |
(status == #unregisteredSuperclass) ifTrue:[ |
|
3598 |
('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR. |
|
3599 |
^ info |
|
3600 |
]. |
|
3601 |
('ObjectFileLoader [error]: load failed') infoPrintCR. |
|
3602 |
^ Array with:#loadFailed with:nil |
|
303 | 3603 |
]. |
3604 |
||
3605 |
"/ |
|
3606 |
"/ remaining initialization |
|
3607 |
"/ |
|
3608 |
Verbose ifTrue:[ |
|
634 | 3609 |
'phase 1 ...' infoPrintCR |
303 | 3610 |
]. |
3611 |
self moduleInit:1 forceOld:true interruptable:false. |
|
3612 |
||
3613 |
Verbose ifTrue:[ |
|
634 | 3614 |
'phase 2 ...' infoPrintCR |
303 | 3615 |
]. |
3616 |
self moduleInit:2 forceOld:true interruptable:false. |
|
3617 |
||
3618 |
Verbose ifTrue:[ |
|
634 | 3619 |
'phase 3 ...' infoPrintCR |
303 | 3620 |
]. |
3621 |
ObjectMemory flushCaches. |
|
3622 |
self moduleInit:3 forceOld:false interruptable:true. |
|
3623 |
||
3624 |
"/ ask objectMemory for the classes we have just loaded |
|
3625 |
"/ and register them in the handle |
|
3626 |
||
3627 |
infoCollection := ObjectMemory binaryModuleInfo. |
|
3628 |
info := infoCollection at:handle moduleID ifAbsent:nil. |
|
3629 |
info isNil ifTrue:[ |
|
634 | 3630 |
"/ mhmh registration failed - |
3631 |
('ObjectFileLoader [error]: registration failed') infoPrintCR. |
|
3632 |
^ Array with:#registrationFailed with:nil |
|
303 | 3633 |
]. |
3634 |
||
405
92cb91b82cf7
changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3635 |
classNames := info classNames. |
303 | 3636 |
classNames size > 0 ifTrue:[ |
634 | 3637 |
classes := classNames collect:[:nm | Smalltalk classNamed:nm]. |
303 | 3638 |
]. |
3639 |
classes size > 0 ifTrue:[ |
|
634 | 3640 |
classes := classes asArray. |
3641 |
classes := classes , (classes collect:[:aClass | aClass class]). |
|
303 | 3642 |
]. |
3643 |
handle classes:classes. |
|
3644 |
||
3645 |
^ Array with:#ok with:nil |
|
3646 |
||
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3647 |
"Modified: 10.1.1997 / 17:58:41 / cg" |
303 | 3648 |
! |
3649 |
||
3650 |
revalidateModule:handle |
|
3651 |
"revalidate all of the classes code objects ..." |
|
3652 |
||
3653 |
|id| |
|
3654 |
||
3655 |
Verbose ifTrue:[ |
|
634 | 3656 |
'revalidate module; name=' infoPrint. handle pathName infoPrint. |
3657 |
' id=' infoPrint. handle moduleID infoPrintCR. |
|
303 | 3658 |
]. |
3659 |
||
3660 |
id := handle moduleID. |
|
3661 |
%{ |
|
3662 |
__REVALIDATE_BY_ID(__intVal(id)); |
|
3663 |
%} |
|
3664 |
! |
|
3665 |
||
3666 |
superClassCheck:aClass |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3667 |
"callBack from class registration code in VM: |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3668 |
make certain, that aClass is loaded too ... |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3669 |
(req'd if a subclass of an autoloaded class has been loaded)" |
303 | 3670 |
|
3671 |
Verbose ifTrue:[ |
|
634 | 3672 |
'checkCall for:' infoPrint. aClass name infoPrint. ' -> ' infoPrint. |
303 | 3673 |
]. |
3674 |
aClass isBehavior ifFalse:[ |
|
634 | 3675 |
Verbose ifTrue:[ |
3676 |
'false' infoPrintCR. |
|
3677 |
]. |
|
3678 |
'ObjectFileLoader [warning]: check failed - no behavior' errorPrintCR. |
|
3679 |
^ false |
|
303 | 3680 |
]. |
3681 |
Verbose ifTrue:[ |
|
634 | 3682 |
'true' infoPrintCR. |
303 | 3683 |
]. |
474 | 3684 |
('ObjectFileLoader [info]: check for ' , aClass name , ' being loaded') infoPrintCR. |
303 | 3685 |
aClass autoload. |
3686 |
(aClass isBehavior and:[aClass isLoaded]) ifTrue:[ |
|
634 | 3687 |
('ObjectFileLoader [info]: ok, loaded. continue registration of actual class') infoPrintCR. |
3688 |
aClass signature. "/ req'd in VM for validation |
|
3689 |
^ true |
|
303 | 3690 |
]. |
474 | 3691 |
('ObjectFileLoader [warning]: superclass not loaded; registration of ' , aClass name , ' fails') errorPrintCR. |
303 | 3692 |
^ false |
474 | 3693 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3694 |
"Modified: 10.1.1997 / 17:58:48 / cg" |
303 | 3695 |
! |
3696 |
||
3697 |
unregisterModule:handle |
|
3698 |
"unregister classes in the VM. |
|
3699 |
This invalidates all of the classes code objects ..." |
|
3700 |
||
3701 |
|id| |
|
3702 |
||
3703 |
Verbose ifTrue:[ |
|
634 | 3704 |
'unregister module; name=' infoPrint. handle pathName infoPrint. |
3705 |
' id=' infoPrint. handle moduleID infoPrintCR. |
|
303 | 3706 |
]. |
3707 |
||
3708 |
id := handle moduleID. |
|
3709 |
%{ |
|
3710 |
__UNREGISTER_BY_ID(__intVal(id)); |
|
3711 |
%} |
|
3712 |
! ! |
|
3713 |
||
369 | 3714 |
!ObjectFileLoader class methodsFor:'documentation'! |
148 | 3715 |
|
3716 |
version |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
3717 |
^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.181 1998-10-01 13:21:33 cg Exp $' |
148 | 3718 |
! ! |
0 | 3719 |
ObjectFileLoader initialize! |