author | sr |
Fri, 03 Jun 2016 14:53:54 +0200 | |
changeset 3904 | cbd7407d4f48 |
parent 3900 | 0f5ffb09e836 |
child 3905 | 9192ece79ae1 |
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 |
" |
|
1116
4cadfbecca99
methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
12 |
"{ Package: 'stx:libcomp' }" |
4cadfbecca99
methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
13 |
|
3556 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
Object subclass:#ObjectFileLoader |
174 | 17 |
instanceVariableNames:'' |
3904 | 18 |
classVariableNames:'ActuallyLoadedObjects CopyLibrariesWhenLoading ErrorPrinting |
19 |
LastError LastErrorNumber LinkErrorMessage LoadedObjects |
|
20 |
MySymbolTable NextHandleID OldSpaceReserve |
|
21 |
PreviouslyLoadedObjects Verbose' |
|
174 | 22 |
poolDictionaries:'' |
23 |
category:'System-Compiler' |
|
47 | 24 |
! |
25 |
||
2627
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
26 |
Error subclass:#ObjectFileLoadError |
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
27 |
instanceVariableNames:'' |
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
28 |
classVariableNames:'' |
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
29 |
poolDictionaries:'' |
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
30 |
privateIn:ObjectFileLoader |
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
31 |
! |
a34348df953a
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
32 |
|
2284
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
33 |
Notification subclass:#ObjectFileLoadErrorNotification |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
34 |
instanceVariableNames:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
35 |
classVariableNames:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
36 |
poolDictionaries:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
37 |
privateIn:ObjectFileLoader |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
38 |
! |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
39 |
|
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
40 |
ObjectFileLoader::ObjectFileLoadErrorNotification subclass:#RegistrationFailedErrorNotification |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
41 |
instanceVariableNames:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
42 |
classVariableNames:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
43 |
poolDictionaries:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
44 |
privateIn:ObjectFileLoader |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
45 |
! |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
46 |
|
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
47 |
ObjectFileLoader::ObjectFileLoadErrorNotification subclass:#SuperClassMissingErrorNotification |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
48 |
instanceVariableNames:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
49 |
classVariableNames:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
50 |
poolDictionaries:'' |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
51 |
privateIn:ObjectFileLoader |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
52 |
! |
ace9886a301e
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2256
diff
changeset
|
53 |
|
53 | 54 |
!ObjectFileLoader primitiveDefinitions! |
0 | 55 |
%{ |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
56 |
|
2999 | 57 |
#undef true |
58 |
#undef false |
|
59 |
||
15 | 60 |
/* |
61 |
* by default, use whatever the system provides |
|
62 |
*/ |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
63 |
#if defined(SYSV4) || defined(HAS_DLOPEN) /* sys5.4 dlopen interface */ |
15 | 64 |
# define SYSV4_DL |
20 | 65 |
# define HAS_DL |
15 | 66 |
#endif |
67 |
||
609 | 68 |
#ifdef __VMS__ |
69 |
# undef __new |
|
70 |
#endif |
|
71 |
||
95 | 72 |
#ifdef DL1_6 /* dl1.6 COFF loader */ |
73 |
# define HAS_DL |
|
74 |
#endif |
|
75 |
||
20 | 76 |
#include <stdio.h> |
77 |
||
95 | 78 |
#ifdef NEXT_DL |
79 |
# ifndef _RLD_H_ |
|
80 |
# define _RLD_H_ |
|
125 | 81 |
# ifdef NEXT3 |
82 |
# include <mach-o/rld.h> |
|
83 |
# else |
|
84 |
# include <rld.h> |
|
85 |
# endif |
|
95 | 86 |
# endif |
87 |
#endif /* NEXT_DL */ |
|
88 |
||
28 | 89 |
#ifdef SYSV4_DL |
1903 | 90 |
# ifndef dlfcn_h |
91 |
# include <dlfcn.h> |
|
92 |
# define dlfcn_h |
|
93 |
# endif |
|
28 | 94 |
#endif |
95 |
||
45 | 96 |
#ifdef GNU_DL |
97 |
# ifndef dld_h |
|
98 |
# include "dld.h" |
|
99 |
# define dld_h |
|
100 |
# endif |
|
101 |
#endif |
|
95 | 102 |
|
103 |
#ifdef DL1_6 |
|
104 |
# ifndef dl_h |
|
105 |
# include "dl.h" |
|
106 |
# define dl_h |
|
107 |
# endif |
|
108 |
#endif |
|
109 |
||
97 | 110 |
#ifdef AIX_DL |
111 |
# include <nlist.h> |
|
100 | 112 |
# include <sys/ldr.h> |
113 |
# include <errno.h> |
|
97 | 114 |
#endif |
180 | 115 |
|
523 | 116 |
#ifdef HPUX10_DL |
1903 | 117 |
# ifndef dl_h |
118 |
# include <dl.h> |
|
119 |
# define dl_h |
|
120 |
# endif |
|
524 | 121 |
# include <errno.h> |
523 | 122 |
#endif |
123 |
||
906 | 124 |
#ifdef BEOS_DL |
125 |
# include <be/kernel/image.h> |
|
126 |
#endif |
|
127 |
||
180 | 128 |
#ifdef WIN_DL |
1906 | 129 |
# undef INT |
2993 | 130 |
# undef UINT |
1906 | 131 |
# undef Array |
132 |
# undef Number |
|
133 |
# undef Method |
|
134 |
# undef Block |
|
135 |
# undef Time |
|
136 |
# undef Date |
|
137 |
# undef Set |
|
138 |
# undef Delay |
|
139 |
# undef Signal |
|
140 |
# undef Context |
|
2114 | 141 |
# undef Message |
142 |
# undef Process |
|
143 |
# undef Processor |
|
2919 | 144 |
# undef Rectangle |
2993 | 145 |
# undef String |
146 |
# undef Character |
|
147 |
# undef Point |
|
148 |
# undef Object |
|
1906 | 149 |
|
150 |
# ifdef __i386__ |
|
151 |
# ifndef _X86_ |
|
152 |
# define _X86_ |
|
729 | 153 |
# endif |
1906 | 154 |
# endif |
155 |
||
156 |
# ifdef __BORLANDC__ |
|
157 |
# define NOATOM |
|
158 |
# define NOUSER |
|
159 |
# define NOGDI |
|
160 |
# define NOGDICAPMASKS |
|
161 |
# define NOMETAFILE |
|
162 |
# define NOMINMAX |
|
163 |
# define NOMSG |
|
164 |
# define NOOPENFILE |
|
165 |
# define NORASTEROPS |
|
166 |
# define NOSCROLL |
|
167 |
# define NOSOUND |
|
168 |
# define NOSYSMETRICS |
|
169 |
# define NOTEXTMETRIC |
|
170 |
# define NOWH |
|
171 |
# define NOCOMM |
|
172 |
# define NOKANJI |
|
173 |
# define NOCRYPT |
|
174 |
# define NOMCX |
|
175 |
# define WIN32_LEAN_AND_MEAN |
|
2920 | 176 |
# include <windows.h> |
177 |
// # include <windef.h> |
|
178 |
// # include <winbase.h> |
|
1906 | 179 |
# else |
2919 | 180 |
# ifdef __VISUALC__ |
2920 | 181 |
// # include <windows.h> |
182 |
# include <windef.h> |
|
183 |
# include <winbase.h> |
|
2919 | 184 |
# else |
2920 | 185 |
# include <windows.h> |
2919 | 186 |
# endif |
187 |
# endif /* BORLANDC */ |
|
188 |
||
1906 | 189 |
|
190 |
# ifdef __DEF_Array |
|
191 |
# define Array __DEF_Array |
|
192 |
# endif |
|
193 |
# ifdef __DEF_Number |
|
194 |
# define Number __DEF_Number |
|
195 |
# endif |
|
196 |
# ifdef __DEF_Method |
|
197 |
# define Method __DEF_Method |
|
198 |
# endif |
|
199 |
# ifdef __DEF_Block |
|
200 |
# define Block __DEF_Block |
|
201 |
# endif |
|
202 |
# ifdef __DEF_Time |
|
203 |
# define Time __DEF_Time |
|
204 |
# endif |
|
205 |
# ifdef __DEF_Date |
|
206 |
# define Date __DEF_Date |
|
207 |
# endif |
|
1010 | 208 |
# ifdef __DEF_Set |
209 |
# define Set __DEF_Set |
|
210 |
# endif |
|
211 |
# ifdef __DEF_Signal |
|
212 |
# define Signal __DEF_Signal |
|
213 |
# endif |
|
214 |
# ifdef __DEF_Delay |
|
215 |
# define Delay __DEF_Delay |
|
216 |
# endif |
|
1175 | 217 |
# ifdef __DEF_Context |
218 |
# define Context __DEF_Context |
|
219 |
# endif |
|
2114 | 220 |
# ifdef __DEF_Message |
221 |
# define Message __DEF_Message |
|
222 |
# endif |
|
223 |
# ifdef __DEF_Process |
|
224 |
# define Process __DEF_Process |
|
225 |
# endif |
|
226 |
# ifdef __DEF_Processor |
|
227 |
# define Processor __DEF_Processor |
|
228 |
# endif |
|
2919 | 229 |
# ifdef __DEF_Rectangle |
230 |
# define Rectangle __DEF_Rectangle |
|
231 |
# endif |
|
2993 | 232 |
# ifdef __DEF_String |
233 |
# define String __DEF_String |
|
234 |
# endif |
|
235 |
# ifdef __DEF_Character |
|
236 |
# define Character __DEF_Character |
|
237 |
# endif |
|
238 |
# ifdef __DEF_Point |
|
239 |
# define Point __DEF_Point |
|
240 |
# endif |
|
241 |
# ifdef __DEF_Object |
|
242 |
# define Object __DEF_Object |
|
243 |
# endif |
|
244 |
||
245 |
||
246 |
# define INT STX_INT |
|
247 |
# define UINT STX_UINT |
|
1974 | 248 |
|
729 | 249 |
#endif /* WIN_DL */ |
1906 | 250 |
|
2998 | 251 |
#undef true |
252 |
#define true __STX_true |
|
2999 | 253 |
|
2998 | 254 |
#undef false |
255 |
#define false __STX_false |
|
256 |
||
0 | 257 |
%} |
20 | 258 |
! ! |
259 |
||
369 | 260 |
!ObjectFileLoader class methodsFor:'documentation'! |
141 | 261 |
|
262 |
copyright |
|
263 |
" |
|
264 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
265 |
All Rights Reserved |
|
266 |
||
267 |
This software is furnished under a license and may be used |
|
268 |
only in accordance with the terms of that license and with the |
|
269 |
inclusion of the above copyright notice. This software may not |
|
270 |
be provided or otherwise made available to, or used by, any |
|
271 |
other person. No title to or ownership of the software is |
|
272 |
hereby transferred. |
|
273 |
" |
|
274 |
! |
|
275 |
||
276 |
documentation |
|
277 |
" |
|
278 |
This class knowns how to dynamically load in external object-modules. |
|
279 |
||
280 |
WARNING: |
|
809 | 281 |
As to date, this is still experimental and WITHOUT ANY WARRANTY. |
282 |
It is still being developed and the code may need some cleanup and more |
|
141 | 283 |
robustness. |
284 |
||
285 |
There are basically two totally different mechanisms to do this: |
|
3890 | 286 |
a) if there exists some dynamic-link facility such as: |
287 |
GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT), |
|
288 |
or LoadLibrary (Win32), this is used |
|
289 |
||
290 |
b) if no such facility exists, the normal linker is used to |
|
291 |
link the module to text/data address as previously malloced, |
|
292 |
and the object file is loaded into that space. |
|
293 |
||
294 |
Not all mechanisms work fully satisfying. |
|
295 |
For example, the sun dl*-functions do an exit on link-errors |
|
296 |
(which is certainly not what we want here :-(; |
|
297 |
the NeXT mechanism does not allow for selective unloading |
|
298 |
(only all or the last loaded module). |
|
845 | 299 |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
300 |
The only really useful packages are the GNU-dl package, |
3890 | 301 |
the SGI/Unixware/sys5.4/linux/osx libdl packages and the win32 dll's. |
809 | 302 |
The GNU-dl package is only available for a.out file formats |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
303 |
(which is more or less obsolete); |
809 | 304 |
|
3890 | 305 |
For the above reasons, dynamic object loading is only |
306 |
officially released for SYS5.4-based, linux, osx and win32 systems. |
|
307 |
||
308 |
When stable, the functionality contained herein will be moved into the VM. |
|
141 | 309 |
(It is needed there, to allow reloading of objectfiles upon |
310 |
image restart; i.e. before any class is reinitialilized). |
|
263 | 311 |
|
3890 | 312 |
Right now, reloading of object files is done by Smalltalk code, |
809 | 313 |
which fails, if code is to be loaded which is required before the |
314 |
load takes place, or which is used by the loader itself. |
|
315 |
(i.e. for now, many primitives from libbasic cannot be dynamically |
|
316 |
loaded at image restart time). |
|
3890 | 317 |
This will fix itself, once we do object file loading in the VM. |
809 | 318 |
|
263 | 319 |
[author:] |
3890 | 320 |
Claus Gittinger |
141 | 321 |
" |
322 |
! ! |
|
323 |
||
369 | 324 |
!ObjectFileLoader class methodsFor:'initialization'! |
0 | 325 |
|
326 |
initialize |
|
1659 | 327 |
|systemType libDir linkCommand linkArgs libPath searchedLibraries| |
0 | 328 |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
329 |
Verbose := false. |
2745 | 330 |
"/ Verbose := true. |
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
331 |
|
759 | 332 |
OperatingSystem isMSDOSlike ifTrue:[ |
2993 | 333 |
"/ default setup for msc |
334 |
ParserFlags useBorlandC ifTrue:[ |
|
335 |
libDir := '..\lib\bc'. |
|
336 |
libDir asFilename exists ifFalse:[ |
|
337 |
libDir := '..\lib\lib\bc'. |
|
338 |
libDir asFilename exists ifFalse:[ |
|
339 |
libDir := '..\lib'. |
|
340 |
] |
|
341 |
]. |
|
342 |
||
343 |
linkCommand isNil ifTrue:[ |
|
344 |
"/ linkCommand := 'tlink32'. |
|
345 |
linkCommand := 'ilink32'. |
|
346 |
]. |
|
347 |
linkArgs isNil ifTrue:[ |
|
348 |
"/ linkArgs := '-L',libDir,' -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ',libDir,'\librun.lib'. |
|
349 |
linkArgs := '-L',libDir,' -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'. |
|
350 |
]. |
|
351 |
searchedLibraries := #( |
|
352 |
'import32.lib' |
|
353 |
). |
|
354 |
] ifFalse:[ |
|
355 |
linkCommand isNil ifTrue:[ |
|
356 |
linkCommand := 'link' |
|
357 |
]. |
|
358 |
linkArgs isNil ifTrue:[ |
|
359 |
linkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def' |
|
360 |
]. |
|
361 |
]. |
|
759 | 362 |
]. |
363 |
||
201 | 364 |
MySymbolTable isNil ifTrue:[ |
2993 | 365 |
NextHandleID := 1. |
366 |
ObjectMemory addDependent:self. |
|
367 |
||
368 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
369 |
searchedLibraries := #( |
|
370 |
'import32.lib' |
|
371 |
). |
|
372 |
]. |
|
373 |
||
374 |
OperatingSystem isUNIXlike ifTrue:[ |
|
375 |
|ldLibraryPath| |
|
376 |
||
377 |
systemType := OperatingSystem getOSType. |
|
378 |
||
379 |
"/ name of object file, where initial symbol table is found |
|
380 |
"/ not req'd for all architectures. |
|
381 |
||
382 |
MySymbolTable := 'stx'. |
|
383 |
||
384 |
searchedLibraries := #(). |
|
385 |
||
386 |
"/ default libraryPath where shared objects are expected |
|
387 |
"/ when a sharedObject load requires other objects to be loaded. |
|
388 |
"/ For more compatibility with ELF systems, look for a shell variable |
|
389 |
"/ named LD_LIBRARY_PATH, and - if present - take that instead if a default. |
|
390 |
"/ Can (should) be set in the smalltalk.rc file. |
|
391 |
||
392 |
ldLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'. |
|
393 |
ldLibraryPath isEmptyOrNil ifTrue:[ |
|
394 |
libPath := '.:lib:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'. |
|
395 |
] ifFalse:[ |
|
396 |
"/ only needed for AIX - the dynamic linker of other Unixes use LD_LIBRARY_PATH implicitly |
|
397 |
systemType = #aix ifTrue:[ |
|
398 |
libPath := ldLibraryPath. |
|
399 |
]. |
|
400 |
] |
|
401 |
] |
|
1659 | 402 |
]. |
403 |
||
404 |
ParserFlags linkCommand:linkCommand. |
|
405 |
ParserFlags linkArgs:linkArgs. |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
406 |
ParserFlags libPath:libPath ? ''. |
1659 | 407 |
ParserFlags searchedLibraries:searchedLibraries. |
107 | 408 |
|
409 |
" |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
410 |
LinkArgs := LinkCommand := nil. |
107 | 411 |
ObjectFileLoader initialize |
412 |
" |
|
316
ee3426730cfc
on sunos: link dynamic objects against libc.a for unresolved symbols.
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
413 |
|
2933 | 414 |
"Modified: / 28-09-2012 / 18:19:28 / cg" |
0 | 415 |
! |
416 |
||
141 | 417 |
lastError |
780
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
418 |
^ LastError ? 'unknown error' |
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
419 |
|
294b6775c8ab
show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
420 |
"Modified: / 30.9.1998 / 17:21:23 / cg" |
141 | 421 |
! |
422 |
||
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
423 |
libPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
424 |
"see comment in #libPath:" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
425 |
|
1659 | 426 |
^ ParserFlags libPath |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
427 |
! |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
428 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
429 |
libPath:aSharedLibraryPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
430 |
"set the pathnames of directories, where other shared objects |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
431 |
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
|
432 |
library object to be loaded. |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
433 |
Currently, this is only required to be set for AIX systems; |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
434 |
ELF based linux and solaris systems specify the libPath in the |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
435 |
LD_LIBRARY_PATH environment variable." |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
436 |
|
1659 | 437 |
ParserFlags libPath:aSharedLibraryPath |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
438 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
439 |
" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
440 |
ObjectFileLoader libPath:'.:/usr/lib:/usr/local/lib' |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
441 |
" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
442 |
! |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
443 |
|
141 | 444 |
linkErrorMessage |
445 |
^ LinkErrorMessage |
|
446 |
! |
|
447 |
||
448 |
searchedLibraries |
|
449 |
"see comment in #searchedLibraries:" |
|
450 |
||
1659 | 451 |
^ ParserFlags searchedLibraries |
141 | 452 |
! |
453 |
||
125 | 454 |
searchedLibraries:aCollectionOfArchivePathNames |
455 |
"set the pathnames of archives which are to be searched |
|
456 |
when unresolved references occur while loading in an object |
|
457 |
file. On systems which support shared libraries (all SYS5.4 based |
|
458 |
systems), this is usually not required. Instead, modules which are to |
|
459 |
be filed in (.so files) are to be prelinked with the appropriate |
|
460 |
shared libraries. The dynamic loader then cares about loading those |
|
461 |
modules (keeping track of which modules are already loaded). |
|
462 |
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
|
463 |
(i.e. currently only linux and a.out-sunos) need to set this." |
125 | 464 |
|
1659 | 465 |
ParserFlags searchedLibraries:aCollectionOfArchivePathNames |
125 | 466 |
! |
467 |
||
741 | 468 |
verbose |
469 |
"return true, if debug traces are turned on" |
|
470 |
||
471 |
^ Verbose |
|
472 |
! |
|
473 |
||
0 | 474 |
verbose:aBoolean |
475 |
"turn on/off debug traces" |
|
476 |
||
10 | 477 |
Verbose := aBoolean |
0 | 478 |
|
479 |
"ObjectFileLoader verbose:true" |
|
480 |
! ! |
|
481 |
||
2982 | 482 |
!ObjectFileLoader class methodsFor:'accessing'! |
483 |
||
484 |
copyLibrariesWhenLoading |
|
485 |
"under windows, a library file (dll) which has been loaded cannot be overwritten. |
|
486 |
This makes it troublesome, to recompile a new lib while a smalltalk is being executed. |
|
487 |
When CopyLibrariesWhenLoading is true, ddl files are copied to a tempdir before loading, |
|
488 |
so that the original can still be recompiled. |
|
489 |
Makes loading a bit slower (due to copying and less sharing/caching of already loaded dlls), |
|
490 |
so it is of by default and must be turned on explicitly during development." |
|
491 |
||
492 |
^ CopyLibrariesWhenLoading ? false |
|
493 |
||
494 |
" |
|
495 |
self copyLibrariesWhenLoading |
|
496 |
self copyLibrariesWhenLoading:true |
|
497 |
" |
|
498 |
! |
|
499 |
||
500 |
copyLibrariesWhenLoading:aBoolean |
|
501 |
"under windows, a library file (dll) which has been loaded cannot be overwritten. |
|
502 |
This makes it troublesome, to recompile a new lib while a smalltalk is being executed. |
|
503 |
When CopyLibrariesWhenLoading is true, ddl files are copied to a tempdir before loading, |
|
504 |
so that the original can still be recompiled. |
|
505 |
Makes loading a bit slower (due to copying and less sharing/caching of already loaded dlls), |
|
506 |
so it is of by default and must be turned on explicitly during development." |
|
507 |
||
508 |
CopyLibrariesWhenLoading := aBoolean. |
|
509 |
||
510 |
" |
|
511 |
self copyLibrariesWhenLoading:true |
|
512 |
" |
|
513 |
! ! |
|
514 |
||
369 | 515 |
!ObjectFileLoader class methodsFor:'change & update'! |
291 | 516 |
|
517 |
update:something with:aParameter from:changedObject |
|
107 | 518 |
"sent, when image is saved or restarted" |
519 |
||
520 |
(something == #aboutToSnapshot) ifTrue:[ |
|
468 | 521 |
self invalidateAndRememberAllObjectFiles |
125 | 522 |
]. |
523 |
(something == #finishedSnapshot) ifTrue:[ |
|
468 | 524 |
self revalidateAllObjectFiles |
107 | 525 |
]. |
226
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
526 |
"/ (something == #restarted) ifTrue:[ |
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
527 |
"/ self reloadAllRememberedObjectFiles |
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
528 |
"/ ]. |
125 | 529 |
|
530 |
"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
|
531 |
"Modified: 8.3.1996 / 23:34:29 / cg" |
291 | 532 |
"Created: 21.6.1996 / 19:50:01 / cg" |
107 | 533 |
! ! |
534 |
||
369 | 535 |
!ObjectFileLoader class methodsFor:'defaults'! |
115 | 536 |
|
141 | 537 |
hasValidBinaryExtension:aFilename |
538 |
"return true, if aFilename looks ok for binary loading. |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
539 |
This checks only the extension - not its contents. |
141 | 540 |
(So an attempt to load the file may fail due to format errors or unresolved symbols) |
541 |
This is very machine specific." |
|
542 |
||
1697 | 543 |
|suffix| |
544 |
||
545 |
suffix := aFilename asFilename suffix. |
|
546 |
^ self validBinaryExtensions includes:suffix. |
|
547 |
"/ |fn| |
|
548 |
"/ |
|
549 |
"/ fn := aFilename asFilename. |
|
550 |
"/ self validBinaryExtensions do:[:ext | |
|
551 |
"/ (fn hasSuffix:ext) ifTrue:[^ true]. |
|
552 |
"/ ]. |
|
553 |
"/ ^ false |
|
141 | 554 |
|
555 |
" |
|
556 |
ObjectFileLoader hasValidBinaryExtension:'foo.st' |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
557 |
ObjectFileLoader hasValidBinaryExtension:'foo.o' |
141 | 558 |
ObjectFileLoader hasValidBinaryExtension:'foo.so' |
516 | 559 |
ObjectFileLoader hasValidBinaryExtension:'foo.dll' |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
560 |
ObjectFileLoader hasValidBinaryExtension:'foo.DLL' |
516 | 561 |
ObjectFileLoader hasValidBinaryExtension:'foo.obj' |
741 | 562 |
ObjectFileLoader hasValidBinaryExtension:'foo.sl' |
141 | 563 |
" |
516 | 564 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
565 |
"Modified: / 1.10.1998 / 12:47:01 / cg" |
141 | 566 |
! |
567 |
||
759 | 568 |
linkArgs |
1659 | 569 |
^ ParserFlags linkArgs |
759 | 570 |
|
571 |
"Created: / 12.8.1998 / 21:41:16 / cg" |
|
572 |
"Modified: / 12.8.1998 / 21:42:50 / cg" |
|
573 |
! |
|
574 |
||
575 |
linkArgs:anArgString |
|
1659 | 576 |
ParserFlags linkArgs:anArgString |
759 | 577 |
|
578 |
" |
|
579 |
MSC: |
|
1906 | 580 |
ParserFlags linkCommand:'link32'. |
581 |
ParserFlags linkArgs:' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def' |
|
759 | 582 |
|
583 |
Borland: |
|
1906 | 584 |
ParserFlags linkCommand:'ilink32'. |
585 |
ParserFlags linkArgs:'-ap -E0 -Tpd -s -c -L\Programme\Borland\CBuilder3\lib -L..\libbc librun.lib import32.lib' |
|
759 | 586 |
' |
587 |
'/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def' |
|
588 |
||
589 |
Unix: |
|
1906 | 590 |
ParserFlags linkCommand:'ld' |
591 |
ParserFlags linkArgs:'-shared' |
|
759 | 592 |
" |
593 |
||
594 |
"Created: / 12.8.1998 / 21:43:16 / cg" |
|
771 | 595 |
"Modified: / 4.9.1998 / 00:33:46 / cg" |
759 | 596 |
! |
597 |
||
598 |
linkCommand |
|
1659 | 599 |
^ ParserFlags linkCommand |
759 | 600 |
|
601 |
"Created: / 12.8.1998 / 21:41:16 / cg" |
|
602 |
! |
|
603 |
||
604 |
linkCommand:aCommand |
|
1659 | 605 |
ParserFlags linkCommand:aCommand |
759 | 606 |
|
607 |
"Created: / 12.8.1998 / 21:40:44 / cg" |
|
608 |
! |
|
609 |
||
1609
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
610 |
linkSharedArgs |
2651 | 611 |
^ ParserFlags linkSharedArgs |
1609
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
612 |
! |
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
613 |
|
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
614 |
linkSharedArgs:anArgString |
1897 | 615 |
ParserFlags linkSharedArgs:anArgString |
1609
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
616 |
|
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
617 |
" |
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
618 |
Linux on AMD64 in 32bit mode: |
1906 | 619 |
LinkSharedArgs := '-shared -m elf_i386' |
1609
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
620 |
" |
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
621 |
! |
ffccd234a5bb
separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents:
1608
diff
changeset
|
622 |
|
188 | 623 |
loadableBinaryObjectFormat |
624 |
"return a symbol describing the expected binary format |
|
625 |
for object files to be loadable. |
|
626 |
This is very machine specific." |
|
627 |
||
628 |
%{ /* NOCONTEXT */ |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
629 |
|
188 | 630 |
#ifdef HAS_DL |
631 |
# if defined(SYSV4) || defined(ELF) |
|
632 |
RETURN ( @symbol(elf)); |
|
633 |
# endif |
|
1607
074a99bb9a50
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
634 |
# if defined(__alpha__) && defined(__osf__) |
590 | 635 |
RETURN ( @symbol(coff)); |
636 |
# endif |
|
188 | 637 |
# if defined(GNU_DL) |
638 |
RETURN ( @symbol(aout)); |
|
639 |
# endif |
|
640 |
# if defined(AIX_DL) |
|
641 |
RETURN ( @symbol(xcoff)); |
|
642 |
# endif |
|
523 | 643 |
# if defined(HPUX10_DL) |
644 |
RETURN ( @symbol(hpcoff)); |
|
645 |
# endif |
|
188 | 646 |
# if defined(DL1_6) |
647 |
RETURN ( @symbol(coff)); |
|
648 |
# endif |
|
649 |
# if defined(WIN_DL) |
|
650 |
RETURN ( @symbol(dll)); |
|
651 |
# endif |
|
906 | 652 |
# if defined(BEOS_DL) |
653 |
RETURN ( @symbol(beobj)); |
|
654 |
# endif |
|
609 | 655 |
# if defined(__VMS__) |
656 |
RETURN ( @symbol(exe)); |
|
657 |
# endif |
|
3107 | 658 |
# if defined(__osx__) |
3054 | 659 |
RETURN ( @symbol(macho)); |
660 |
# endif |
|
188 | 661 |
#endif |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
662 |
|
188 | 663 |
%}. |
664 |
^ nil |
|
665 |
||
666 |
" |
|
667 |
ObjectFileLoader loadableBinaryObjectFormat |
|
668 |
" |
|
669 |
! |
|
670 |
||
141 | 671 |
nm:file |
403 | 672 |
"this should return a string to list the namelist of file. |
673 |
The output of the command should be one line for each symbol, |
|
674 |
formatted as: |
|
2993 | 675 |
addr segment name |
403 | 676 |
This is parsed and read by #namesMatching:segment:in:. |
677 |
||
678 |
If your default nm command cannot produce this, write a little |
|
679 |
shell or awk script, to generate this and return a corresponding command |
|
521 | 680 |
below. |
681 |
This entry is obsolete (no longer req'd) and will vanish." |
|
141 | 682 |
|
683 |
|os| |
|
684 |
||
521 | 685 |
os := OperatingSystem getOSType. |
2935 | 686 |
(os = #irix or:[os = #osf]) ifTrue:[ |
2993 | 687 |
^ 'nm -B ' , file |
403 | 688 |
]. |
2935 | 689 |
(os = #solaris) ifTrue:[ |
2993 | 690 |
^ 'nm -p ' , file |
141 | 691 |
]. |
692 |
^ 'nm ' , file |
|
403 | 693 |
|
702
80f90a274837
more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
694 |
"Modified: / 4.5.1998 / 12:18:47 / cg" |
141 | 695 |
! |
696 |
||
741 | 697 |
objectFileExtension |
698 |
"return the fileName extension used for objects, |
|
699 |
as generated by myself (output of cc). |
|
115 | 700 |
This is very machine specific." |
701 |
||
521 | 702 |
OperatingSystem isMSDOSlike ifTrue:[ |
741 | 703 |
"/ includes all of win32s, win95, winNT & os/2 |
704 |
^ '.obj' |
|
521 | 705 |
]. |
609 | 706 |
OperatingSystem isVMSlike ifTrue:[ |
741 | 707 |
^ '.obj' |
708 |
]. |
|
709 |
||
710 |
^ '.o' |
|
711 |
||
712 |
" |
|
713 |
ObjectFileLoader objectFileExtension |
|
714 |
" |
|
715 |
||
716 |
"Modified: / 4.5.1998 / 12:17:34 / cg" |
|
717 |
! |
|
718 |
||
719 |
sharedLibraryExtension |
|
720 |
"return the fileName extension used for dynamic loadable objects, |
|
721 |
as generated by myself (output of linker). |
|
722 |
This is very machine specific." |
|
723 |
||
1019 | 724 |
|suff| |
725 |
||
726 |
suff := self sharedLibrarySuffix. |
|
727 |
suff notNil ifTrue:[^ '.' , suff]. |
|
728 |
^ suff |
|
729 |
||
730 |
" |
|
731 |
ObjectFileLoader sharedLibraryExtension |
|
732 |
" |
|
733 |
||
734 |
"Modified: / 4.5.1998 / 12:17:34 / cg" |
|
735 |
! |
|
736 |
||
737 |
sharedLibrarySuffix |
|
738 |
"return the fileName suffix used for dynamic loadable objects, |
|
739 |
as generated by myself (output of linker). |
|
740 |
This is very machine specific." |
|
741 |
||
741 | 742 |
|os| |
743 |
||
744 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
3721 | 745 |
"/ includes all Windows systems & os/2 |
746 |
^ 'dll' |
|
741 | 747 |
]. |
748 |
OperatingSystem isVMSlike ifTrue:[ |
|
3721 | 749 |
^ 'exe' |
609 | 750 |
]. |
521 | 751 |
|
115 | 752 |
os := OperatingSystem getSystemType. |
3054 | 753 |
"/ are we really still supporting that old stuff? |
754 |
(self loadableBinaryObjectFormat == #aout) ifTrue:[ |
|
3721 | 755 |
"/ not really shared, but loadable |
756 |
^ 'o' |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
757 |
]. |
2992 | 758 |
(os = #hpux) ifTrue:[ |
3721 | 759 |
^ 'sl' |
2992 | 760 |
]. |
119 | 761 |
|
1287
d1199118e73d
sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents:
1254
diff
changeset
|
762 |
^ 'so' |
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
763 |
|
741 | 764 |
" |
1019 | 765 |
ObjectFileLoader sharedLibrarySuffix |
741 | 766 |
" |
767 |
||
702
80f90a274837
more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
768 |
"Modified: / 4.5.1998 / 12:17:34 / cg" |
115 | 769 |
! |
0 | 770 |
|
2012 | 771 |
useBorlandC |
772 |
^ ParserFlags useBorlandC |
|
773 |
||
774 |
"Created: / 15-03-2007 / 13:32:29 / cg" |
|
775 |
! |
|
776 |
||
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
777 |
validBinaryExtensions |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
778 |
"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
|
779 |
This is very machine specific." |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
780 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
781 |
|os| |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
782 |
|
521 | 783 |
OperatingSystem isMSDOSlike ifTrue:[ |
3721 | 784 |
"/ includes all of win32s, win95, winNT & os/2 |
785 |
^ #('dll') |
|
521 | 786 |
]. |
609 | 787 |
OperatingSystem isVMSlike ifTrue:[ |
3721 | 788 |
^ #('exe') |
609 | 789 |
]. |
521 | 790 |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
791 |
os := OperatingSystem getSystemType. |
2156
2cb69ec50829
#validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents:
2154
diff
changeset
|
792 |
(os = 'linux') ifTrue:[ |
3721 | 793 |
"/ are we really still supporting that old stuff? |
794 |
self loadableBinaryObjectFormat == #aout ifTrue:[ |
|
795 |
^ #('o' 'obj' 'a') |
|
796 |
]. |
|
797 |
^ #('so') |
|
2156
2cb69ec50829
#validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents:
2154
diff
changeset
|
798 |
]. |
2cb69ec50829
#validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents:
2154
diff
changeset
|
799 |
(os = 'hpux') ifTrue:[^ #('sl') ]. |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
800 |
(os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ]. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
801 |
(os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ]. |
2998 | 802 |
|
803 |
"/ a useful default |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
804 |
|
1287
d1199118e73d
sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents:
1254
diff
changeset
|
805 |
^ #('so') |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
806 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
807 |
" |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
808 |
ObjectFileLoader validBinaryExtensions |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
809 |
" |
403 | 810 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
811 |
"Modified: / 1.10.1998 / 12:46:03 / cg" |
141 | 812 |
! ! |
813 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
814 |
!ObjectFileLoader class methodsFor:'dynamic object loading'! |
141 | 815 |
|
816 |
loadCPlusPlusObjectFile:aFileName |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
817 |
"load a c++ object file (.o-file) into the image. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
818 |
This method is not maintained (name mangling and static |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
819 |
initialization is so different among systems ...)" |
141 | 820 |
|
821 |
|handle initAddr list| |
|
822 |
||
823 |
handle := self loadDynamicObject:aFileName. |
|
824 |
handle isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
825 |
^ nil |
141 | 826 |
]. |
827 |
||
609 | 828 |
list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName. |
141 | 829 |
list size == 1 ifTrue:[ |
830 |
"/ (self isCPlusPlusObject:handle) ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
831 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
832 |
'a c++ object file' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
833 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
834 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
835 |
what I would like to get is the CTOR_LIST, |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
836 |
and call each function. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
837 |
But dld cannot (currently) handle SET-type symbols, therefore |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
838 |
we search (using nm) for all __GLOBAL_$I* syms, get their values |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
839 |
and call them each |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
840 |
" |
609 | 841 |
"/ list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName. |
141 | 842 |
|
843 |
"/ initAddr := self getFunction:'__CTOR_LIST__' from:handle. |
|
844 |
"/ Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
845 |
"/ ('calling CTORs at:' , (initAddr printStringRadix:16)) errorPrintCR |
141 | 846 |
"/ ]. |
847 |
||
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
848 |
initAddr := self getFunction:list first from:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
849 |
initAddr isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
850 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
851 |
try with added underscore |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
852 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
853 |
initAddr := self getFunction:('_' , list first) from:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
854 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
855 |
(initAddr isNil and:[list first startsWith:'_']) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
856 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
857 |
try with removed underscore |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
858 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
859 |
initAddr := self getFunction:(list first copyFrom:2) from:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
860 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
861 |
initAddr isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
862 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
863 |
('no CTOR-func found (' , list first , ')') errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
864 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
865 |
self unloadDynamicObject:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
866 |
^ nil |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
867 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
868 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
869 |
('calling CTORs at:' , (initAddr printStringRadix:16)) errorPrintCR |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
870 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
871 |
self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
872 |
saveCallInitFunctionAt:initAddr |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
873 |
in:aFileName |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
874 |
specialInit:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
875 |
forceOld:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
876 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
877 |
argument:0 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
878 |
identifyAs:nil |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
879 |
returnsObject:false. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
880 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
881 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
882 |
'done with CTORs.' errorPrintCR |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
883 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
884 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
885 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
886 |
cannot create a CPlusPlus class automatically (there could be more than |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
887 |
one classes in it too ...) |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
888 |
" |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
889 |
^ handle |
141 | 890 |
]. |
891 |
||
892 |
||
893 |
Verbose ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
894 |
'unknown object file' errorPrintCR |
141 | 895 |
]. |
2348
b2a3bb714bf6
comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents:
2346
diff
changeset
|
896 |
self unloadDynamicObject:handle. |
141 | 897 |
^ nil |
272 | 898 |
|
2459 | 899 |
"Modified: / 15-11-2010 / 13:19:06 / cg" |
141 | 900 |
! |
901 |
||
902 |
loadClass:aClassName fromObjectFile:aFileName |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
903 |
"load a compiled class (.o-file) into the image. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
904 |
Returns the class or nil." |
141 | 905 |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
906 |
|handle initAddr symName newClass moreHandles info status |
141 | 907 |
otherClass knownToBeOk| |
908 |
||
909 |
handle := self loadDynamicObject:aFileName. |
|
910 |
handle isNil ifTrue:[ |
|
3721 | 911 |
^ nil |
141 | 912 |
]. |
913 |
||
914 |
" |
|
915 |
get the Init-function; let the class install itself |
|
916 |
" |
|
917 |
symName := '_' , aClassName , '_Init'. |
|
918 |
initAddr := self getFunction:symName from:handle. |
|
919 |
initAddr isNil ifTrue:[ |
|
3721 | 920 |
"try with added underscore" |
921 |
symName := '__' , aClassName , '_Init'. |
|
922 |
initAddr := self getFunction:symName from:handle. |
|
141 | 923 |
]. |
924 |
||
925 |
knownToBeOk := true. |
|
926 |
||
927 |
"/ knownToBeOk ifFalse:[ |
|
468 | 928 |
"/ |list| |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
929 |
"/ |
141 | 930 |
"/ Verbose ifTrue:[ |
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
931 |
"/ 'looking for undefs ...' errorPrintCR. |
141 | 932 |
"/ ]. |
933 |
"/ |
|
934 |
"/ " |
|
935 |
"/ if there are any undefined symbols, we may have to load more |
|
936 |
"/ files (libs, other modules) |
|
937 |
"/ " |
|
938 |
"/ list := self getListOfUndefinedSymbolsFrom:handle. |
|
939 |
"/ list notNil ifTrue:[ |
|
940 |
"/ moreHandles := self loadModulesFromListOfUndefined:list. |
|
941 |
"/ |
|
942 |
"/ " |
|
943 |
"/ now, try again |
|
944 |
"/ " |
|
945 |
"/ symName := '_' , aClassName , '_Init'. |
|
946 |
"/ initAddr := self getFunction:symName from:handle. |
|
947 |
"/ initAddr isNil ifTrue:[ |
|
948 |
"/ "try with added underscore" |
|
949 |
"/ symName := '__' , aClassName , '_Init'. |
|
950 |
"/ initAddr := self getFunction:symName from:handle. |
|
951 |
"/ ]. |
|
952 |
"/ ] |
|
953 |
"/ ]. |
|
954 |
||
955 |
initAddr notNil ifTrue:[ |
|
3721 | 956 |
Verbose ifTrue:[ |
957 |
('calling init at: ' , (initAddr printStringRadix:16)) errorPrintCR. |
|
958 |
]. |
|
959 |
info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle. |
|
960 |
status := info at:1. |
|
961 |
" |
|
962 |
if any classes are missing ... |
|
963 |
" |
|
964 |
(status == #missingClass) ifTrue:[ |
|
965 |
" |
|
966 |
... and we are loading a module ... |
|
967 |
" |
|
968 |
Transcript showCR:'ObjectFileLoader [info]: try for missing class in same object ...'. |
|
969 |
Verbose ifTrue:[ |
|
970 |
'try for missing class:' errorPrint. (info at:2) errorPrintCR. |
|
971 |
]. |
|
972 |
otherClass := self loadClass:(info at:2) fromObjectFile:aFileName. |
|
973 |
otherClass notNil ifTrue:[ |
|
974 |
" |
|
975 |
try again ... |
|
976 |
" |
|
977 |
Transcript showCR:'ObjectFileLoader [info]: missing class is here; try again ...'. |
|
978 |
info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle. |
|
979 |
status := info at:1. |
|
980 |
] |
|
981 |
]. |
|
982 |
||
983 |
Verbose ifTrue:[ |
|
984 |
'done init status=' errorPrint. info errorPrintCR. |
|
985 |
]. |
|
986 |
(status == #unregisteredSuperclass) ifTrue:[ |
|
987 |
Transcript showCR:'ObjectFileLoader [info]: superclass is not registered'. |
|
988 |
]. |
|
989 |
||
990 |
(Symbol hasInterned:aClassName) ifTrue:[ |
|
991 |
newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil]. |
|
992 |
Verbose ifTrue:[ |
|
993 |
'newClass is: ' errorPrint. newClass errorPrintCR |
|
994 |
]. |
|
995 |
newClass notNil ifTrue:[ |
|
996 |
Smalltalk at:aClassName asSymbol put:newClass. |
|
997 |
||
998 |
(newClass includesSelector:#initialize) ifTrue:[ |
|
999 |
Verbose ifTrue:[ |
|
1000 |
'initialize newClass ...' errorPrintCR |
|
1001 |
]. |
|
1002 |
newClass initialize. |
|
1003 |
]. |
|
1004 |
"force cache flush" |
|
1005 |
Smalltalk isInitialized ifTrue:[ |
|
1006 |
Smalltalk changed. |
|
1007 |
] |
|
1008 |
]. |
|
1009 |
] ifFalse:[ |
|
1010 |
'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint. |
|
1011 |
' did not define itself' errorPrintCR |
|
1012 |
" |
|
1013 |
do not unload - could have installed other classes/methods ... |
|
1014 |
" |
|
1015 |
]. |
|
1016 |
^ newClass |
|
141 | 1017 |
]. |
1018 |
||
1019 |
Verbose ifTrue:[ |
|
3721 | 1020 |
('no symbol: ', symName,' in ',aFileName) errorPrintCR. |
141 | 1021 |
]. |
1022 |
||
1023 |
" |
|
1024 |
unload |
|
1025 |
" |
|
1026 |
Verbose ifTrue:[ |
|
3721 | 1027 |
'unloading due to init failure:' errorPrint. handle pathName errorPrintCR. |
141 | 1028 |
]. |
1029 |
||
3038 | 1030 |
"/ moreHandles notNil ifTrue:[ |
1031 |
"/ moreHandles do:[:eachHandle | |
|
1032 |
"/ Verbose ifTrue:[ |
|
1033 |
"/ ('unloading: ', eachHandle printString) errorPrintCR. |
|
1034 |
"/ ]. |
|
1035 |
"/ self unloadDynamicObject:eachHandle. |
|
1036 |
"/ ] |
|
1037 |
"/ ]. |
|
141 | 1038 |
|
1039 |
Verbose ifTrue:[ |
|
3721 | 1040 |
('unloading: ', handle printString) errorPrintCR. |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1041 |
]. |
141 | 1042 |
self unloadDynamicObject:handle. |
1043 |
^ nil |
|
1044 |
||
1045 |
" |
|
1046 |
ObjectFileLoader loadClass:'Tetris' fromObjectFile:'../clients/Tetris/Tetris.o' |
|
1047 |
ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o' |
|
1048 |
ObjectFileLoader loadClass:'Foo' fromObjectFile:'classList.o' |
|
1049 |
" |
|
272 | 1050 |
|
582
9a00e2dbdc97
must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents:
580
diff
changeset
|
1051 |
"Modified: 6.7.1997 / 12:34:48 / cg" |
141 | 1052 |
! |
1053 |
||
504 | 1054 |
loadLibrary:aLibraryFileName |
1055 |
"load a library; search in some standard places and using |
|
1056 |
standard suffixes (i.e. no suffix should be given in the arg). |
|
1057 |
Returns a handle or nil. |
|
1058 |
Use this to attach C-libraries." |
|
1059 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1060 |
|s suffixes handle libFilename libPath| |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1061 |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1062 |
Verbose ifTrue:[ |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1063 |
('loadLibrary:' , aLibraryFileName) errorPrintCR. |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1064 |
]. |
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1065 |
libFilename := aLibraryFileName asFilename. |
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
1066 |
(s := libFilename suffix) isEmpty ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1067 |
suffixes := self validBinaryExtensions |
504 | 1068 |
] ifFalse:[ |
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1069 |
suffixes := Array with:s |
504 | 1070 |
]. |
1071 |
||
1072 |
"/ try each suffix ... |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1073 |
suffixes do:[:aSuffix | |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1074 |
|fn f| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1075 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1076 |
aSuffix isEmptyOrNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1077 |
fn := libFilename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1078 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1079 |
fn := libFilename withSuffix:aSuffix. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1080 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1081 |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1082 |
Verbose ifTrue:[ |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1083 |
('loadLibrary try:' , fn asString) errorPrintCR. |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1084 |
]. |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1085 |
|
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1086 |
handle := self loadObjectFile:fn asString. |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1087 |
handle notNil ifTrue:[^ handle]. |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1088 |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1089 |
(libFilename isAbsolute |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1090 |
or:[(aLibraryFileName startsWith:'./') |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1091 |
or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[ |
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1092 |
"/ already tried... |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1093 |
] ifFalse:[ |
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1094 |
"/ try to load it by name - maybe someone else knows |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1095 |
"/ how to find it (the system itself) |
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1096 |
|
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1097 |
"/ try each directory in libPath |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1098 |
libPath := self libPath. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1099 |
libPath notEmptyOrNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1100 |
(libPath asCollectionOfSubstringsSeparatedBy:$:) do:[:eachSinglePath | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1101 |
f := eachSinglePath asFilename construct:fn. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1102 |
f exists ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1103 |
handle := self loadObjectFile:f pathName. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1104 |
handle notNil ifTrue:[^ handle]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1105 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1106 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1107 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1108 |
] |
504 | 1109 |
]. |
1110 |
||
1111 |
^ nil |
|
1112 |
||
1113 |
" |
|
1114 |
ObjectFileLoader loadLibrary:'libjpeg' |
|
845 | 1115 |
ObjectFileLoader loadLibrary:'odbc32' |
504 | 1116 |
" |
1117 |
||
845 | 1118 |
"Modified: / 4.5.1999 / 17:01:47 / cg" |
504 | 1119 |
! |
1120 |
||
174 | 1121 |
loadMethodObjectFile:aFileName |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1122 |
"load an object file (.o-file) for a single method into the image; |
174 | 1123 |
This does a slightly different initialization. |
1124 |
Return an object handle; nil on error" |
|
1125 |
||
346 | 1126 |
|handle initAddr initName m| |
174 | 1127 |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1128 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1129 |
"/ load the objectfile |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1130 |
"/ |
174 | 1131 |
handle := self loadDynamicObject:aFileName. |
1132 |
handle isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1133 |
^ nil |
174 | 1134 |
]. |
1135 |
||
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1136 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1137 |
"/ find the entry function |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1138 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
1139 |
initName := aFileName asFilename withoutSuffix baseName. |
174 | 1140 |
|
1141 |
initAddr := self getFunction:'__' , initName , '_Init' from:handle. |
|
1142 |
initAddr isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1143 |
initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1144 |
initAddr isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1145 |
(self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1146 |
self listUndefinedSymbolsIn:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1147 |
'ObjectFileLoader [info]: undefined symbols in primitive code' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1148 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1149 |
('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1150 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1151 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1152 |
"/ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1153 |
"/ not found - unload |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1154 |
"/ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1155 |
self unloadDynamicObject:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1156 |
^ nil |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1157 |
] |
174 | 1158 |
]. |
1159 |
||
1555 | 1160 |
OSSignalInterrupt handle:[:ex | |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1161 |
('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1162 |
self unloadDynamicObject:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1163 |
^ nil |
790 | 1164 |
] do:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1165 |
"/ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1166 |
"/ call it - it returns the new method object |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1167 |
"/ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1168 |
self "/ registration |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1169 |
saveCallInitFunctionAt:initAddr |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1170 |
in:aFileName |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1171 |
specialInit:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1172 |
forceOld:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1173 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1174 |
argument:0 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1175 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1176 |
returnsObject:false. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1177 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1178 |
self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1179 |
saveCallInitFunctionAt:initAddr "/ global setup |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1180 |
in:aFileName |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1181 |
specialInit:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1182 |
forceOld:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1183 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1184 |
argument:1 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1185 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1186 |
returnsObject:false. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1187 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1188 |
m := self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1189 |
saveCallInitFunctionAt:initAddr "/ initialization |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1190 |
in:aFileName |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1191 |
specialInit:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1192 |
forceOld:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1193 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1194 |
argument:2 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1195 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1196 |
returnsObject:true. |
790 | 1197 |
]. |
174 | 1198 |
|
1199 |
handle method:m. |
|
1200 |
^ handle |
|
1201 |
||
1942
dffae6fd22d8
oops - initialization of single-method objects needs phase1
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1202 |
"Created: / 05-12-1995 / 20:59:46 / cg" |
2459 | 1203 |
"Modified: / 15-11-2010 / 13:20:36 / cg" |
174 | 1204 |
! |
1205 |
||
141 | 1206 |
loadObjectFile:aFileName |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1207 |
"load an object file (.o-file) into the image; |
141 | 1208 |
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
|
1209 |
This may be either a smalltalk object or a C-object file. |
472 | 1210 |
The object files init function (if any) is called, and the module |
1211 |
is unloaded if it returns failure (use lowLevel load, to load a file |
|
1212 |
without automatic initialization). |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1213 |
Return nil on error, an objectFile handle if ok." |
141 | 1214 |
|
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1215 |
^ self |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1216 |
loadObjectFile:aFileName |
1010 | 1217 |
invokeInitializeMethods:true |
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1218 |
! |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1219 |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1220 |
loadObjectFile:pathNameOrFilename invokeInitializeMethods:invokeInitializeMethods |
1993
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1221 |
"load an object file (.dll or .so-file) into the image; |
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1222 |
the class name is not needed (multiple definitions may be in the file). |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1223 |
This may be either a smalltalk object or a C-object file. |
3006 | 1224 |
The object file's init function (if any) is called, and the module |
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1225 |
is unloaded if it returns failure (use lowLevel load, to load a file |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
1226 |
without automatic initialization). |
3006 | 1227 |
Returns nil on error, or the objectFile's handle if ok." |
1228 |
||
1229 |
|filename pathName handle initAddr initDefinitionAddr initFunctionName initNames didInit info status |
|
3736 | 1230 |
dummyHandle msg isCModule doNotUnload definitionClassName definitionClass cRetVal| |
141 | 1231 |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1232 |
filename := pathNameOrFilename asFilename. |
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1233 |
pathName := filename pathName. |
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1234 |
|
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1235 |
handle := self handleForDynamicObject:filename. |
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
1236 |
handle notNil ifTrue:[ |
3736 | 1237 |
"already loaded" |
1238 |
^ handle. |
|
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
1239 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
1240 |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
1241 |
handle := self loadDynamicObject:filename. |
141 | 1242 |
handle isNil ifTrue:[ |
3736 | 1243 |
^ nil |
141 | 1244 |
]. |
1245 |
||
1246 |
didInit := false. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1247 |
isCModule := false. |
141 | 1248 |
|
1993
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1249 |
"with dld, load may have worked, even if undefined symbols |
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1250 |
are to be resolved. If that's the case, load all libraries ..." |
141 | 1251 |
|
3890 | 1252 |
ParserFlags searchedLibraries notEmptyOrNil ifTrue:[ |
3736 | 1253 |
(self hasUndefinedSymbolsIn:handle) ifTrue:[ |
1254 |
self initializeLoader. |
|
1255 |
||
1256 |
ParserFlags searchedLibraries do:[:libName | |
|
1257 |
(self hasUndefinedSymbolsIn:handle) ifTrue:[ |
|
3895 | 1258 |
Logger info:' ... trying %1 to resolve undefined symbols ...' with:libName. |
3736 | 1259 |
dummyHandle := Array new:4. |
1260 |
dummyHandle := self primLoadDynamicObject:libName into:dummyHandle. |
|
228
be9939d96cfe
removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents:
227
diff
changeset
|
1261 |
"/ dummyHandle isNil ifTrue:[ |
272 | 1262 |
"/ Transcript showCR:' ... load of library ' , libName , ' failed.'. |
228
be9939d96cfe
removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents:
227
diff
changeset
|
1263 |
"/ ] |
3736 | 1264 |
] |
1265 |
]. |
|
1266 |
(self hasUndefinedSymbolsIn:handle) isNil ifTrue:[ |
|
3895 | 1267 |
Logger info:'still undefined symbols in %1.' with:pathName. |
3736 | 1268 |
]. |
1269 |
] |
|
141 | 1270 |
]. |
2882
e7fb69ba1a54
Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents:
2806
diff
changeset
|
1271 |
|
141 | 1272 |
" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1273 |
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
|
1274 |
(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
|
1275 |
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
|
1276 |
scheme as well) |
141 | 1277 |
" |
3006 | 1278 |
initFunctionName := self initFunctionBasenameForFile:filename. |
1279 |
||
1280 |
"look for explicit initDefinition (xxx_InitDefinition) function |
|
1281 |
This is used in ST packaged classLib object files" |
|
1282 |
||
3029 | 1283 |
(initFunctionName startsWith:'lib') ifTrue:[ |
3736 | 1284 |
definitionClassName := initFunctionName copyFrom:4. |
1285 |
definitionClass := Smalltalk classNamed:definitionClassName. |
|
3029 | 1286 |
]. |
3030 | 1287 |
(definitionClass isNil or:[definitionClass isLoaded not]) ifTrue:[ |
3736 | 1288 |
"the project definition class has not been loaded yet. |
1289 |
initialize and load it" |
|
1290 |
||
1291 |
initDefinitionAddr := self findInitDefinitionFunction:initFunctionName in:handle. |
|
1292 |
initDefinitionAddr isNil ifTrue:[ |
|
1293 |
('WARNING: no init definitions for: ' , pathName) errorPrintCR. |
|
1294 |
] ifFalse:[ |
|
1295 |
Verbose ifTrue:[ |
|
1296 |
('calling initDefinition at:' , (initDefinitionAddr printStringRadix:16)) errorPrintCR. |
|
1297 |
]. |
|
1298 |
info := self |
|
1299 |
performModuleInitAt:initDefinitionAddr |
|
1300 |
invokeInitializeMethods:false |
|
1301 |
for:definitionClassName |
|
1302 |
identifyAs:handle. |
|
1303 |
status := info at:1. |
|
1304 |
status == #ok ifTrue:[ |
|
1305 |
"/ now, we have only loaded and installed the projectDefinition class. |
|
1306 |
"/ (but no containing classes or extensions, yet). |
|
1307 |
"/ let the projectDefinition load any prereqs |
|
1308 |
definitionClassName notNil ifTrue:[ |
|
1309 |
definitionClass := Smalltalk classNamed:definitionClassName. |
|
1310 |
definitionClass notNil ifTrue:[ |
|
3900 | 1311 |
"/ "if projectDefinition denies loading, unload" |
1312 |
"/ self unloadDynamicObject:handle. |
|
3895 | 1313 |
|
3736 | 1314 |
definitionClass |
3900 | 1315 |
checkForLoad; "/ raise exception if not supported on platform / not licensed |
3736 | 1316 |
initialize; |
3895 | 1317 |
preLoadAction; |
3736 | 1318 |
loadMandatoryPreRequisitesAsAutoloaded:false. |
1319 |
]. |
|
1320 |
]. |
|
1321 |
] |
|
1322 |
]. |
|
3006 | 1323 |
]. |
1993
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1324 |
"look for explicit init (xxx_Init) function |
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1325 |
This is used in ST object files" |
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1326 |
|
3006 | 1327 |
initAddr := self findInitFunction:initFunctionName in:handle. |
141 | 1328 |
initAddr notNil ifTrue:[ |
3736 | 1329 |
Verbose ifTrue:[ |
1330 |
('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR. |
|
1331 |
]. |
|
1332 |
info := self |
|
1333 |
performModuleInitAt:initAddr |
|
1334 |
invokeInitializeMethods:invokeInitializeMethods |
|
1335 |
for:nil |
|
1336 |
identifyAs:handle. |
|
1337 |
status := info at:1. |
|
1338 |
status == #ok ifTrue:[ |
|
1339 |
didInit := true. |
|
1340 |
definitionClassName notNil ifTrue:[ |
|
1341 |
definitionClass := Smalltalk classNamed:definitionClassName. |
|
1342 |
] |
|
1343 |
] |
|
141 | 1344 |
] ifFalse:[ |
3736 | 1345 |
"look for explicit C-init (xxx__Init) function |
1346 |
This is used in C object files" |
|
1347 |
||
1348 |
initAddr := self findFunction:initFunctionName suffix:'__Init' in:handle. |
|
1349 |
initAddr notNil ifTrue:[ |
|
1350 |
isCModule := true. |
|
1351 |
||
1352 |
OSSignalInterrupt handle:[:ex | |
|
3895 | 1353 |
Logger error:'hard error in initFunction of class-module: %1' with:pathName. |
3736 | 1354 |
status := #initFailed. |
1355 |
] do:[ |
|
1356 |
cRetVal := self |
|
1357 |
saveCallInitFunctionAt:initAddr |
|
1358 |
in:pathNameOrFilename |
|
1359 |
specialInit:false |
|
1360 |
forceOld:true |
|
1361 |
interruptable:false |
|
1362 |
argument:0 |
|
1363 |
identifyAs:handle |
|
1364 |
returnsObject:false. |
|
1365 |
(cRetVal < 0) ifTrue:[ |
|
1366 |
Verbose ifTrue:[ |
|
1367 |
'init function return failure ... unload' errorPrintCR. |
|
1368 |
]. |
|
1369 |
status := #initFailed. |
|
1370 |
] ifFalse:[ |
|
1371 |
didInit := true. |
|
1372 |
] |
|
1373 |
] |
|
1374 |
] ifFalse:[ |
|
1375 |
status := #noInitFunction. |
|
1376 |
||
1377 |
"look for any init-function(s); call them all" |
|
1378 |
Verbose ifTrue:[ |
|
1379 |
'no good init functions found; looking for candidates ...' errorPrintCR. |
|
1380 |
]. |
|
1381 |
initNames := self namesMatching:'*_Init' segment:'[tT?]' in:pathName. |
|
1382 |
initNames notNil ifTrue:[ |
|
1383 |
initNames do:[:aName | |
|
1384 |
initAddr := self getFunction:aName from:handle. |
|
1385 |
initAddr isNil ifTrue:[ |
|
1386 |
(aName startsWith:'_') ifTrue:[ |
|
1387 |
initAddr := self getFunction:(aName copyFrom:2) from:handle. |
|
1388 |
]. |
|
1389 |
]. |
|
1390 |
initAddr isNil ifTrue:[ |
|
1391 |
Transcript showCR:('no symbol: ',aName,' in ', pathName). |
|
1392 |
] ifFalse:[ |
|
1393 |
Verbose ifTrue:[ |
|
1394 |
('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR |
|
1395 |
]. |
|
1396 |
self |
|
1397 |
performModuleInitAt:initAddr |
|
1398 |
invokeInitializeMethods:invokeInitializeMethods |
|
1399 |
for:nil |
|
1400 |
identifyAs:handle. |
|
1401 |
didInit := true. |
|
1402 |
] |
|
1403 |
]. |
|
1404 |
]. |
|
1405 |
] |
|
141 | 1406 |
]. |
1407 |
||
2457
1927f463ca87
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2456
diff
changeset
|
1408 |
(invokeInitializeMethods and:[didInit not]) ifTrue:[ |
3736 | 1409 |
status == #noInitFunction ifTrue:[ |
1410 |
msg := 'no classLib init function found; assume load ok' |
|
1411 |
] ifFalse:[ |
|
1412 |
(status ~~ #registrationFailed |
|
1413 |
and:[status ~~ #initFailed |
|
1414 |
and:[status ~~ #missingClass |
|
1415 |
and:[status ~~ #versionMismatch]]]) |
|
1416 |
ifTrue:[ |
|
1417 |
self listUndefinedSymbolsIn:handle. |
|
1418 |
]. |
|
1419 |
||
1420 |
Verbose ifTrue:[ |
|
1421 |
'unloading, since init failed ...' errorPrintCR. |
|
1422 |
]. |
|
1423 |
||
1424 |
"/ give caller a chance to prevent unloading (to register later, when a prerequisite class comes) |
|
1425 |
status == #missingClass ifTrue:[ |
|
1426 |
doNotUnload := (SuperClassMissingErrorNotification query ? false). |
|
1427 |
] ifFalse:[ |
|
1428 |
status == #registrationFailed ifTrue:[ |
|
1429 |
doNotUnload := (RegistrationFailedErrorNotification query ? false). |
|
1430 |
] ifFalse:[ |
|
1431 |
doNotUnload := false. |
|
1432 |
]. |
|
1433 |
]. |
|
1434 |
doNotUnload ifFalse:[ |
|
1435 |
self unloadDynamicObject:handle. |
|
1436 |
Verbose ifTrue:[ |
|
1437 |
'unloaded.' errorPrintCR. |
|
1438 |
]. |
|
1439 |
handle := nil. |
|
1440 |
]. |
|
1441 |
||
1442 |
status == #initFailed ifTrue:[ |
|
1443 |
msg := 'module not loaded (init function signaled failure).' |
|
1444 |
] ifFalse:[ |
|
1445 |
status == #missingClass ifTrue:[ |
|
1446 |
msg := 'module not loaded (superclass missing: ' , (info at:2) , ').' |
|
1447 |
] ifFalse:[ |
|
1448 |
status == #registrationFailed ifTrue:[ |
|
1449 |
msg := 'module registration failed (incompatible object or missing superclass)' |
|
1450 |
] ifFalse:[ |
|
1451 |
status == #versionMismatch ifTrue:[ |
|
1452 |
msg := 'module registration failed (class version mismatch ' , (info at:2) printString , ')' |
|
1453 |
] ifFalse:[ |
|
1454 |
(self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:pathName) notNil ifTrue:[ |
|
1455 |
msg := 'module not loaded (unknown error reason).' |
|
1456 |
] ifFalse:[ |
|
1457 |
msg := 'module not loaded (no _Init entry in object file ?).' |
|
1458 |
] |
|
1459 |
] |
|
1460 |
]. |
|
1461 |
]. |
|
1462 |
]. |
|
1463 |
]. |
|
3895 | 1464 |
Logger info:'%1: %2' with:pathNameOrFilename asFilename baseName with:msg. |
141 | 1465 |
]. |
1466 |
||
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1467 |
isCModule ifFalse:[ |
3736 | 1468 |
Smalltalk flushCachedClasses. |
1469 |
Class flushSubclassInfo. |
|
1470 |
||
1471 |
(definitionClass notNil and:[definitionClass isLoaded]) ifTrue:[ |
|
3900 | 1472 |
definitionClass |
1473 |
checkForLoad; "/ raise exception if not supported on platform / not licensed |
|
1474 |
loadAllClassesAsAutoloaded:true; |
|
1475 |
loadPreRequisitesAsAutoloaded:true; "/ load non-mandatory prerequisites |
|
1476 |
projectIsLoaded:true. "/ this performs the postLoadAction, too. |
|
3736 | 1477 |
]. |
1478 |
Smalltalk isInitialized ifTrue:[ |
|
1479 |
"really don't know, if and what has changed ... |
|
1480 |
... but assume, that new classes have been installed." |
|
1481 |
Smalltalk changed:#postLoad. |
|
1482 |
]. |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
1483 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1484 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1485 |
|
2459 | 1486 |
"Modified: / 15-11-2010 / 13:19:26 / cg" |
141 | 1487 |
! |
1488 |
||
1489 |
unloadAllObsoleteObjectFiles |
|
1490 |
"unload all dynamically loaded object files for which the classes/method |
|
1491 |
has been already garbage collected." |
|
1492 |
||
1493 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1494 |
LoadedObjects values copy do:[:eachHandle | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1495 |
(eachHandle notNil and:[eachHandle isObsolete]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1496 |
self unloadDynamicObject:eachHandle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1497 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1498 |
] |
141 | 1499 |
]. |
1500 |
||
1501 |
" |
|
1502 |
ObjectFileLoader unloadAllObsoleteObjectFiles |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1503 |
" |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1504 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1505 |
"Modified: 5.12.1995 / 18:16:52 / cg" |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1506 |
! |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1507 |
|
141 | 1508 |
unloadObjectFile:aFileName |
1509 |
"unload an object file (.o-file) from the image. |
|
1510 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1511 |
objects of this module exist - in future versions, the system will keep |
|
1512 |
track of these. For now, use at your own risk. |
|
1513 |
(especially critical are blocks-functions)." |
|
1514 |
||
1515 |
|handle| |
|
1516 |
||
1517 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1518 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
141 | 1519 |
]. |
1520 |
handle isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1521 |
('ObjectFileLoader [info]: oops - file to be unloaded was not loaded dynamically (', aFileName , ')') infoPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1522 |
^ self |
141 | 1523 |
]. |
1524 |
||
2348
b2a3bb714bf6
comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents:
2346
diff
changeset
|
1525 |
"/ call the modules deInit-function and unload... |
141 | 1526 |
self unloadDynamicObject:handle |
1961 | 1527 |
|
1528 |
"Modified: / 06-12-2006 / 18:19:13 / cg" |
|
634 | 1529 |
! |
1530 |
||
1531 |
unloadObjectFileAndRemoveClasses:aFileName |
|
1532 |
"unload an object file (.o-file) from the image and remove all |
|
1533 |
corresponding classes from the system. |
|
1534 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1535 |
objects of this module exist - in future versions, the system will keep |
|
1536 |
track of these. For now, use at your own risk. |
|
1537 |
(especially critical are blocks-functions)." |
|
1538 |
||
1539 |
|handle| |
|
1540 |
||
1541 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1542 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
634 | 1543 |
]. |
1544 |
handle isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1545 |
('ObjectFileLoader [info]: oops - file to be unloaded was not loaded dynamically (', (aFileName ? 'unknown-file') , ')') infoPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1546 |
^ self |
634 | 1547 |
]. |
1548 |
handle isClassLibHandle ifFalse:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1549 |
self error:'Module is not a classLib module. Proceed to unload anyway' mayProceed:true. |
634 | 1550 |
]. |
1551 |
||
1552 |
"/ remove the classes ... |
|
1553 |
Class withoutUpdatingChangesDo:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1554 |
handle classes do:[:eachClass | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1555 |
(eachClass notNil and:[eachClass isMeta not]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1556 |
eachClass removeFromSystem. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1557 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1558 |
] |
634 | 1559 |
]. |
1560 |
||
2348
b2a3bb714bf6
comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents:
2346
diff
changeset
|
1561 |
"/ call the modules deInit-function and unload... |
634 | 1562 |
self unloadDynamicObject:handle |
1563 |
||
1961 | 1564 |
"Modified: / 06-12-2006 / 18:19:19 / cg" |
141 | 1565 |
! ! |
1566 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1567 |
!ObjectFileLoader class methodsFor:'dynamic object queries'! |
141 | 1568 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1569 |
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
|
1570 |
"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
|
1571 |
|
609 | 1572 |
|initAddr className nm| |
1573 |
||
1574 |
"/ care for colons, as found in nameSpace classes ... |
|
3499 | 1575 |
nm := functionName asString. |
1576 |
nm := nm copyReplaceAll:$: with:$_ ifNone:nm. |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1577 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1578 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1579 |
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
|
1580 |
" |
609 | 1581 |
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
|
1582 |
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
|
1583 |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1584 |
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
|
1585 |
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
|
1586 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1587 |
"/ |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1588 |
"/ special for broken ultrix nlist |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1589 |
"/ (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
|
1590 |
"/ 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
|
1591 |
"/ |
609 | 1592 |
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
|
1593 |
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
|
1594 |
|
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1595 |
(functionName startsWith:'lib') ifTrue:[ |
3721 | 1596 |
className := functionName |
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1597 |
] ifFalse:[ |
3721 | 1598 |
" |
1599 |
look for reverse abbreviation - slow, because abbrevs are recursively read |
|
1600 |
" |
|
1601 |
className := Smalltalk classNameForFile:functionName. |
|
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1602 |
]. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1603 |
className notNil ifTrue:[ |
3721 | 1604 |
initAddr := self getFunction:(className , suffix) from:handle. |
1605 |
initAddr notNil ifTrue:[^ initAddr]. |
|
1606 |
||
1607 |
initAddr := self getFunction:('_' , className , suffix) from:handle. |
|
1608 |
initAddr isNil ifTrue:[ |
|
1609 |
"/ |
|
1610 |
"/ special for broken ultrix nlist |
|
1611 |
"/ (will not find symbol with single underscore) |
|
1612 |
"/ workaround: add another underscore and retry |
|
1613 |
"/ |
|
1614 |
initAddr := self getFunction:('__' , className , suffix) from:handle. |
|
1615 |
]. |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1616 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1617 |
^ initAddr |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1618 |
|
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1619 |
"Created: / 13-07-1996 / 00:38:01 / cg" |
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1620 |
"Modified: / 16-01-2012 / 19:57:11 / cg" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1621 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1622 |
|
3006 | 1623 |
findInitDefinitionFunction:functionName in:handle |
1624 |
"look for the initDefinition function and return its address or nil" |
|
1625 |
||
1626 |
^ self findFunction:functionName suffix:'_InitDefinition' in:handle |
|
1627 |
||
1628 |
"Modified: 13.7.1996 / 00:38:33 / cg" |
|
1629 |
! |
|
1630 |
||
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1631 |
findInitFunction:functionName in:handle |
3006 | 1632 |
"look for the init function and return its address or nil" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1633 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1634 |
^ 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
|
1635 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1636 |
"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
|
1637 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1638 |
|
1745 | 1639 |
getFunction:aStringOrSymbol from:handle |
141 | 1640 |
"return the address of a function from a dynamically loaded object file. |
1641 |
Handle must be the one returned previously from loadDynamicObject. |
|
1642 |
Return the address of the function, or nil on any error." |
|
1643 |
||
1745 | 1644 |
^ self getSymbol:aStringOrSymbol asString function:true from:handle |
141 | 1645 |
! |
1646 |
||
1647 |
getListOfUndefinedSymbolsFrom:aHandle |
|
1648 |
"return a collection of undefined symbols in a dynamically loaded object file. |
|
1649 |
Handle must be the one returned previously from loadDynamicObject. |
|
1650 |
Not all systems allow an object with undefined symbols to be |
|
1651 |
loaded (actually, only dld does)." |
|
1652 |
||
1653 |
|list| |
|
1654 |
||
1655 |
%{ /* STACK: 20000 */ |
|
1656 |
#ifdef GNU_DL |
|
1657 |
void (*func)(); |
|
1658 |
unsigned long addr; |
|
1659 |
char *name; |
|
1660 |
int nMax; |
|
1661 |
char **undefNames; |
|
1662 |
||
1663 |
undefNames = dld_list_undefined_sym(); |
|
1664 |
if (dld_undefined_sym_count > 0) { |
|
1665 |
char **nm; |
|
1666 |
int index; |
|
1667 |
int count = dld_undefined_sym_count; |
|
1668 |
||
1669 |
if (count > 100) count = 100; |
|
1670 |
list = __ARRAY_NEW_INT(count); |
|
1671 |
if (list) { |
|
1672 |
nm = undefNames; |
|
1673 |
for (index = 0; index < count; index++) { |
|
1674 |
OBJ s; |
|
1675 |
||
238 | 1676 |
s = __MKSTRING(*nm); |
1677 |
__ArrayInstPtr(list)->a_element[index] = s; |
|
141 | 1678 |
__STORE(list, s); |
1679 |
nm++; |
|
1680 |
} |
|
1681 |
free(undefNames); |
|
1682 |
} |
|
1683 |
} |
|
1684 |
#endif |
|
1685 |
||
1686 |
#ifdef DL1_6 |
|
1687 |
/* |
|
2998 | 1688 |
* don't know how to do it |
141 | 1689 |
*/ |
1690 |
#endif |
|
1691 |
||
1692 |
#ifdef SYSV4_DL |
|
1693 |
/* |
|
2998 | 1694 |
* don't know how to do it |
141 | 1695 |
*/ |
1696 |
#endif |
|
1697 |
||
1698 |
#ifdef SUN_DL |
|
1699 |
/* |
|
2998 | 1700 |
* don't know how to do it |
141 | 1701 |
*/ |
1702 |
#endif |
|
1703 |
||
1704 |
#ifdef NEXT_DL |
|
1705 |
/* |
|
2998 | 1706 |
* don't know how to do it |
141 | 1707 |
*/ |
1708 |
#endif |
|
180 | 1709 |
|
1710 |
#ifdef WIN_DL |
|
1711 |
/* |
|
2998 | 1712 |
* don't know how to do it |
180 | 1713 |
*/ |
1714 |
#endif |
|
1715 |
||
906 | 1716 |
#ifdef BEOS_DL |
1717 |
/* |
|
2998 | 1718 |
* don't know how to do it |
906 | 1719 |
*/ |
1720 |
#endif |
|
1721 |
||
141 | 1722 |
%}. |
1723 |
^ list |
|
1724 |
! |
|
1725 |
||
1726 |
getSymbol:aString function:isFunction from:aHandle |
|
1727 |
"return the address of a symbol/function from a dynamically loaded object file. |
|
1728 |
Handle must be the one returned previously from loadDynamicObject. |
|
1729 |
Return the address of the symbol, or nil on any error." |
|
1730 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1731 |
|sysHandle1 sysHandle2 pathName address| |
141 | 1732 |
|
1733 |
sysHandle1 := aHandle sysHandle1. |
|
1734 |
sysHandle2 := aHandle sysHandle2. |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1735 |
pathName := aHandle pathName. |
141 | 1736 |
|
1737 |
%{ /* STACK: 20000 */ |
|
1738 |
||
1739 |
#ifdef GNU_DL |
|
1740 |
{ |
|
1741 |
void (*func)(); |
|
2998 | 1742 |
unsigned INT addr; |
141 | 1743 |
char *name; |
1744 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
1745 |
if (__isStringLike(aString)) { |
3721 | 1746 |
name = (char *) __stringVal(aString); |
1747 |
if (isFunction == false) { |
|
1748 |
addr = dld_get_symbol(name); |
|
1749 |
if (addr) { |
|
1750 |
if (@global(Verbose) == true) { |
|
1751 |
console_printf("addr of %s = %x\n", name, addr); |
|
1752 |
} |
|
1753 |
address = __MKUINT( addr ); |
|
1754 |
} |
|
1755 |
} else { |
|
1756 |
func = (void (*) ()) dld_get_func(name); |
|
1757 |
if (func) { |
|
1758 |
if (@global(Verbose) == true) { |
|
1759 |
console_printf("addr of %s = %x\n", name, (INT)func); |
|
1760 |
} |
|
1761 |
if (dld_function_executable_p(name)) { |
|
1762 |
address = __MKUINT( (INT)func ); |
|
1763 |
} else { |
|
1764 |
char **undefNames; |
|
1765 |
char **nm; |
|
1766 |
int i; |
|
1767 |
||
1768 |
if (@global(Verbose) == true) { |
|
1769 |
console_printf ("function %s not executable\n", name); |
|
1770 |
dld_perror("not executable"); |
|
1771 |
||
1772 |
console_printf("undefined:\n"); |
|
1773 |
nm = undefNames = dld_list_undefined_sym(); |
|
1774 |
for (i=dld_undefined_sym_count; i; i--) { |
|
1775 |
console_printf(" %s\n", *nm++); |
|
1776 |
} |
|
1777 |
free(undefNames); |
|
1778 |
} |
|
1779 |
} |
|
1780 |
} else { |
|
1781 |
if (@global(Verbose) == true) { |
|
1782 |
console_printf ("function %s not found\n", name); |
|
1783 |
dld_perror("get_func"); |
|
1784 |
} |
|
1785 |
} |
|
1786 |
} |
|
141 | 1787 |
} |
1788 |
} |
|
1789 |
#endif /* GNU_DL */ |
|
1790 |
||
180 | 1791 |
#ifdef WIN_DL |
1792 |
{ |
|
1793 |
void *h; |
|
1794 |
void *addr; |
|
701 | 1795 |
INT val; |
180 | 1796 |
FARPROC entry; |
1797 |
HMODULE handle; |
|
1798 |
||
1799 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
3001 | 1800 |
# if __POINTER_SIZE__ == 8 |
3721 | 1801 |
val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1); |
3001 | 1802 |
# else |
3721 | 1803 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
3001 | 1804 |
# endif |
3721 | 1805 |
handle = (HMODULE)(val); |
1806 |
if (__isStringLike(aString)) { |
|
1807 |
if (@global(Verbose) == true) |
|
1808 |
console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle); |
|
1809 |
entry = GetProcAddress(handle, (char *) __stringVal(aString)); |
|
1810 |
if (entry != NULL) { |
|
1811 |
addr = (void *)entry; |
|
1812 |
if (@global(Verbose) == true) { |
|
1813 |
console_printf("GetProcAddr %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr); |
|
1814 |
} |
|
3723 | 1815 |
address = __MKUINT( (INT)addr ); |
3721 | 1816 |
} else { |
1817 |
if (@global(Verbose) == true) { |
|
1818 |
console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError()); |
|
1819 |
} |
|
1820 |
} |
|
1821 |
} |
|
180 | 1822 |
} |
1823 |
} |
|
1824 |
#endif |
|
1825 |
||
906 | 1826 |
#ifdef BEOS_DL |
1827 |
{ |
|
1828 |
void *h; |
|
1829 |
void *addr; |
|
1830 |
INT val; |
|
1831 |
void *handle; |
|
1832 |
||
1833 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
3001 | 1834 |
# if __POINTER_SIZE__ == 8 |
3721 | 1835 |
val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1); |
3001 | 1836 |
# else |
3721 | 1837 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
3001 | 1838 |
# endif |
3721 | 1839 |
handle = (void *)(val); |
1840 |
||
1841 |
if (__isStringLike(aString)) { |
|
1842 |
if (@global(Verbose) == true) |
|
3723 | 1843 |
console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle); |
3721 | 1844 |
entry = NULL; |
1845 |
get_image_symbol((image_id) handle, (char *) __stringVal(aString), B_SYMBOL_TYPE_TEXT, &entry); |
|
1846 |
if (entry != NULL) { |
|
1847 |
addr = (void *)entry; |
|
1848 |
if (@global(Verbose) == true) { |
|
1849 |
console_printf("get_image_symbol %s ok; addr = %x\n", __stringVal(aString), addr); |
|
1850 |
} |
|
3723 | 1851 |
address = __MKUINT( (INT)addr ); |
3721 | 1852 |
} else { |
1853 |
if (@global(Verbose) == true) { |
|
1854 |
console_printf("get_image_symbol %s error\n", __stringVal(aString)); |
|
1855 |
} |
|
1856 |
} |
|
1857 |
} |
|
906 | 1858 |
} |
1859 |
} |
|
1860 |
#endif |
|
1861 |
||
141 | 1862 |
#ifdef DL1_6 |
1863 |
{ |
|
1864 |
void *h; |
|
1865 |
void *addr; |
|
701 | 1866 |
INT val; |
141 | 1867 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
1868 |
if (__isStringLike(aString)) { |
3721 | 1869 |
if (__isStringLike(sysHandle1)) { |
1870 |
if (@global(Verbose) == true) |
|
1871 |
console_printf("get sym <%s> handle = %x\n", |
|
1872 |
__stringVal(aString), __stringVal(sysHandle1)); |
|
1873 |
addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString)); |
|
1874 |
if (addr) { |
|
1875 |
if (@global(Verbose) == true) |
|
1876 |
console_printf("addr = %x\n", addr); |
|
3723 | 1877 |
address = __MKUINT( (INT)addr ); |
3721 | 1878 |
} else { |
1879 |
if (@global(Verbose) == true) |
|
1880 |
console_printf("dl_getsymbol %s failed\n", __stringVal(aString)); |
|
1881 |
} |
|
1882 |
} |
|
141 | 1883 |
} |
1884 |
} |
|
1885 |
#endif |
|
1886 |
||
1887 |
#ifdef SYSV4_DL |
|
1888 |
{ |
|
1889 |
void *h; |
|
1890 |
void *addr; |
|
701 | 1891 |
INT val; |
141 | 1892 |
OBJ low = sysHandle1, hi = sysHandle2; |
701 | 1893 |
extern void *dlsym(); |
141 | 1894 |
|
1895 |
if (__bothSmallInteger(low, hi)) { |
|
3001 | 1896 |
# if __POINTER_SIZE__ == 8 |
3721 | 1897 |
val = (__intVal(hi) << 32) + __intVal(low); |
3001 | 1898 |
# else |
3721 | 1899 |
val = (__intVal(hi) << 16) + __intVal(low); |
3001 | 1900 |
# endif |
3721 | 1901 |
h = (void *)(val); |
1902 |
if (__isStringLike(aString)) { |
|
1903 |
if (@global(Verbose) == true) { |
|
1904 |
console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)h); |
|
1905 |
} |
|
1906 |
addr = dlsym(h, (char *) __stringVal(aString)); |
|
1907 |
if (addr) { |
|
1908 |
if (@global(Verbose) == true) { |
|
1909 |
console_printf("dlsym %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr); |
|
1910 |
} |
|
1911 |
address = __MKUINT( (INT)addr ); |
|
1912 |
} else { |
|
1913 |
if (@global(Verbose) == true) { |
|
1914 |
console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
|
1915 |
} |
|
1916 |
} |
|
1917 |
} |
|
141 | 1918 |
} |
1919 |
} |
|
1920 |
#endif |
|
1921 |
||
523 | 1922 |
#ifdef HPUX10_DL |
1923 |
{ |
|
1924 |
void *h; |
|
1925 |
void *addr; |
|
701 | 1926 |
INT val, ret; |
523 | 1927 |
OBJ low = sysHandle1, hi = sysHandle2; |
1928 |
||
1929 |
if (__bothSmallInteger(low, hi)) { |
|
3001 | 1930 |
# if __POINTER_SIZE__ == 8 |
3721 | 1931 |
val = (__intVal(hi) << 32) + __intVal(low); |
3001 | 1932 |
# else |
3721 | 1933 |
val = (_intVal(hi) << 16) + _intVal(low); |
3001 | 1934 |
# endif |
3721 | 1935 |
h = (void *)(val); |
1936 |
if (__isStringLike(aString)) { |
|
1937 |
if (@global(Verbose) == true) { |
|
1938 |
console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
|
1939 |
} |
|
1940 |
ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr); |
|
1941 |
if (ret != 0) { |
|
1942 |
if (@global(Verbose) == true) { |
|
1943 |
console_printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno); |
|
1944 |
} |
|
1945 |
} else { |
|
1946 |
if (@global(Verbose) == true) { |
|
1947 |
console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr); |
|
1948 |
} |
|
1949 |
address = __MKUINT( (INT)addr ); |
|
1950 |
} |
|
1951 |
} |
|
523 | 1952 |
} |
1953 |
} |
|
1954 |
#endif |
|
1955 |
||
1956 |
||
141 | 1957 |
#ifdef AIX_DL |
1958 |
{ |
|
1959 |
void *h; |
|
1960 |
void *addr; |
|
3001 | 1961 |
INT val; |
141 | 1962 |
struct nlist nl[2]; |
1963 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1964 |
char nameBuffer[256]; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1965 |
static struct funcDescriptor { |
3721 | 1966 |
unsigned vaddr; |
1967 |
unsigned long2; |
|
1968 |
unsigned long3; |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1969 |
} descriptor; |
141 | 1970 |
|
1971 |
if (__bothSmallInteger(low, hi) |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
1972 |
&& __isStringLike(aString) && __isStringLike(pathName)) { |
3001 | 1973 |
# if __POINTER_SIZE__ == 8 |
3721 | 1974 |
val = (__intVal(hi) << 32) + __intVal(low); |
3001 | 1975 |
# else |
3721 | 1976 |
val = (__intVal(hi) << 16) + __intVal(low); |
3001 | 1977 |
# endif |
3721 | 1978 |
h = (void *)(val); |
1979 |
||
1980 |
if (@global(Verbose) == true) { |
|
1981 |
console_printf("get sym <%s> handle = %x path= %s\n", |
|
1982 |
__stringVal(aString), h, __stringVal(pathName)); |
|
1983 |
} |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1984 |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1985 |
#define USE_ENTRY |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1986 |
#ifdef USE_ENTRY |
3721 | 1987 |
/* |
1988 |
* only works, if the entry-function is the Init function |
|
1989 |
* (i.e. linked with -e _xxx_Init) |
|
1990 |
*/ |
|
1991 |
if (@global(Verbose) == true) { |
|
1992 |
console_printf("returned handle as addr = %x\n", h); |
|
1993 |
} |
|
3723 | 1994 |
address = __MKUINT( (INT)(h) ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1995 |
#else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1996 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1997 |
# ifdef USE_DESCRIPTOR |
3721 | 1998 |
if (isFunction == true) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1999 |
# else |
3721 | 2000 |
if (0) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2001 |
# endif |
3721 | 2002 |
nameBuffer[0] = '.'; |
2003 |
strcpy(nameBuffer+1, aString); |
|
2004 |
nl[0].n_name = nameBuffer; |
|
2005 |
} else { |
|
2006 |
nl[0].n_name = __stringVal(aString); |
|
2007 |
} |
|
2008 |
nl[1].n_name = ""; |
|
2009 |
||
2010 |
if (nlist(__stringVal(pathName), &nl) == -1) { |
|
2011 |
if (@global(Verbose) == true) { |
|
2012 |
console_printf("nlist error\n"); |
|
2013 |
} |
|
2014 |
} else { |
|
2015 |
addr = (void *)((unsigned)nl[0].n_value + (unsigned)h); |
|
2016 |
||
2017 |
if (isFunction == true) { |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2018 |
# ifdef USE_DESCRIPTOR |
3721 | 2019 |
console_printf("daddr = %x\n", addr); |
2020 |
console_printf("daddr[0] = %x\n", ((long *)addr)[0]); |
|
2021 |
console_printf("daddr[1] = %x\n", ((long *)addr)[1]); |
|
2022 |
console_printf("daddr[2] = %x\n", ((long *)addr)[2]); |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2023 |
# endif |
3721 | 2024 |
} |
2025 |
||
2026 |
if (@global(Verbose) == true) { |
|
2027 |
console_printf("value=%x section=%d type=%x sclass=%d\n", |
|
2028 |
nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass); |
|
2029 |
console_printf("vaddr = %x\n", addr); |
|
2030 |
} |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2031 |
# ifdef DOES_NOT_WORK |
3723 | 2032 |
address = __MKUINT( (INT)addr ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2033 |
# else |
3723 | 2034 |
descriptor.vaddr = (unsigned INT) addr; |
3721 | 2035 |
descriptor.long2 = 0; |
2036 |
descriptor.long3 = 0; |
|
3723 | 2037 |
address = __MKUINT( (INT)(&descriptor) ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2038 |
# endif |
3721 | 2039 |
} |
2998 | 2040 |
#endif /* don't USE_ENTRY */ |
141 | 2041 |
} |
2042 |
} |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2043 |
#endif /* AIX_DL */ |
141 | 2044 |
|
523 | 2045 |
|
141 | 2046 |
#ifdef SUN_DL |
2047 |
{ |
|
2048 |
void *h; |
|
2049 |
void *addr; |
|
3723 | 2050 |
INT val; |
141 | 2051 |
OBJ low = sysHandle1, hi = sysHandle2; |
2052 |
||
2053 |
if (__bothSmallInteger(low, hi)) { |
|
3721 | 2054 |
val = (_intVal(hi) << 16) + _intVal(low); |
2055 |
h = (void *)(val); |
|
2056 |
if (__isStringLike(aString)) { |
|
2057 |
if (@global(Verbose) == true) { |
|
2058 |
console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
|
2059 |
} |
|
2060 |
addr = dlsym(h, __stringVal(aString)); |
|
2061 |
if (addr) { |
|
2062 |
if (@global(Verbose) == true) { |
|
2063 |
console_printf("addr = %x\n", addr); |
|
2064 |
} |
|
3723 | 2065 |
address = __MKUINT( (INT)addr ); |
3721 | 2066 |
} else { |
2067 |
if (@global(Verbose) == true) { |
|
2068 |
console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
|
2069 |
} |
|
2070 |
} |
|
2071 |
} |
|
141 | 2072 |
} |
2073 |
} |
|
2074 |
#endif |
|
2075 |
||
523 | 2076 |
|
141 | 2077 |
#ifdef NEXT_DL |
2078 |
{ |
|
2079 |
unsigned long addr; |
|
2080 |
long result; |
|
2081 |
NXStream *errOut; |
|
2082 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
2083 |
if (__isStringLike(aString)) { |
3721 | 2084 |
if (@global(Verbose) == true) { |
2085 |
console_printf("get sym <%s>\n", __stringVal(aString)); |
|
2086 |
} |
|
2087 |
errOut = NXOpenFile(2, 2); |
|
2088 |
result = rld_lookup(errOut, |
|
2089 |
(char *) __stringVal(aString), |
|
2090 |
&addr); |
|
2091 |
NXClose(errOut); |
|
2092 |
if (result) { |
|
2093 |
if (@global(Verbose) == true) { |
|
2094 |
console_printf("addr = %x\n", addr); |
|
2095 |
} |
|
3723 | 2096 |
address = __MKUINT( (INT)addr ); |
3721 | 2097 |
} |
141 | 2098 |
} |
2099 |
} |
|
2100 |
#endif |
|
180 | 2101 |
|
141 | 2102 |
%}. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2103 |
^ address |
141 | 2104 |
! |
2105 |
||
2106 |
hasUndefinedSymbolsIn:handle |
|
259 | 2107 |
"return true, if a module has undefined symbols in it. |
2108 |
This is only possible if the system supports loading |
|
2109 |
modules with undefined things in it - most do not" |
|
2110 |
||
141 | 2111 |
^ (self getListOfUndefinedSymbolsFrom:handle) size > 0 |
259 | 2112 |
|
2113 |
"Modified: 25.4.1996 / 09:47:27 / cg" |
|
141 | 2114 |
! |
2115 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2116 |
initFunctionBasenameForFile:pathNameOrFilename |
3006 | 2117 |
"return the expected initFunction's name, given a fileName" |
2118 |
||
2119 |
|fileName name suffixLen| |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2120 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2121 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2122 |
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
|
2123 |
" |
3006 | 2124 |
fileName := pathNameOrFilename asFilename. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2125 |
suffixLen := 0. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2126 |
self validBinaryExtensions do:[:suffix | |
3721 | 2127 |
suffixLen == 0 ifTrue:[ |
2128 |
(fileName hasSuffix:suffix) ifTrue:[ |
|
2129 |
suffixLen := suffix size + 1 |
|
2130 |
] |
|
2131 |
] |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2132 |
]. |
3006 | 2133 |
name := fileName baseName. |
403 | 2134 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2135 |
suffixLen ~~ 0 ifTrue:[ |
3721 | 2136 |
name := name copyButLast:suffixLen |
3006 | 2137 |
] ifFalse:[ |
3721 | 2138 |
('ObjectFileLoader [warning]: invalid binary object file suffix in: ',fileName name) infoPrintCR. |
2139 |
name := fileName withoutSuffix baseName |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2140 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2141 |
^ name. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2142 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2143 |
" |
3006 | 2144 |
ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.so' (unix) |
2145 |
ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.dll' (msdos) |
|
3721 | 2146 |
ObjectFileLoader initFunctionBasenameForFile:'demo.so' |
2147 |
ObjectFileLoader initFunctionBasenameForFile:'demo.o' |
|
2148 |
ObjectFileLoader initFunctionBasenameForFile:'demo.obj' |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2149 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2150 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
2151 |
"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
|
2152 |
"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
|
2153 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2154 |
|
141 | 2155 |
isCPlusPlusObject:handle |
259 | 2156 |
"return true, if the loaded object is a c++ object module. |
2157 |
This is not yet fully implemented/supported." |
|
141 | 2158 |
|
2159 |
(self getSymbol:'__gnu_compiled_cplusplus' function:true from:handle) notNil ifTrue:[^ true]. |
|
2160 |
(self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true]. |
|
2161 |
(self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true]. |
|
2162 |
(self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true]. |
|
6 | 2163 |
^ false |
259 | 2164 |
|
2165 |
"Modified: 25.4.1996 / 09:48:19 / cg" |
|
0 | 2166 |
! |
2167 |
||
141 | 2168 |
isObjectiveCObject:handle |
259 | 2169 |
"return true, if the loaded object is an objective-C object module. |
2170 |
This is not yet implemented/supported" |
|
141 | 2171 |
|
2172 |
^ false |
|
259 | 2173 |
|
2174 |
"Modified: 25.4.1996 / 09:47:59 / cg" |
|
141 | 2175 |
! |
2176 |
||
2177 |
isSmalltalkObject:handle |
|
2178 |
"return true, if the loaded object is a smalltalk object module" |
|
2179 |
||
2180 |
"not yet implemented - stc_compiled_smalltalk is a static symbol, |
|
2181 |
not found in list - need nm-interface, or nlist-walker |
|
2182 |
" |
|
2183 |
^ true. |
|
2184 |
||
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
2185 |
"/ (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
|
2186 |
"/ (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
|
2187 |
"/ ^ false |
141 | 2188 |
! |
2189 |
||
2190 |
listUndefinedSymbolsIn:handle |
|
259 | 2191 |
"list undefined objects in a module on the transcript" |
2192 |
||
141 | 2193 |
|undefinedNames| |
2194 |
||
2195 |
undefinedNames := self getListOfUndefinedSymbolsFrom:handle. |
|
2196 |
undefinedNames size > 0 ifTrue:[ |
|
3721 | 2197 |
Transcript showCR:'ObjectFileLoader [info]: undefined:'. |
2198 |
undefinedNames do:[:aName | |
|
2199 |
Transcript showCR:' ' , aName |
|
2200 |
] |
|
141 | 2201 |
]. |
259 | 2202 |
|
272 | 2203 |
"Modified: 18.5.1996 / 15:43:45 / cg" |
141 | 2204 |
! |
2205 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2206 |
namesMatching:aPattern segment:segmentPattern in:aPathName |
521 | 2207 |
"search for entries which match a pattern. |
2208 |
This is obsolete & rubbish - it will vanish soon" |
|
141 | 2209 |
|
2210 |
|p l s addr segment name entry| |
|
2211 |
||
766 | 2212 |
OperatingSystem isVMSlike ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2213 |
"/ no nm command |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2214 |
^ nil |
766 | 2215 |
]. |
2216 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2217 |
"/ no nm command |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2218 |
^ nil |
609 | 2219 |
]. |
521 | 2220 |
OperatingSystem getOSType = 'aix' ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2221 |
"/ no useful nm info |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2222 |
^ nil |
749 | 2223 |
]. |
141 | 2224 |
|
2225 |
l := OrderedCollection new. |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2226 |
p := PipeStream readingFrom:(self nm:aPathName). |
141 | 2227 |
p isNil ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2228 |
('ObjectFileLoader [info]: cannot read names from ' , aPathName) infoPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2229 |
^ nil |
141 | 2230 |
]. |
2231 |
[p atEnd] whileFalse:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2232 |
entry := p nextLine. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2233 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2234 |
entry errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2235 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2236 |
entry notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2237 |
s := ReadStream on:entry. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2238 |
addr := s nextAlphaNumericWord. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2239 |
s skipSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2240 |
segment := s upToSeparator. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2241 |
s skipSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2242 |
name := s upToEnd withoutSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2243 |
(addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2244 |
(aPattern match:name) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2245 |
(segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2246 |
l add:name. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2247 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2248 |
('found name: ' , name) errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2249 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2250 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2251 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2252 |
name errorPrint. ' segment mismatch ' errorPrint. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2253 |
segmentPattern errorPrint. ' ' errorPrint. segment errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2254 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2255 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2256 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2257 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2258 |
] |
0 | 2259 |
]. |
141 | 2260 |
p close. |
2261 |
^ l |
|
225 | 2262 |
|
749 | 2263 |
"Modified: / 27.7.1998 / 20:10:57 / cg" |
141 | 2264 |
! |
2265 |
||
2266 |
releaseSymbolTable |
|
2267 |
"this is needed on NeXT to forget loaded names. If this wasnt done, |
|
2268 |
the same class could not be loaded in again due to multiple defines. |
|
2269 |
On other architectures, this is not needed and therefore a noop." |
|
2270 |
||
2271 |
%{ |
|
2272 |
#ifdef NEXT_DL |
|
2273 |
NXStream *errOut; |
|
2274 |
||
2275 |
errOut = NXOpenFile(2, 2); |
|
2276 |
rld_unload_all(errOut, (long)0); |
|
2277 |
rld_load_basefile(errOut, "smalltalk"); |
|
2278 |
NXClose(errOut); |
|
2279 |
#endif |
|
2280 |
%} |
|
303 | 2281 |
! ! |
2282 |
||
369 | 2283 |
!ObjectFileLoader class methodsFor:'image save/restart'! |
303 | 2284 |
|
2285 |
invalidateAndRememberAllObjectFiles |
|
2286 |
"invalidate code refs into all dynamically loaded object files. |
|
2287 |
Required before writing a snapshot image." |
|
2288 |
||
2289 |
LoadedObjects notNil ifTrue:[ |
|
468 | 2290 |
ActuallyLoadedObjects := LoadedObjects. |
2291 |
self rememberAllObjectFiles. |
|
2292 |
ActuallyLoadedObjects keys do:[:aFileName | |
|
2293 |
|handle| |
|
2294 |
||
2295 |
handle := ActuallyLoadedObjects at:aFileName. |
|
2296 |
handle isNil ifTrue:[ |
|
2297 |
self error:'oops, no handle'. |
|
2298 |
] ifFalse:[ |
|
2299 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
2300 |
self invalidateModule:handle |
|
2301 |
] |
|
2302 |
] |
|
2303 |
]. |
|
2304 |
LoadedObjects := nil. |
|
303 | 2305 |
]. |
2306 |
||
2307 |
"Created: 5.10.1995 / 15:48:56 / claus" |
|
2308 |
"Modified: 5.10.1995 / 16:48:51 / claus" |
|
2309 |
"Modified: 12.7.1996 / 17:13:45 / cg" |
|
28 | 2310 |
! |
6 | 2311 |
|
303 | 2312 |
reloadAllRememberedObjectFiles |
2313 |
"reload all object modules as were loaded when the image was saved. |
|
2314 |
Some care has to be taken, if files are missing or otherwise corrupted." |
|
2315 |
||
2882
e7fb69ba1a54
Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents:
2806
diff
changeset
|
2316 |
|oldDummyMethod who newHandle |
e7fb69ba1a54
Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents:
2806
diff
changeset
|
2317 |
savedOldClasses functions saveOldMethodsPerClass anyModulesToInitialize m| |
303 | 2318 |
|
2319 |
PreviouslyLoadedObjects notNil ifTrue:[ |
|
3721 | 2320 |
anyModulesToInitialize := false. |
2321 |
||
2322 |
PreviouslyLoadedObjects do:[:entry | |
|
2323 |
|fileName handle cls sel| |
|
2324 |
||
2325 |
fileName := entry key. |
|
2326 |
handle := entry value. |
|
2327 |
handle moduleID:nil. |
|
2328 |
||
2329 |
handle isClassLibHandle ifTrue:[ |
|
2330 |
"/ ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR. |
|
2331 |
||
2332 |
"/ |
|
2333 |
"/ remember all byteCode methods (as added in the session) |
|
2334 |
"/ |
|
2335 |
savedOldClasses := IdentitySet new. |
|
2336 |
saveOldMethodsPerClass := IdentityDictionary new. |
|
2337 |
||
2338 |
handle classes do:[:eachClass | |
|
2339 |
(eachClass notNil and:[eachClass ~~ 0]) ifTrue:[ |
|
2340 |
saveOldMethodsPerClass at:eachClass put:eachClass methodDictionary copy. |
|
2341 |
savedOldClasses add:eachClass. |
|
2342 |
]. |
|
2343 |
]. |
|
2344 |
"/ |
|
2345 |
"/ load the class binary |
|
2346 |
"/ |
|
2347 |
handle := self loadObjectFile:fileName invokeInitializeMethods:false. |
|
2348 |
handle notNil ifTrue:[ |
|
2349 |
anyModulesToInitialize := true |
|
2350 |
]. |
|
2351 |
||
2352 |
"/ after reloading of the objectFile, |
|
2353 |
"/ some of the changes made in the previous life have to be |
|
2354 |
"/ redone here - otherwise, we will be left with the |
|
2355 |
"/ state contained in the loaded objectModule - instead of |
|
2356 |
"/ what we had when saving the image ... |
|
2357 |
||
2358 |
||
2359 |
"/ |
|
2360 |
"/ re-remove removed methods |
|
2361 |
"/ and re-change method categories |
|
2362 |
"/ |
|
2363 |
savedOldClasses do:[:oldClass | |
|
2364 |
|newClass oldMethods newMethodDict newMthd |
|
2365 |
oldCat oldClassVarString oldClassCategory| |
|
2366 |
||
2367 |
newClass := Smalltalk classNamed:(oldClass name). |
|
2368 |
newClass notNil ifTrue:[ |
|
2369 |
oldClassVarString := oldClass classVariableString. |
|
2370 |
newClass classVariableString ~= oldClassVarString ifTrue:[ |
|
2371 |
"/ there is no need to recreate the variable |
|
2372 |
"/ (its in the smalltalk dictionary) |
|
2373 |
newClass setClassVariableString:oldClassVarString |
|
2374 |
]. |
|
2375 |
newClass isMeta ifFalse:[ |
|
2376 |
newClass setSharedPoolNames:(oldClass sharedPoolNames). |
|
2377 |
oldClassCategory := oldClass category. |
|
2378 |
newClass category ~= oldClassCategory ifTrue:[ |
|
2379 |
newClass setCategory:oldClassCategory |
|
2380 |
] |
|
2381 |
]. |
|
2382 |
oldMethods := saveOldMethodsPerClass at:oldClass. |
|
2383 |
newMethodDict := newClass methodDictionary. |
|
2384 |
oldMethods keysAndValuesDo:[:selector :oldMethod| |
|
2385 |
oldMethod |
|
2386 |
code:nil; |
|
2387 |
mclass:self. |
|
2388 |
oldMethod byteCode isNil ifTrue:[ |
|
2389 |
"a compiled method, load the new code (addresses may have been changed)" |
|
2390 |
newMthd := newMethodDict at:selector ifAbsent:nil. |
|
2391 |
newMthd notNil ifTrue:[ |
|
2392 |
oldMethod code:newMthd code. |
|
2393 |
] ifFalse:[ |
|
2394 |
('ObjectFileLoader [warning]: ' , oldClass name , ' missing method: ', selector, '.') errorPrintCR. |
|
2395 |
]. |
|
2396 |
]. |
|
2397 |
]. |
|
2398 |
newClass setMethodDictionary:oldMethods. |
|
2399 |
]. |
|
2400 |
]. |
|
2401 |
||
2402 |
"/ |
|
2403 |
"/ validate old-classes vs. new classes. |
|
2404 |
"/ and if things look ok, get rid of old stuff |
|
2405 |
"/ and make instances become instances of the new class |
|
2406 |
"/ |
|
638 | 2407 |
"/ ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR. |
2408 |
||
3721 | 2409 |
savedOldClasses do:[:oldClass | |
2410 |
|newClass oldCat oldCVars| |
|
2411 |
||
2412 |
newClass := Smalltalk classNamed:(oldClass name). |
|
2413 |
newClass == oldClass ifTrue:[ |
|
474 | 2414 |
"/ ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR. |
3721 | 2415 |
] ifFalse:[ |
2416 |
(newClass isNil or:[newClass == oldClass]) ifTrue:[ |
|
2417 |
('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR. |
|
2418 |
] ifFalse:[ |
|
303 | 2419 |
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print. |
2420 |
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR. |
|
2421 |
||
3721 | 2422 |
oldClass instSize ~~ newClass instSize ifTrue:[ |
2423 |
('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR. |
|
2424 |
] ifFalse:[ |
|
2425 |
oldClass class instSize ~~ newClass class instSize ifTrue:[ |
|
2426 |
('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR. |
|
2427 |
] ifFalse:[ |
|
638 | 2428 |
"/ ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR. |
3721 | 2429 |
(oldCat := oldClass category) ~= newClass category ifTrue:[ |
2430 |
newClass setCategory:oldCat. |
|
2431 |
]. |
|
2432 |
(oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[ |
|
2433 |
newClass setClassVariableString:oldCVars |
|
2434 |
]. |
|
2435 |
"/ copy over the oldClasses class-instVars |
|
2436 |
(Class instSize + 1) to:(oldClass class instSize) do:[:idx | |
|
2437 |
newClass instVarAt:idx put:(oldClass instVarAt:idx) |
|
2438 |
]. |
|
2439 |
oldClass becomeSameAs:newClass |
|
638 | 2440 |
"/ oldClass become:newClass |
3721 | 2441 |
] |
2442 |
] |
|
2443 |
] |
|
2444 |
] |
|
2445 |
] |
|
2446 |
||
2447 |
] ifFalse:[ |
|
2448 |
handle isMethodHandle ifTrue:[ |
|
2449 |
oldDummyMethod := handle method. |
|
2450 |
(oldDummyMethod isMethod) ifFalse:[ |
|
2451 |
('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR |
|
2452 |
] ifTrue:[ |
|
2453 |
('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR. |
|
2454 |
who := oldDummyMethod who. |
|
2455 |
newHandle := self loadMethodObjectFile:fileName. |
|
2456 |
newHandle isNil ifTrue:[ |
|
2457 |
('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR. |
|
2458 |
handle moduleID:nil. |
|
2459 |
] ifFalse:[ |
|
2460 |
m := newHandle method. |
|
2461 |
oldDummyMethod sourceFilename notNil ifTrue:[ |
|
2462 |
m sourceFilename:(oldDummyMethod sourceFilename) |
|
2463 |
position:(oldDummyMethod sourcePosition). |
|
2464 |
] ifFalse:[ |
|
2465 |
m source:(oldDummyMethod source). |
|
2466 |
]. |
|
2467 |
m setPackage:(oldDummyMethod package). |
|
2468 |
who notNil ifTrue:[ |
|
2469 |
cls := who methodClass. |
|
2470 |
sel := who methodSelector. |
|
2471 |
m == (cls compiledMethodAt:sel) ifFalse:[ |
|
2472 |
'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR. |
|
2473 |
] ifTrue:[ |
|
303 | 2474 |
"/ cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod). |
3721 | 2475 |
] |
2476 |
]. |
|
2477 |
] |
|
2478 |
] |
|
2479 |
] ifFalse:[ |
|
2480 |
handle isFunctionObjectHandle ifTrue:[ |
|
2481 |
functions := handle functions. |
|
2482 |
functions isEmpty ifTrue:[ |
|
2483 |
('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR |
|
2484 |
] ifFalse:[ |
|
2485 |
newHandle := self loadDynamicObject:fileName. |
|
2486 |
newHandle isNil ifTrue:[ |
|
2487 |
('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR. |
|
2488 |
handle moduleID:nil. |
|
2489 |
] ifFalse:[ |
|
2490 |
('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR. |
|
2491 |
functions do:[:eachFunction | |addr| |
|
2492 |
addr := newHandle getFunctionAddress:(eachFunction name) into:eachFunction. |
|
2493 |
addr isNil ifTrue:[ |
|
2494 |
('ObjectFileLoader [info]: function: ''' , eachFunction name , ''' no longer present.') errorPrintCR. |
|
2495 |
eachFunction invalidate. |
|
2496 |
] ifFalse:[ |
|
2497 |
eachFunction setModuleHandle:newHandle. |
|
2498 |
('ObjectFileLoader [info]: rebound function: ''' , eachFunction name , '''.') infoPrintCR. |
|
2499 |
] |
|
2500 |
]. |
|
2501 |
handle becomeSameAs:newHandle. "/ the old handle is now void |
|
2502 |
] |
|
2503 |
] |
|
2504 |
] ifFalse:[ |
|
2505 |
('ObjectFileLoader [info]: ignore invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR. |
|
2506 |
] |
|
2507 |
] |
|
2508 |
] |
|
2509 |
]. |
|
2510 |
PreviouslyLoadedObjects := nil. |
|
2511 |
||
2512 |
"/ now, as we hopefully have all loaded, |
|
2513 |
"/ send #reinitializeAfterLoad to each of them |
|
2514 |
anyModulesToInitialize ifTrue:[ |
|
2515 |
AbortOperationRequest catch:[ |
|
2516 |
self moduleInit:4 forceOld:false interruptable:true. |
|
2517 |
] |
|
2518 |
] |
|
303 | 2519 |
] |
2520 |
||
2472
8ae818e74044
changed: #reloadAllRememberedObjectFiles
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
2521 |
"Modified: / 18-01-2011 / 20:42:57 / cg" |
303 | 2522 |
! |
2523 |
||
2524 |
rememberAllObjectFiles |
|
2525 |
"remember all loaded objectModules in the |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2526 |
PreviouslyLoadedObjects classVariable. |
303 | 2527 |
Called when an image is restarted to reload all modules which |
2528 |
were loaded in the previous life" |
|
2529 |
||
2530 |
LoadedObjects notNil ifTrue:[ |
|
2919 | 2531 |
PreviouslyLoadedObjects := OrderedCollection new. |
2532 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
2533 |
handle isObsolete ifTrue:[ |
|
2534 |
('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR |
|
2535 |
] ifFalse:[ |
|
2536 |
PreviouslyLoadedObjects add:(name -> handle) |
|
2537 |
] |
|
2538 |
]. |
|
2539 |
PreviouslyLoadedObjects sort:[:a :b | |
|
2540 |
|h1 h2| |
|
2541 |
||
2542 |
h1 := a value moduleID. |
|
2543 |
h2 := b value moduleID. |
|
2544 |
h1 isNil |
|
2545 |
ifTrue:[true] |
|
2546 |
ifFalse:[ |
|
2547 |
h2 isNil |
|
2548 |
ifTrue:[false] |
|
2549 |
ifFalse:[ |
|
2550 |
h1 < h2 |
|
2551 |
] |
|
2552 |
] |
|
2553 |
]. |
|
303 | 2554 |
] |
2555 |
||
2556 |
"Created: 5.12.1995 / 20:51:07 / cg" |
|
474 | 2557 |
"Modified: 10.1.1997 / 15:06:25 / cg" |
303 | 2558 |
! |
2559 |
||
2560 |
revalidateAllObjectFiles |
|
2561 |
"revalidate code refs into all dynamically loaded object files. |
|
2562 |
Required after writing a snapshot image." |
|
2563 |
||
2564 |
ActuallyLoadedObjects notNil ifTrue:[ |
|
468 | 2565 |
ActuallyLoadedObjects keys do:[:aFileName | |
2566 |
|handle| |
|
2567 |
||
2568 |
handle := ActuallyLoadedObjects at:aFileName. |
|
2569 |
handle isNil ifTrue:[ |
|
2570 |
self error:'oops, no handle'. |
|
2571 |
] ifFalse:[ |
|
2572 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
2573 |
self revalidateModule:handle |
|
2574 |
] |
|
2575 |
] |
|
2576 |
]. |
|
2577 |
LoadedObjects := ActuallyLoadedObjects. |
|
2578 |
ActuallyLoadedObjects := PreviouslyLoadedObjects := nil. |
|
28 | 2579 |
]. |
141 | 2580 |
|
303 | 2581 |
"Created: 5.10.1995 / 15:49:08 / claus" |
2582 |
"Modified: 5.10.1995 / 16:49:18 / claus" |
|
2583 |
"Modified: 12.7.1996 / 17:14:48 / cg" |
|
2584 |
! |
|
2585 |
||
2586 |
unloadAllObjectFiles |
|
2587 |
"unload all dynamically loaded object files from the image. |
|
2588 |
see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:" |
|
2589 |
||
2590 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2591 |
LoadedObjects values copy do:[:eachHandle | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2592 |
eachHandle notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2593 |
self unloadDynamicObject:eachHandle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2594 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2595 |
] |
303 | 2596 |
]. |
2597 |
||
2598 |
" |
|
2599 |
ObjectFileLoader unloadAllObjectFiles |
|
2600 |
" |
|
2601 |
! |
|
2602 |
||
2603 |
unloadAndRememberAllObjectFiles |
|
2604 |
"remember all modules and unload them" |
|
2605 |
||
2606 |
LoadedObjects notNil ifTrue:[ |
|
468 | 2607 |
self rememberAllObjectFiles. |
2608 |
self unloadAllObjectFiles |
|
303 | 2609 |
] |
2610 |
||
2611 |
"Modified: 25.4.1996 / 09:46:27 / cg" |
|
0 | 2612 |
! ! |
2613 |
||
369 | 2614 |
!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
|
2615 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2616 |
createLoadableObjectFor:baseFileName |
259 | 2617 |
"given an oFile, arrange for it to be loadable. |
2618 |
On ELF systems, this means that it has to be linked with the |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2619 |
-shared option into a .so file; |
259 | 2620 |
DLD based loaders (linux a.out) can directly load a .o file; |
2621 |
Other systems may require more ..." |
|
2622 |
||
513 | 2623 |
|osType oFileName soFileName expFileName librunExpFileName |
3050 | 2624 |
needSharedObject ld ldArg expFile ok outfile output libDir libDirBasename |
3054 | 2625 |
errorMessage homeDir fmt| |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2626 |
|
750
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2627 |
osType := OperatingSystem getOSType. |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2628 |
|
2025
00f8564566e8
No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents:
2012
diff
changeset
|
2629 |
osType = #win32 ifTrue:[ |
3721 | 2630 |
self activityNotification:'generating shared object'. |
2631 |
ParserFlags linkArgs isNil ifTrue:[ |
|
2632 |
ld := self linkCommand , ' ' , baseFileName , '.obj'. |
|
2633 |
ld := ld |
|
2634 |
, ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL' |
|
2635 |
, ' /OUT:' , baseFileName , '.dll ' |
|
2025
00f8564566e8
No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents:
2012
diff
changeset
|
2636 |
"/ , ' /DEF:' , baseFileName , '.def'. |
3721 | 2637 |
] ifFalse:[ |
3011 | 2638 |
"/ libDir := ParserFlags libDirectory. |
2639 |
"/ (libDir notNil and:[libDir asFilename exists]) ifFalse:[ |
|
3721 | 2640 |
ParserFlags useBorlandC ifTrue:[ |
2641 |
libDirBasename := 'lib\bc' |
|
2642 |
] ifFalse:[ |
|
2643 |
ParserFlags useVisualC ifTrue:[ |
|
2644 |
libDirBasename := 'lib\vc' |
|
2645 |
] ifFalse:[ |
|
2646 |
(ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[ |
|
2647 |
libDirBasename := 'lib\mingw' |
|
2648 |
] ifFalse:[ |
|
2649 |
libDirBasename := 'lib\vc' |
|
2650 |
] |
|
2651 |
] |
|
2652 |
]. |
|
2653 |
homeDir := Smalltalk packagePath detect:[:p | (p asFilename / 'stx' / libDirBasename) exists] ifNone:nil. |
|
2654 |
homeDir notNil ifTrue:[ |
|
2655 |
libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName |
|
2656 |
]. |
|
2657 |
libDir isNil ifTrue:[ |
|
2658 |
"/ some fallback |
|
2659 |
libDir := #( '..' |
|
2660 |
'..\..' |
|
2661 |
'..\..\..' |
|
2662 |
'..\..\stx' |
|
2663 |
'..\..\..\stx' |
|
2664 |
) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil. |
|
2665 |
||
2666 |
libDir isNil ifTrue:[ |
|
2667 |
LastError := errorMessage := 'could not locate directory where .lib files are (',libDirBasename,')'. |
|
2668 |
ObjectFileLoadError raiseRequestErrorString:errorMessage. |
|
2669 |
^ nil |
|
2670 |
]. |
|
2671 |
]. |
|
3011 | 2672 |
"/ ]. |
2673 |
||
3721 | 2674 |
ParserFlags useBorlandC ifTrue:[ |
2675 |
ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). |
|
2676 |
ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. |
|
2677 |
ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. |
|
2678 |
ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). |
|
2679 |
ld := ld , ' ',libDir,'\cs32i.lib,,'. |
|
2680 |
] ifFalse:[ |
|
2681 |
ParserFlags useVisualC ifTrue:[ |
|
2682 |
"/ todo: fix for correct link libs |
|
2683 |
ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). |
|
2684 |
ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. |
|
2685 |
ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. |
|
2686 |
ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). |
|
2687 |
ld := ld , ' ',libDir,'\cs32i.lib,,'. |
|
2688 |
] ifFalse:[ |
|
2689 |
(ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[ |
|
2690 |
ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). |
|
2691 |
ld := ld , ' -shared -o ',baseFileName,'.dll '. |
|
2692 |
ld := ld , baseFileName,'.obj '. |
|
2693 |
ld := ld , libDir,'\librun.lib '. |
|
2694 |
ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). |
|
2695 |
] ifFalse:[ |
|
2696 |
ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'. |
|
2697 |
LastError := 'for dynamic objects, only borlandC is (currently) supported'. |
|
2698 |
^ nil |
|
2699 |
] |
|
2700 |
] |
|
2701 |
] |
|
2702 |
]. |
|
2703 |
||
2704 |
outfile := (baseFileName , '.out'). |
|
2705 |
(Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ |
|
2706 |
Transcript showCR:('executing: ',ld). |
|
2707 |
]. |
|
2708 |
||
2709 |
ok := OperatingSystem executeCommand:(ld , ' >' , outfile). |
|
2710 |
ok ifFalse:[ |
|
2711 |
output := (baseFileName , '.out') asFilename contentsOfEntireFile. |
|
2712 |
Transcript showCR:output; endEntry. |
|
2713 |
Transcript showCR:'Failed linkCommand:'. |
|
2714 |
Transcript showCR:ld. |
|
2715 |
Transcript showCR:'ParserFlags are:'. |
|
2716 |
Transcript showCR:ParserFlags. |
|
2717 |
]. |
|
2718 |
||
2719 |
#('.obj' '.out' '.tds' '.ilc' '.ild' |
|
2720 |
'.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix| |
|
2721 |
(baseFileName , eachSuffix) asFilename delete. |
|
2722 |
]. |
|
2723 |
||
2724 |
ok ifFalse:[ |
|
2725 |
LastError := output. |
|
2726 |
"/ ObjectFileLoadError raiseRequestErrorString:'link failed'. |
|
2727 |
^ nil |
|
2728 |
]. |
|
2729 |
oFileName := (baseFileName , self sharedLibraryExtension) asFilename name. |
|
2730 |
^ oFileName |
|
750
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2731 |
]. |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2732 |
|
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2733 |
"/ UNIX systems |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2734 |
|
2653
e228edb0b67a
changed: #createLoadableObjectFor:
Stefan Vogel <sv@exept.de>
parents:
2651
diff
changeset
|
2735 |
ld := self linkCommand ? 'ld'. |
188 | 2736 |
needSharedObject := false. |
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2737 |
|
3054 | 2738 |
fmt := ObjectFileLoader loadableBinaryObjectFormat. |
2739 |
(fmt == #elf |
|
2740 |
or:[ fmt == #macho ]) ifTrue:[ |
|
3721 | 2741 |
" |
2742 |
link it to a shared object with 'ld -shared' |
|
2743 |
" |
|
2744 |
needSharedObject := true. |
|
2745 |
ld := self linkCommand ? 'cc'. |
|
2746 |
ldArg := self linkSharedArgs. |
|
2747 |
ldArg isNil ifTrue:[ |
|
2748 |
"/ some default |
|
2749 |
ExternalAddress pointerSize == 4 ifTrue:[ |
|
2750 |
ldArg := '-m32 -shared'. |
|
2751 |
] ifFalse:[ |
|
2752 |
ldArg := '--shared'. |
|
2753 |
] |
|
2754 |
] |
|
3052 | 2755 |
]. |
2756 |
||
2935 | 2757 |
osType = #irix ifTrue:[ |
3721 | 2758 |
" |
2759 |
link it to a shared object with 'ld -shared' |
|
2760 |
" |
|
2761 |
needSharedObject := true. |
|
2762 |
ldArg := self linkSharedArgs ? '-shared'. |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2763 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2764 |
|
2935 | 2765 |
osType = #'sys5_4' ifTrue:[ |
3721 | 2766 |
" |
2767 |
link it to a shared object with 'ld -G' |
|
2768 |
" |
|
2769 |
needSharedObject := true. |
|
2770 |
ldArg := self linkSharedArgs ? '-G'. |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2771 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2772 |
|
2935 | 2773 |
osType = #solaris ifTrue:[ |
3721 | 2774 |
" |
2775 |
link it to a shared object with 'ld -G -B dynamic' |
|
2776 |
" |
|
2777 |
needSharedObject := true. |
|
2778 |
ldArg := self linkSharedArgs ? '-G -Bdynamic'. |
|
741 | 2779 |
]. |
2780 |
||
2935 | 2781 |
osType = #hpux ifTrue:[ |
3721 | 2782 |
" |
2783 |
link it to a shared object with 'ld -b -B immediate' |
|
2784 |
" |
|
2785 |
needSharedObject := true. |
|
2786 |
ldArg := self linkSharedArgs ? '-b -B immediate'. |
|
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2787 |
]. |
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2788 |
|
2935 | 2789 |
osType = #aix ifTrue:[ |
3721 | 2790 |
self activityNotification:'create export file'. |
2791 |
||
2792 |
"/ create an exports file. |
|
2793 |
expFileName := './' , baseFileName , '.exp'. |
|
2794 |
[ |
|
2795 |
expFile := expFileName asFilename writeStream. |
|
2796 |
expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension). |
|
2797 |
expFile cr. |
|
2798 |
expFile nextPutAll:'_' , baseFileName , '_Init'. |
|
2799 |
expFile close. |
|
2800 |
] on:FileStream openErrorSignal do:[:ex| "do nothing"]. |
|
2801 |
||
2802 |
self activityNotification:'generating shared object'. |
|
2803 |
||
2804 |
" |
|
2805 |
link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE' |
|
2806 |
" |
|
2807 |
needSharedObject := true. |
|
2808 |
ld := 'cc'. |
|
2809 |
librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'. |
|
2810 |
librunExpFileName isNil ifTrue:[ |
|
2811 |
LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'. |
|
2812 |
^ nil |
|
2813 |
]. |
|
2814 |
||
2815 |
ldArg := '-bI:' , librunExpFileName , |
|
2816 |
' -bE:' , baseFileName , '.exp' , |
|
2817 |
' -bM:SRE -e _' , baseFileName , '_Init'. |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2818 |
]. |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2819 |
|
2648
2d046cf8c90e
changed: #createLoadableObjectFor:
Stefan Vogel <sv@exept.de>
parents:
2627
diff
changeset
|
2820 |
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
|
2821 |
needSharedObject ifTrue:[ |
3721 | 2822 |
self activityNotification:'generating shared object'. |
2823 |
||
2824 |
soFileName := baseFileName , self sharedLibraryExtension. |
|
2825 |
OperatingSystem removeFile:soFileName. |
|
2826 |
ld := ld , ' ' , ldArg , ' ', (ParserFlags linkArgs ? '') , |
|
2827 |
' -o ' , soFileName , ' ' , oFileName , ' ', |
|
2828 |
((ParserFlags searchedLibraries ? #()) asStringCollection asStringWith: $ ). |
|
2829 |
||
2830 |
(Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ |
|
2831 |
Transcript showCR:('linking with: ',ld). |
|
2832 |
]. |
|
2833 |
ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1'). |
|
2834 |
||
2835 |
ok ifFalse:[ |
|
2836 |
output := 'errorOutput' asFilename contentsOfEntireFile. |
|
2837 |
Transcript showCR:'linker error message:'. |
|
2838 |
Transcript showCR:output. |
|
2839 |
Transcript showCR:'linker command:'. |
|
2840 |
Transcript showCR:ld; endEntry. |
|
2841 |
]. |
|
2842 |
||
2843 |
OperatingSystem removeFile:oFileName. |
|
2844 |
expFileName notNil ifTrue:[ |
|
2845 |
OperatingSystem removeFile:expFileName |
|
2846 |
]. |
|
2847 |
^ soFileName. |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2848 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2849 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2850 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2851 |
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
|
2852 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2853 |
^ oFileName |
698 | 2854 |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2855 |
"Modified: / 29-07-2004 / 17:29:44 / stefan" |
2932
d61b51867682
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
2856 |
"Modified: / 28-09-2012 / 18:00:13 / cg" |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2857 |
! ! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2858 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2859 |
!ObjectFileLoader class methodsFor:'lowlevel object loading'! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2860 |
|
633 | 2861 |
initializeLoader |
2862 |
"initialize dynamic loader if required" |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2863 |
|
633 | 2864 |
|stxName stxPathName| |
2865 |
||
2866 |
stxPathName := OperatingSystem pathOfSTXExecutable. |
|
2867 |
%{ |
|
2868 |
#ifdef GNU_DL |
|
2869 |
{ |
|
2870 |
static alreadyInitialized = 0; |
|
2871 |
extern dld_ignore_redefinitions; |
|
2872 |
||
2873 |
if (! alreadyInitialized) { |
|
2874 |
alreadyInitialized = 1; |
|
2875 |
||
2876 |
if (@global(Verbose) == true) { |
|
1975 | 2877 |
console_printf ("dld_init(%s)\n", __stringVal(stxPathName)); |
633 | 2878 |
} |
2879 |
/* |
|
2880 |
* dld requires the running executables name, |
|
2881 |
* to resolve symbols. |
|
2882 |
*/ |
|
2883 |
(void) dld_init (__stringVal(stxPathName)); |
|
2884 |
dld_ignore_redefinitions = 1; |
|
2885 |
} |
|
2886 |
} |
|
2887 |
#endif |
|
2888 |
%}. |
|
2889 |
! |
|
2890 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2891 |
loadDynamicObject:pathNameOrFilename |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2892 |
"load an object-file (load/map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2893 |
Return a non-nil handle if ok, nil otherwise. |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2894 |
No bindings or automatic initializations are done |
472 | 2895 |
- only a pure (low-level) load is performed. |
2896 |
For class-files or C-objects to be loaded with this method, |
|
2897 |
it is your responsibility to fetch any init-functions and |
|
2898 |
call them as appropriate. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2899 |
This function is not supported on all architectures. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2900 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2901 |
|
2989 | 2902 |
|fn handle buffer pathName tempFile encodedPathName| |
2982 | 2903 |
|
2904 |
fn := pathNameOrFilename asFilename. |
|
2905 |
fn exists ifTrue:[ |
|
2993 | 2906 |
pathName := fn pathName. |
2907 |
self copyLibrariesWhenLoading ifTrue:[ |
|
2908 |
fn copyTo:(tempFile := ParserFlags stcModulePath asFilename construct:fn baseName). |
|
2909 |
pathName := tempFile pathName. |
|
2910 |
]. |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
2911 |
] ifFalse:[ |
2993 | 2912 |
"/ something like "kernel32.dll"; must be along the PATH setting |
2913 |
pathName := pathNameOrFilename asString. |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
2914 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2915 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2916 |
Verbose ifTrue:[ |
2993 | 2917 |
('loadDynamic: ',pathNameOrFilename asString,' (',pathName asString,')...') errorPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2918 |
]. |
2989 | 2919 |
encodedPathName := OperatingSystem encodePath:pathName. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2920 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2921 |
"/ already loaded ? |
2989 | 2922 |
handle := self handleForDynamicObject:encodedPathName. |
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
2923 |
handle notNil ifTrue:[ |
2993 | 2924 |
Verbose ifTrue:[ |
2925 |
('... ' , pathName , ' already loaded.') errorPrintCR. |
|
2926 |
]. |
|
2927 |
^ handle |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2928 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2929 |
|
759 | 2930 |
Verbose ifTrue:[ |
2993 | 2931 |
('initializeLoader...') errorPrintCR |
759 | 2932 |
]. |
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
|
2933 |
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
|
2934 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2935 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2936 |
"/ the 1st two entries are system dependent; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2937 |
"/ entry 3 is the pathName |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2938 |
"/ entry 4 is a unique ID |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2939 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2940 |
buffer := Array new:4. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2941 |
buffer at:3 put:pathName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2942 |
buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2943 |
|
759 | 2944 |
Verbose ifTrue:[ |
2993 | 2945 |
('primLoadDynamicObject...') errorPrintCR |
759 | 2946 |
]. |
2947 |
||
2989 | 2948 |
buffer := self primLoadDynamicObject:encodedPathName into:buffer. |
759 | 2949 |
Verbose ifTrue:[ |
2993 | 2950 |
('done') errorPrintCR |
759 | 2951 |
]. |
2952 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2953 |
buffer isNil ifTrue:[ |
2993 | 2954 |
LastError == #notImplemented ifTrue:[ |
2955 |
'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR. |
|
2956 |
] ifFalse:[ |
|
2957 |
LastError == #linkError ifTrue:[ |
|
2958 |
LinkErrorMessage notNil ifTrue:[ |
|
2959 |
('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR. |
|
2960 |
] ifFalse:[ |
|
2961 |
('ObjectFileLoader [warning]: load error') infoPrintCR. |
|
2962 |
]. |
|
2963 |
]. |
|
2964 |
]. |
|
2965 |
('ObjectFileLoader [warning]: failed to load: ' , pathName) infoPrintCR. |
|
2966 |
Transcript showCR:('ObjectFileLoader [warning]: failed to load: ' , pathName). |
|
2967 |
^ nil |
|
470
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 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2971 |
remember loaded object for later unloading |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2972 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2973 |
handle := ObjectFileHandle new. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2974 |
handle sysHandle1:(buffer at:1). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2975 |
handle sysHandle2:(buffer at:2). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2976 |
handle pathName:(buffer at:3). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2977 |
handle moduleID:(buffer at:4). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2978 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2979 |
LoadedObjects isNil ifTrue:[ |
2993 | 2980 |
LoadedObjects := Dictionary new. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2981 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2982 |
LoadedObjects at:pathName put:handle. |
1904
71c41110a83a
flush cache when init function was called (not when the dll was loaded)
Michael Beyl <mb@exept.de>
parents:
1903
diff
changeset
|
2983 |
"/ Smalltalk flushCachedClasses. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2984 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2985 |
Verbose ifTrue:[ |
2993 | 2986 |
('loadDynamic ok; handle is: ' , handle printString) errorPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2987 |
]. |
2767
12da7f27dcce
changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents:
2746
diff
changeset
|
2988 |
"/ ObjectMemory garbageCollect. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2989 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2990 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2991 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2992 |
"sys5.4: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2993 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2994 |
handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2995 |
ObjectFileLoader getFunction:'module1' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2996 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2997 |
"next: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2998 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2999 |
handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3000 |
ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3001 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3002 |
"GLD: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3003 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3004 |
handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3005 |
ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3006 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3007 |
|
2767
12da7f27dcce
changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents:
2746
diff
changeset
|
3008 |
"Modified: / 06-12-2011 / 15:42:16 / cg" |
470
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 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3011 |
loadModulesFromListOfUndefined:list |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3012 |
"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
|
3013 |
return a list of handles of loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3014 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3015 |
|inits classNames| |
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 |
inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3018 |
inits notNil ifTrue:[ |
634 | 3019 |
classNames := inits collect:[:symbol | |
3020 |
(symbol startsWith:'___') ifTrue:[ |
|
3021 |
symbol copyFrom:4 to:(symbol size - 5) |
|
3022 |
] ifFalse:[ |
|
3023 |
(symbol startsWith:'__') ifTrue:[ |
|
3024 |
symbol copyFrom:3 to:(symbol size - 5) |
|
3025 |
] ifFalse:[ |
|
3026 |
(symbol startsWith:'_') ifTrue:[ |
|
3027 |
symbol copyFrom:2 to:(symbol size - 5) |
|
3028 |
] ifFalse:[ |
|
3029 |
symbol |
|
3030 |
] |
|
3031 |
] |
|
3032 |
] |
|
3033 |
]. |
|
3034 |
" |
|
3035 |
autoload those classes |
|
3036 |
" |
|
3037 |
classNames do:[:aClassName | |
|
3038 |
|cls| |
|
3039 |
||
3040 |
(cls := Smalltalk classNamed:aClassName) notNil ifTrue:[ |
|
3041 |
'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR. |
|
3042 |
cls autoload |
|
3043 |
] |
|
3044 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3045 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3046 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3047 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3048 |
"Modified: 10.1.1997 / 17:58:23 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3049 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3050 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3051 |
primLoadDynamicObject:pathName into:anInfoBuffer |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3052 |
"load an object-file (map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3053 |
Return an OS-handle (whatever that is) - where some space |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3054 |
(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
|
3055 |
The first two entries are used in a machine dependent way, |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3056 |
and callers may not depend on what is found there |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3057 |
(instead, only pass around handles transparently). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3058 |
This function is not supported on all architectures." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3059 |
|
1760
09a5b2b97f29
WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents:
1759
diff
changeset
|
3060 |
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3061 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3062 |
if (! __isArray(anInfoBuffer) |
646
02b5ea95f888
eliminated some single-underscore macro refs (stringSize, arraySize ...)
Claus Gittinger <cg@exept.de>
parents:
645
diff
changeset
|
3063 |
|| (__arraySize(anInfoBuffer) < 3)) { |
3721 | 3064 |
RETURN(nil); |
470
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 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3067 |
#ifdef GNU_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3068 |
{ |
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3069 |
if (__isStringLike(pathName)) { |
3721 | 3070 |
if (dld_link(__stringVal(pathName))) { |
3071 |
if (@global(Verbose) == true) { |
|
3072 |
console_printf ("link file %s failed\n", __stringVal(pathName)); |
|
3073 |
} |
|
3074 |
if (@global(ErrorPrinting) == true) { |
|
3075 |
dld_perror("ObjectFileLoader - DLD error cant link"); |
|
3076 |
} |
|
3077 |
@global(LastError) = @symbol(linkError); |
|
3078 |
@global(LinkErrorMessage) = __MKSTRING("DLD error"); |
|
3079 |
RETURN ( nil ); |
|
3080 |
} |
|
3081 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
|
3082 |
__STORE(anInfoBuffer, pathName); |
|
3083 |
RETURN ( anInfoBuffer ); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3084 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3085 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3086 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3087 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3088 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3089 |
#ifdef WIN_DL |
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 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3092 |
int err; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3093 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3094 |
if (__isStringLike(pathName)) { |
3721 | 3095 |
if (@global(Verbose) == true) { |
3096 |
console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName)); |
|
3097 |
console_fflush(stderr); |
|
3098 |
} |
|
3099 |
// |
|
3100 |
// LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also |
|
3101 |
// in the directory of the loaded library, if an absolute path to |
|
3102 |
// the library has been provided. |
|
3103 |
// Note: this does not work for redirected library symbols, since they are |
|
3104 |
// resolved ad symbol lookup time and not at library load time |
|
3105 |
// |
|
3106 |
handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
|
3107 |
if (@global(Verbose) == true) { |
|
3722 | 3108 |
console_fprintf(stderr, "ObjectFileLoader [info]: handle: %"_lx_"\n", (INT)handle); |
3721 | 3109 |
console_fflush(stderr); |
3110 |
} |
|
3111 |
if (handle == NULL) { |
|
3112 |
char *msg; |
|
3113 |
||
3114 |
err = GetLastError(); |
|
3115 |
if ((@global(ErrorPrinting) == true) |
|
3116 |
|| (@global(Verbose) == true)) { |
|
3117 |
console_fprintf (stderr, |
|
3118 |
"ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n", |
|
3119 |
__stringVal(pathName), err); |
|
3120 |
} |
|
3121 |
@global(LastError) = @symbol(loadError);; |
|
3122 |
@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err)); |
|
3123 |
switch (err) { |
|
3124 |
case ERROR_BAD_FORMAT: |
|
3125 |
msg = "LoadLibrary error - bad format"; |
|
3126 |
default: |
|
3127 |
msg = "LoadLibrary error"; |
|
3128 |
break; |
|
3129 |
} |
|
3130 |
@global(LinkErrorMessage) = __MKSTRING(msg); |
|
3131 |
RETURN ( nil ); |
|
3132 |
} |
|
3001 | 3133 |
# if __POINTER_SIZE__ == 8 |
3721 | 3134 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFFL ); |
3135 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFFL ); |
|
3001 | 3136 |
# else |
3721 | 3137 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF ); |
3138 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3001 | 3139 |
# endif |
3721 | 3140 |
RETURN ( anInfoBuffer ); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3141 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3142 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3143 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3144 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3145 |
|
906 | 3146 |
#ifdef BEOS_DL |
3147 |
{ |
|
3148 |
void *handle; |
|
3149 |
int err; |
|
3150 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3151 |
if (__isStringLike(pathName)) { |
3721 | 3152 |
if (@global(Verbose) == true) { |
3153 |
console_fprintf(stderr, "ObjectFileLoader [info]: loading : %s...\n", __stringVal(pathName)); |
|
3154 |
console_fflush(stderr); |
|
3155 |
} |
|
3156 |
handle = load_add_on(__stringVal(pathName)); |
|
3157 |
if (@global(Verbose) == true) { |
|
3158 |
console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle); |
|
3159 |
console_fflush(stderr); |
|
3160 |
} |
|
3161 |
if (handle == NULL) { |
|
3162 |
char *msg; |
|
3163 |
||
3164 |
@global(LastError) = @symbol(linkError); |
|
3165 |
@global(LinkErrorMessage) = __MKSTRING("unknown error"); |
|
3166 |
RETURN ( nil ); |
|
3167 |
} |
|
3001 | 3168 |
# if __POINTER_SIZE__ == 8 |
3721 | 3169 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF ); |
3170 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF ); |
|
3001 | 3171 |
# else |
3721 | 3172 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF ); |
3173 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3174 |
RETURN ( anInfoBuffer ); |
|
3001 | 3175 |
# endif |
906 | 3176 |
} |
3177 |
RETURN ( nil ); |
|
3178 |
} |
|
3179 |
#endif |
|
3180 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3181 |
#ifdef DL1_6 |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3182 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3183 |
extern char *__myName__; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3184 |
char *ldname; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3185 |
OBJ tmpName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3186 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3187 |
if (__isStringLike(pathName)) { |
3721 | 3188 |
if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) { |
3189 |
if (@global(Verbose) == true) { |
|
3190 |
console_printf ("link file %s failed\n", __stringVal(pathName)); |
|
3191 |
} |
|
3192 |
@global(LinkErrorMessage) = __MKSTRING("dl_load error"); |
|
3193 |
RETURN ( nil ); |
|
3194 |
} |
|
3195 |
/* |
|
3196 |
* returns the name of the temporary ld-file |
|
3197 |
* use that as handle ... |
|
3198 |
*/ |
|
3199 |
tmpName = __MKSTRING(ldname); |
|
3200 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName; |
|
3201 |
__STORE(anInfoBuffer, tmpName); |
|
3202 |
RETURN ( anInfoBuffer ); |
|
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 |
RETURN ( nil ); |
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 |
#endif |
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 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3209 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3210 |
char *objName, *libPath; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3211 |
int *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3212 |
extern errno; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3213 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3214 |
if (__isStringLike(pathName)) { |
3721 | 3215 |
objName = __stringVal(pathName); |
3216 |
||
3217 |
if (__isStringLike(@global(LibPath))) { |
|
3218 |
libPath = __stringVal(@global(LibPath)); |
|
3219 |
} else { |
|
3220 |
libPath = (char *)0; |
|
3221 |
} |
|
3222 |
if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) { |
|
3223 |
if (@global(Verbose) == true) { |
|
3224 |
char *messages[64]; |
|
3225 |
int i; |
|
3226 |
||
3227 |
console_fprintf (stderr, |
|
3228 |
"ObjectFileLoader [info]: load file %s failed errno=%d\n", |
|
3229 |
objName, errno); |
|
3230 |
||
3231 |
switch (errno) { |
|
3232 |
case ENOEXEC: |
|
3233 |
console_fprintf(stderr, " load messages:\n"); |
|
3234 |
loadquery(L_GETMESSAGES, messages, sizeof(messages)); |
|
3235 |
for (i=0; messages[i]; i++) { |
|
3236 |
console_fprintf(stderr, " %s\n", messages[i]); |
|
3237 |
} |
|
3238 |
break; |
|
3239 |
} |
|
3240 |
} else { |
|
3241 |
if (@global(ErrorPrinting) == true) { |
|
3242 |
console_fprintf (stderr, |
|
3243 |
"ObjectFileLoader [warning]: load file %s failed errno=%d\n", |
|
3244 |
objName, errno); |
|
3245 |
} |
|
3246 |
} |
|
3247 |
@global(LinkErrorMessage) = __MKSTRING("load error"); |
|
3248 |
RETURN ( nil ); |
|
3249 |
} |
|
3250 |
if (@global(Verbose) == true) { |
|
3251 |
console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle); |
|
3252 |
} |
|
3001 | 3253 |
|
3254 |
# if __POINTER_SIZE__ == 8 |
|
3721 | 3255 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF ); |
3256 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF ); |
|
3001 | 3257 |
# else |
3721 | 3258 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF ); |
3259 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3001 | 3260 |
# endif |
3721 | 3261 |
RETURN (anInfoBuffer); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3262 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3263 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3264 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3265 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3266 |
|
523 | 3267 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3268 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3269 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3270 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3271 |
char *nm; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3272 |
char *errMsg; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3273 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3274 |
if ((pathName == nil) || __isStringLike(pathName)) { |
3721 | 3275 |
INT lowHandle, hiHandle; |
3276 |
||
3277 |
handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW); |
|
3278 |
||
3279 |
if (! handle) { |
|
3280 |
errMsg = (char *) dlerror(); |
|
3281 |
if (@global(ErrorPrinting) == true) { |
|
3282 |
console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName)); |
|
3283 |
console_fprintf(stderr, " <%s>\n", errMsg); |
|
3284 |
} |
|
3285 |
@global(LastError) = @symbol(linkError); |
|
3286 |
@global(LinkErrorMessage) = __MKSTRING(errMsg); |
|
3287 |
RETURN (nil); |
|
3288 |
} |
|
3289 |
||
3290 |
if (@global(Verbose) == true) { |
|
3291 |
console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle); |
|
3292 |
} |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3293 |
|
1607
074a99bb9a50
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
3294 |
#if __POINTER_SIZE__ == 8 |
3721 | 3295 |
lowHandle = (INT)handle & 0xFFFFFFFFL; |
3296 |
hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL; |
|
701 | 3297 |
#else |
3721 | 3298 |
lowHandle = (INT)handle & 0xFFFF; |
3299 |
hiHandle = ((INT)handle >> 16) & 0xFFFF; |
|
701 | 3300 |
#endif |
3721 | 3301 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle); |
3302 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle); |
|
3303 |
RETURN (anInfoBuffer); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3304 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3305 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3306 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3307 |
|
523 | 3308 |
|
3309 |
#ifdef HPUX10_DL |
|
3310 |
{ |
|
3311 |
void *handle; |
|
3312 |
char *nm; |
|
3313 |
char *errMsg; |
|
3314 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3315 |
if (__isStringLike(pathName)) { |
3721 | 3316 |
handle = (void *)shl_load(__stringVal(pathName), |
3317 |
BIND_IMMEDIATE, 0L /* address */); |
|
3318 |
||
3319 |
if (! handle) { |
|
3320 |
if (@global(ErrorPrinting) == true) { |
|
3321 |
console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName)); |
|
3322 |
} |
|
3323 |
@global(LastError) = @symbol(linkError); |
|
3324 |
switch (errno) { |
|
3325 |
case ENOEXEC: |
|
3326 |
errMsg = "not a shared library"; |
|
3327 |
break; |
|
3328 |
case ENOSYM: |
|
3329 |
errMsg = "undefined symbols"; |
|
3330 |
break; |
|
3331 |
case ENOMEM: |
|
3332 |
errMsg = "out of memory"; |
|
3333 |
break; |
|
3334 |
case ENOENT: |
|
3335 |
errMsg = "non existing library"; |
|
3336 |
break; |
|
3337 |
case EACCES: |
|
3338 |
errMsg = "permission denied"; |
|
3339 |
break; |
|
3340 |
default: |
|
3341 |
errMsg = "unspecified error"; |
|
3342 |
break; |
|
3343 |
} |
|
3344 |
@global(LinkErrorMessage) = __MKSTRING(errMsg); |
|
3345 |
RETURN (nil); |
|
3346 |
} |
|
3347 |
||
3348 |
if (@global(Verbose) == true) { |
|
3349 |
console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle); |
|
3350 |
} |
|
3001 | 3351 |
|
3352 |
# if __POINTER_SIZE__ == 8 |
|
3721 | 3353 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF ); |
3354 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF ); |
|
3001 | 3355 |
# else |
3721 | 3356 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF); |
3357 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3358 |
RETURN (anInfoBuffer); |
|
3001 | 3359 |
# endif |
523 | 3360 |
} |
3361 |
} |
|
3362 |
#endif |
|
3363 |
||
3364 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3365 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3366 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3367 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3368 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3369 |
if ((pathName == nil) || __isStringLike(pathName)) { |
3721 | 3370 |
if (pathName == nil) |
3371 |
handle = dlopen((char *)0, 1); |
|
3372 |
else |
|
3373 |
handle = dlopen(__stringVal(pathName), 1); |
|
3374 |
||
3375 |
if (! handle) { |
|
3376 |
if (@global(ErrorPrinting) == true) { |
|
3377 |
console_fprintf(stderr, "dlopen %s error: <%s>\n", |
|
3378 |
__stringVal(pathName), dlerror()); |
|
3379 |
} |
|
3380 |
@global(LastError) = @symbol(linkError); |
|
3381 |
@global(LinkErrorMessage) = __MKSTRING("dlopen error"); |
|
3382 |
RETURN (nil); |
|
3383 |
} |
|
3384 |
||
3385 |
if (@global(Verbose) == true) { |
|
3386 |
console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle); |
|
3387 |
} |
|
3388 |
||
3389 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
|
3390 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
|
3391 |
RETURN (anInfoBuffer); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3392 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3393 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3394 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3395 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3396 |
#ifdef NEXT_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3397 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3398 |
long result; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3399 |
char *files[2]; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3400 |
NXStream *errOut; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3401 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3402 |
if (__isStringLike(pathName)) { |
3721 | 3403 |
files[0] = (char *) __stringVal(pathName); |
3404 |
files[1] = (char *) 0; |
|
3405 |
errOut = NXOpenFile(2, 2); |
|
3406 |
result = rld_load(errOut, |
|
3407 |
(struct mach_header **)0, |
|
3408 |
files, |
|
3409 |
(char *)0); |
|
3410 |
NXClose(errOut); |
|
3411 |
if (! result) { |
|
3412 |
@global(LinkErrorMessage) = __MKSTRING("rld_load error"); |
|
3413 |
@global(LastError) = @symbol(linkError); |
|
3414 |
if (@global(ErrorPrinting) == true) { |
|
3415 |
console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName)); |
|
3416 |
} |
|
3417 |
RETURN (nil); |
|
3418 |
} |
|
3419 |
||
3420 |
if (@global(Verbose) == true) |
|
3421 |
console_printf("rld_load %s ok\n", __stringVal(pathName)); |
|
3422 |
||
3423 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
|
3424 |
__STORE(anInfoBuffer, pathName); |
|
3425 |
RETURN ( anInfoBuffer ); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3426 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3427 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3428 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3429 |
%}. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3430 |
LastError := #notImplemented. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3431 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3432 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3433 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3434 |
primUnloadDynamicObject:aHandle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3435 |
"unload an object-file (unmap from my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3436 |
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
|
3437 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3438 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3439 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3440 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3441 |
|sysHandle1 sysHandle2| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3442 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3443 |
sysHandle1 := aHandle sysHandle1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3444 |
sysHandle2 := aHandle sysHandle2. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3445 |
|
1760
09a5b2b97f29
WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents:
1759
diff
changeset
|
3446 |
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3447 |
#ifdef GNU_DL |
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3448 |
if (__isStringLike(sysHandle1)) { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3449 |
if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3450 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3451 |
console_printf ("unlink file %s failed\n", __stringVal(sysHandle1)); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3452 |
dld_perror("cant unlink"); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3453 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3454 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3455 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3456 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3457 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3458 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3459 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3460 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3461 |
#ifdef WIN_DL |
3721 | 3462 |
INT val; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3463 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3464 |
int err; |
771 | 3465 |
jmp_buf exitJmpBuf; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3466 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3467 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
3721 | 3468 |
# if __POINTER_SIZE__ == 8 |
3469 |
val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1); |
|
3470 |
# else |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3471 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
3721 | 3472 |
# endif |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3473 |
handle = (HINSTANCE)(val); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3474 |
|
3722 | 3475 |
if (setjmp(exitJmpBuf)) { |
3476 |
__setAtExitLongJmp(exitJmpBuf); |
|
3477 |
if (@global(Verbose) == true) { |
|
3478 |
console_fprintf (stderr, |
|
3479 |
"ObjectFileLoader [info]: FreeLibrary %s handle: %"_lx_"\n", |
|
3480 |
__stringVal(sysHandle1), (INT)handle); |
|
3481 |
} |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3482 |
if (FreeLibrary(handle) != TRUE) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3483 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3484 |
err = GetLastError(); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3485 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3486 |
console_fprintf (stderr, |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3487 |
"ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n", |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3488 |
__stringVal(sysHandle1), err); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3489 |
} |
2923
10853691e2f2
oops - missing MKINT (may lead to crash in GC after unloading objects)
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
3490 |
@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err)); |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3491 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3492 |
} |
771 | 3493 |
} else { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3494 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3495 |
console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n"); |
771 | 3496 |
} |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3497 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3498 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3499 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3500 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3501 |
|
906 | 3502 |
#ifdef BEOS_DL |
3503 |
int val; |
|
3504 |
void *handle; |
|
3505 |
int ok, err; |
|
3506 |
jmp_buf exitJmpBuf; |
|
3507 |
||
3508 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3509 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3510 |
handle = (HINSTANCE)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3511 |
|
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3512 |
if (setjmp(exitJmpBuf)) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3513 |
__setAtExitLongJmp(exitJmpBuf); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3514 |
ok = unload_add_on((image_id) handle); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3515 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3516 |
if (ok != 0) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3517 |
@global(LastErrorNumber) = __MKSMALLINT(ok); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3518 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3519 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3520 |
} else { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3521 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3522 |
console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n"); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3523 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3524 |
RETURN (true); |
906 | 3525 |
} |
3526 |
RETURN (false); |
|
3527 |
#endif |
|
3528 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3529 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3530 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3531 |
void *h; |
701 | 3532 |
INT val; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3533 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3534 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3535 |
if (__bothSmallInteger(low, hi)) { |
1607
074a99bb9a50
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
3536 |
#if __POINTER_SIZE__ == 8 |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3537 |
val = (__intVal(hi) << 32) + __intVal(low); |
701 | 3538 |
#else |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3539 |
val = (_intVal(hi) << 16) + _intVal(low); |
701 | 3540 |
#endif |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3541 |
h = (void *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3542 |
if (@global(Verbose) == true) |
2998 | 3543 |
console_printf("close handle = %"_lx_"\n", (INT)h); |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3544 |
if (dlclose(h) != 0) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3545 |
console_fprintf(stderr, "dlclose failed with:<%s>\n", dlerror()); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3546 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3547 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3548 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3549 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3550 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3551 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3552 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3553 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3554 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3555 |
void *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3556 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3557 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3558 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3559 |
if (__bothSmallInteger(low, hi)) { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3560 |
val = (_intVal(hi) << 16) + _intVal(low); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3561 |
h = (void *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3562 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3563 |
console_printf("close handle = %x\n", h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3564 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3565 |
dlclose(h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3566 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3567 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3568 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3569 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3570 |
|
523 | 3571 |
#ifdef HPUX10_DL |
3572 |
{ |
|
3573 |
int *h; |
|
3574 |
int val; |
|
3575 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
3576 |
||
3577 |
if (__bothSmallInteger(low, hi)) { |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3578 |
val = (_intVal(hi) << 16) + _intVal(low); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3579 |
h = (void *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3580 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3581 |
console_printf("unload handle = %x\n", h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3582 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3583 |
shl_unload(h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3584 |
RETURN (true); |
523 | 3585 |
} |
3586 |
} |
|
3587 |
#endif |
|
3588 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3589 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3590 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3591 |
int *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3592 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3593 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3594 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3595 |
if (__bothSmallInteger(low, hi)) { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3596 |
val = (_intVal(hi) << 16) + _intVal(low); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3597 |
h = (int *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3598 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3599 |
console_printf("unload handle = %x\n", h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3600 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3601 |
if ( unload(h) != 0) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3602 |
console_fprintf(stderr, "unload failed\n"); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3603 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3604 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3605 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3606 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3607 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3608 |
#endif |
529
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3609 |
|
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3610 |
#ifdef NEXT_DL |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3611 |
{ |
1975 | 3612 |
console_fprintf(stderr, "ObjectFileLoader [warning]: Sorry, NeXTStep does not support selective unloading\n"); |
529
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3613 |
} |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3614 |
#endif |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3615 |
%}. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3616 |
^ false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3617 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3618 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3619 |
unloadDynamicObject:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3620 |
"close an object-file (unmap from my address space) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3621 |
and remove the entry from the remembered object file set. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3622 |
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
|
3623 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3624 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3625 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3626 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3627 |
|key fileName functionName deInitAddr m| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3628 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3629 |
Verbose ifTrue:[ |
3904 | 3630 |
'unload module name=' errorPrint. handle pathName errorPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3631 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3632 |
|
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3633 |
handle isUnknownHandle ifTrue:[ |
3904 | 3634 |
Verbose ifTrue:[ |
3635 |
'module type is not known - assume uninitialized classLib' errorPrintCR. |
|
3636 |
]. |
|
3637 |
self unregisterModule:handle. |
|
3638 |
handle makeClassLibHandle. |
|
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3639 |
] ifFalse:[ |
3904 | 3640 |
handle isClassLibHandle ifTrue:[ |
3641 |
Verbose ifTrue:[ |
|
3642 |
'a classLib - deinit classes' errorPrintCR. |
|
3643 |
]. |
|
3644 |
self deinitializeClassesFromModule:handle. |
|
3645 |
Verbose ifTrue:[ |
|
3646 |
'unregister' errorPrintCR. |
|
3647 |
]. |
|
3648 |
self unregisterModule:handle. |
|
3649 |
] ifFalse:[ |
|
3650 |
handle isMethodHandle ifTrue:[ |
|
3651 |
Verbose ifTrue:[ |
|
3652 |
'a methodHandle - unregister' errorPrintCR. |
|
3653 |
]. |
|
3654 |
self unregisterModule:handle. |
|
3655 |
] ifFalse:[ |
|
3656 |
handle isFunctionObjectHandle ifTrue:[ |
|
3657 |
Verbose ifTrue:[ |
|
3658 |
'a functionObject - fixup functionRefs' errorPrintCR. |
|
3659 |
]. |
|
3660 |
handle functions do:[:f | |
|
3661 |
f notNil ifTrue:[ |
|
3662 |
f invalidate |
|
3663 |
] |
|
3664 |
]. |
|
3665 |
]. |
|
3666 |
||
3667 |
"/ |
|
3668 |
"/ call its deInit function (if present) |
|
3669 |
"/ |
|
3670 |
Verbose ifTrue:[ |
|
3671 |
'search for deInit function...' errorPrintCR. |
|
3672 |
]. |
|
3673 |
fileName := handle pathName asFilename baseName. |
|
3674 |
functionName := self initFunctionBasenameForFile:fileName. |
|
3675 |
||
3676 |
deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle. |
|
3677 |
deInitAddr notNil ifTrue:[ |
|
3678 |
Verbose ifTrue:[ |
|
3679 |
'invoke deInit function...' errorPrintCR. |
|
3680 |
]. |
|
3681 |
self |
|
3682 |
saveCallInitFunctionAt:deInitAddr |
|
3683 |
in:fileName |
|
3684 |
specialInit:false |
|
3685 |
forceOld:true |
|
3686 |
interruptable:false |
|
3687 |
argument:0 |
|
3688 |
identifyAs:handle |
|
3689 |
returnsObject:false. |
|
3690 |
] |
|
3691 |
] |
|
3692 |
]. |
|
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3693 |
]. |
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3694 |
|
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3695 |
Verbose ifTrue:[ |
3904 | 3696 |
'cleanup done - now unload...' errorPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3697 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3698 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3699 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3700 |
"/ now, really unload |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3701 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3702 |
(self primUnloadDynamicObject:handle) ifFalse:[ |
3904 | 3703 |
^ self error:'unloadDynamic failed' mayProceed:true |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3704 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3705 |
|
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3706 |
Verbose ifTrue:[ |
3904 | 3707 |
'unload done ...' errorPrintCR. |
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3708 |
]. |
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3709 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3710 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3711 |
"/ remove from loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3712 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3713 |
LoadedObjects notNil ifTrue:[ |
3904 | 3714 |
key := LoadedObjects keyAtEqualValue:handle. |
3715 |
key notNil ifTrue:[ |
|
3716 |
LoadedObjects removeKey:key |
|
3717 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3718 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3719 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3720 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3721 |
for individual methods, we keep the methodObject, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3722 |
but make it unexecutable. Its still visible in the browser. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3723 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3724 |
handle isMethodHandle ifTrue:[ |
3904 | 3725 |
((m := handle method) notNil |
3726 |
and:[m ~~ 0]) ifTrue:[ |
|
3727 |
m makeUnloaded. |
|
3728 |
] |
|
791
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3729 |
]. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3730 |
|
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3731 |
handle isClassLibHandle ifTrue:[ |
3904 | 3732 |
Smalltalk flushCachedClasses. |
3733 |
Class flushSubclassInfo. |
|
791
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3734 |
]. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3735 |
handle isMethodHandle ifTrue:[ |
3904 | 3736 |
ObjectMemory flushCaches. |
791
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3737 |
]. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3738 |
|
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3739 |
handle moduleID:nil. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3740 |
handle sysHandle1:nil. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3741 |
handle sysHandle2:nil. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3742 |
|
2459 | 3743 |
"Modified: / 15-11-2010 / 13:20:20 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3744 |
! ! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3745 |
|
369 | 3746 |
!ObjectFileLoader class methodsFor:'queries'! |
141 | 3747 |
|
3556 | 3748 |
binaryClassFilenameForPackage:aPackageId inDirectory:packageDirOrNil |
3749 |
|shLibName exeDir binaryClassLibraryFilename| |
|
3750 |
||
3751 |
"Is there a shared library (.dll or .so) ?" |
|
3752 |
shLibName := aPackageId asPackageId libraryName asFilename |
|
3721 | 3753 |
withSuffix:self sharedLibrarySuffix. |
3556 | 3754 |
|
3755 |
exeDir := OperatingSystem pathOfSTXExecutable asFilename directory. |
|
3756 |
binaryClassLibraryFilename := exeDir / shLibName. |
|
3757 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3721 | 3758 |
exeDir baseName = 'bin' ifTrue:[ |
3759 |
binaryClassLibraryFilename := exeDir directory / 'lib' / shLibName. |
|
3760 |
]. |
|
3761 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3762 |
binaryClassLibraryFilename := exeDir directory / 'plugin' / shLibName. |
|
3763 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3556 | 3764 |
"/ binaryClassLibraryFilename := Filename currentDirectory / shLibName. |
3765 |
"/ binaryClassLibraryFilename exists ifFalse:[ |
|
3721 | 3766 |
packageDirOrNil notNil ifTrue:[ |
3767 |
binaryClassLibraryFilename := packageDirOrNil / shLibName. |
|
3768 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3769 |
"/ mhmh - is this a good idea ? (temporary kludge) |
|
3770 |
ExternalAddress pointerSize == 4 ifTrue:[ |
|
3771 |
binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName. |
|
3772 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3773 |
binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName. |
|
3774 |
] |
|
3775 |
] ifFalse:[ |
|
3776 |
binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName. |
|
3777 |
]. |
|
3778 |
] |
|
3779 |
] |
|
3556 | 3780 |
"/ ]. |
3721 | 3781 |
]. |
3782 |
]. |
|
3783 |
packageDirOrNil notNil ifTrue:[ |
|
3784 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3785 |
"/ look in package directory |
|
3786 |
binaryClassLibraryFilename := packageDirOrNil / shLibName. |
|
3787 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3788 |
ExternalAddress pointerSize == 4 ifTrue:[ |
|
3789 |
binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName. |
|
3790 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3791 |
binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName. |
|
3792 |
] |
|
3793 |
] ifFalse:[ |
|
3794 |
binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName. |
|
3795 |
]. |
|
3796 |
]. |
|
3797 |
]. |
|
3798 |
]. |
|
3556 | 3799 |
]. |
3800 |
^ binaryClassLibraryFilename |
|
3801 |
! |
|
3802 |
||
141 | 3803 |
canLoadObjectFiles |
259 | 3804 |
"return true, if dynamic loading is possible. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3805 |
Currently, only ELF based systems, AIX and linux a.out can do this." |
141 | 3806 |
|
3807 |
self primCanLoadObjectFiles ifTrue:[^true]. |
|
3808 |
||
3809 |
"/ can add a return true here, if I ever get manual loading to work |
|
3810 |
"/ for some specific machine |
|
3811 |
^ false |
|
259 | 3812 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3813 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3814 |
ObjectFileLoader canLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3815 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3816 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3817 |
"Modified: 8.1.1997 / 18:13:01 / cg" |
141 | 3818 |
! |
3819 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3820 |
handleForDynamicObject:pathNameOrFilename |
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3821 |
"answer the handle of pathName (or nil if it has not been loaded)" |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3822 |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3823 |
|pathName| |
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3824 |
|
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3825 |
LoadedObjects isNil ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3826 |
^ nil. |
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3827 |
]. |
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3828 |
pathName := pathNameOrFilename asFilename pathName. |
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3829 |
^ LoadedObjects at:pathName ifAbsent:nil. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3830 |
! |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3831 |
|
2393 | 3832 |
handleFromID:id |
3833 |
"given an id, return the pathName, or nil for static modules" |
|
3834 |
||
3835 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3836 |
LoadedObjects keysAndValuesDo:[:name :handle | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3837 |
handle moduleID == id ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3838 |
^ handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3839 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3840 |
]. |
2393 | 3841 |
]. |
3842 |
^ nil |
|
3843 |
||
3844 |
" |
|
3845 |
ObjectFileLoader handleFromID:1 |
|
3846 |
" |
|
3847 |
||
3848 |
"Modified: 28.8.1995 / 18:08:28 / claus" |
|
3849 |
! |
|
3850 |
||
141 | 3851 |
loadedObjectFiles |
3852 |
"return a collection containing the names of all |
|
3853 |
dynamically loaded objects." |
|
3854 |
||
3855 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
3856 |
^ LoadedObjects keys copy |
|
3857 |
||
3858 |
" |
|
3859 |
ObjectFileLoader loadedObjectFiles |
|
3860 |
" |
|
3861 |
! |
|
3862 |
||
3863 |
loadedObjectHandles |
|
3864 |
"return a collection of all handles" |
|
3865 |
||
3866 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3867 |
^ LoadedObjects |
141 | 3868 |
|
3869 |
" |
|
3870 |
ObjectFileLoader loadedObjectHandles |
|
3871 |
" |
|
3872 |
||
3873 |
"Created: 17.9.1995 / 14:28:55 / claus" |
|
3874 |
"Modified: 17.9.1995 / 16:13:48 / claus" |
|
3875 |
! |
|
3876 |
||
3877 |
loadedObjectHandlesDo:aBlock |
|
3878 |
"enumerate all handles" |
|
3879 |
||
3880 |
LoadedObjects notNil ifTrue:[ |
|
3881 |
LoadedObjects copy do:aBlock. |
|
3882 |
]. |
|
3883 |
||
3884 |
" |
|
3885 |
ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL] |
|
3886 |
" |
|
3887 |
||
3888 |
"Created: 14.9.1995 / 22:03:13 / claus" |
|
3889 |
"Modified: 14.9.1995 / 22:32:48 / claus" |
|
3890 |
! |
|
3891 |
||
1602 | 3892 |
moduleNamed:aNameString |
3893 |
"return the module named aNameString" |
|
3894 |
||
3895 |
|moduleDescriptor| |
|
3896 |
||
1906 | 3897 |
moduleDescriptor := |
3898 |
ObjectMemory binaryModuleInfo |
|
3899 |
detect:[:eachModuleDescriptor | eachModuleDescriptor libraryName = aNameString] |
|
3900 |
ifNone:[^ nil]. |
|
1742 | 3901 |
|
3902 |
^ LoadedObjects at:(moduleDescriptor pathName) ifAbsent:[]. |
|
1602 | 3903 |
|
3904 |
" |
|
3905 |
ObjectFileLoader moduleNamed:'ctypes' |
|
3906 |
" |
|
3907 |
! |
|
3908 |
||
141 | 3909 |
pathNameFromID:id |
3910 |
"given an id, return the pathName, or nil for static modules" |
|
3911 |
||
3912 |
LoadedObjects notNil ifTrue:[ |
|
3913 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
3914 |
handle moduleID == id ifTrue:[ |
|
3915 |
^ handle pathName |
|
3916 |
] |
|
3917 |
]. |
|
3918 |
]. |
|
3919 |
^ nil |
|
3920 |
||
3921 |
" |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3922 |
ObjectFileLoader pathNameFromID:1 |
141 | 3923 |
" |
3924 |
||
3925 |
"Modified: 28.8.1995 / 18:08:28 / claus" |
|
3926 |
! |
|
3927 |
||
3928 |
primCanLoadObjectFiles |
|
3929 |
"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
|
3930 |
|
141 | 3931 |
%{ /* NOCONTEXT */ |
3932 |
#ifdef HAS_DL |
|
3933 |
# if !defined(OS_DEFINE) || defined(unknownOS) |
|
1975 | 3934 |
console_fprintf(stderr, "*** OS_DEFINE not correct\n"); |
141 | 3935 |
# else |
3936 |
# if !defined(CPU_DEFINE) || defined(unknownCPU) |
|
1975 | 3937 |
console_fprintf(stderr, "*** CPU_DEFINE not correct\n"); |
141 | 3938 |
# else |
3939 |
RETURN (true); |
|
3940 |
# endif |
|
3941 |
# endif |
|
3942 |
#endif |
|
3943 |
%}. |
|
3944 |
^ false |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3945 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3946 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3947 |
ObjectFileLoader primCanLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3948 |
" |
20 | 3949 |
! ! |
3950 |
||
3556 | 3951 |
!ObjectFileLoader class methodsFor:'signal access'! |
3952 |
||
3953 |
objectFileLoadErrorNotification |
|
3954 |
^ ObjectFileLoadErrorNotification |
|
3955 |
! ! |
|
3956 |
||
369 | 3957 |
!ObjectFileLoader class methodsFor:'st object file handling'! |
303 | 3958 |
|
3959 |
callInitFunctionAt:address specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject |
|
3960 |
"call a function at address - a very dangerous operation. |
|
3961 |
This is needed to call the classes init-function after loading in a |
|
3962 |
class-object file or to call the CTORS when c++ modules are loaded. |
|
3963 |
ForceOld (if true) will have the memory manager |
|
3964 |
allocate things in oldSpace instead of newSpace. |
|
3965 |
If special is true, this is a smalltalk moduleInit (i.e. pass the vm-entries table); |
|
3966 |
otherwise, its called without arguments. |
|
3967 |
If its a smalltalk-moduleInit, it may be either for a classPackage (which should |
|
3968 |
install all of its classes) or for a single incrementally compiled methdod |
|
3969 |
(it should then NOT install it, but return the method object instead). |
|
3970 |
||
3971 |
DANGER: Internal & highly specialized. Dont use in your programs. |
|
1906 | 3972 |
This interface may change without notice." |
1018
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3973 |
|
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3974 |
|moduleID retVal oldSpaceReserve| |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3975 |
|
303 | 3976 |
handle notNil ifTrue:[ |
1906 | 3977 |
moduleID := handle moduleID |
303 | 3978 |
]. |
1018
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3979 |
"/ |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3980 |
"/ for various reasons, classes, methods, literals, methodDicts etc. |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3981 |
"/ must be allocated in oldSpace when coming from a compiled |
1759
a49b7066594c
UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents:
1745
diff
changeset
|
3982 |
"/ classLibrary, and no compressing garbage collect is allowed during |
1018
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3983 |
"/ the creation of those. |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3984 |
"/ Therefore, we must ensure, that enough oldSpace reserve is available ... |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3985 |
"/ (how much is enough ?) |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3986 |
"/ |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3987 |
oldSpaceReserve := OldSpaceReserve ? (1024*1024). |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3988 |
|
1033
f5bad5027056
More Stack when calling init function.
Stefan Vogel <sv@exept.de>
parents:
1024
diff
changeset
|
3989 |
%{ /* CALLSSTACK: 128000 */ |
303 | 3990 |
OBJ (*addr)(); |
3991 |
int prevSpace, force; |
|
591 | 3992 |
INT arg = 0, ret = 0; |
303 | 3993 |
int wasBlocked = 1; |
3994 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3995 |
if (__isInteger(address)) { |
1906 | 3996 |
if (_isSmallInteger(argument)) { |
3997 |
arg = __intVal(argument); |
|
3998 |
||
3999 |
addr = (OBJFUNC)(__longIntVal(address)); |
|
4000 |
||
4001 |
/* |
|
4002 |
* allow function to be interrupted |
|
4003 |
*/ |
|
4004 |
if (interruptable != true) { |
|
4005 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
|
4006 |
} |
|
4007 |
||
4008 |
force = (forceOld == true); |
|
4009 |
if (force) { |
|
4010 |
int reserve = __intVal(oldSpaceReserve); |
|
4011 |
if ((__oldSpaceSize() - __oldSpaceUsed()) < reserve) { |
|
4012 |
__moreOldSpace(__thisContext, reserve); |
|
4013 |
} |
|
4014 |
prevSpace = __allocForceSpace(OLDSPACE); |
|
4015 |
} |
|
4016 |
||
4017 |
if (@global(Verbose) == true) { |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
4018 |
console_printf("calling initfunc %lx(%lx) ...\n", (long)addr, (long)arg); |
1906 | 4019 |
} |
4020 |
||
4021 |
if (special == true) { |
|
4022 |
if (__isSmallInteger(moduleID)) { |
|
4023 |
__SET_MODULE_ID(__intVal(moduleID)); |
|
4024 |
} |
|
4025 |
retVal = (*addr)(arg, __pRT__); |
|
4026 |
__SET_MODULE_ID(0); |
|
4027 |
if (returnsObject != true) { |
|
4028 |
retVal = nil; |
|
4029 |
} |
|
4030 |
} else { |
|
4031 |
if (returnsObject == true) { |
|
4032 |
retVal = (*addr)(arg); |
|
4033 |
} else { |
|
4034 |
ret = (INT) ((*addr)(arg)); |
|
4035 |
retVal = __mkSmallInteger(ret); |
|
4036 |
} |
|
4037 |
} |
|
4038 |
||
4039 |
if (force) { |
|
4040 |
__allocForceSpace(prevSpace); |
|
4041 |
} |
|
4042 |
||
4043 |
if (! wasBlocked) { |
|
4044 |
__UNBLOCKINTERRUPTS(); |
|
4045 |
} |
|
4046 |
RETURN (retVal); |
|
4047 |
} |
|
303 | 4048 |
} |
4049 |
%}. |
|
4050 |
self primitiveFailed |
|
4051 |
! |
|
4052 |
||
1988
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4053 |
classPresentCheck:aClassOrClassName |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4054 |
"callBack from class registration code in VM: |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4055 |
make certain, that aClassOrClassName is loaded too ... |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4056 |
(req'd if a subclass of an autoloaded class has been loaded). |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4057 |
This is now invoked both for superClasses AND preRequisite classnames (for extensions)" |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4058 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4059 |
|className class| |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4060 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4061 |
aClassOrClassName isBehavior ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4062 |
class := aClassOrClassName. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4063 |
className := aClassOrClassName name. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4064 |
] ifFalse:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4065 |
aClassOrClassName isString ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4066 |
className := aClassOrClassName. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4067 |
class := Smalltalk classNamed:aClassOrClassName. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4068 |
] ifFalse:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4069 |
'ObjectFileLoader [warning]: check failed - no behavior' errorPrintCR. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4070 |
^ false |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4071 |
] |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4072 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4073 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4074 |
class isNil ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4075 |
Verbose ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4076 |
('ObjectFileLoader [info]: missing class: ' , className) errorPrintCR. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4077 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4078 |
"/ how can I find this missing class - need some package info |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4079 |
^ false. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4080 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4081 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4082 |
class notNil ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4083 |
Verbose ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4084 |
('ObjectFileLoader [info]: check for ' , className , ' being loaded') errorPrintCR. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4085 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4086 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4087 |
class autoload. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4088 |
(class isBehavior and:[class isLoaded]) ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4089 |
Verbose ifTrue:[ |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4090 |
('ObjectFileLoader [info]: ok, loaded. continue registration of actual class') errorPrintCR. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4091 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4092 |
class signature. "/ req'd in VM for validation |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4093 |
^ true |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4094 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4095 |
]. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4096 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4097 |
('ObjectFileLoader [warning]: superclass not loaded; registration of ' , className , ' fails') errorPrintCR. |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4098 |
^ false |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4099 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4100 |
"Modified: 10.1.1997 / 17:58:48 / cg" |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4101 |
! |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4102 |
|
303 | 4103 |
deinitializeClassesFromModule:handle |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
4104 |
"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
|
4105 |
to all classes of a module." |
303 | 4106 |
|
4107 |
|classes| |
|
4108 |
||
4109 |
classes := handle classes. |
|
4110 |
classes notNil ifTrue:[ |
|
634 | 4111 |
classes do:[:aClass | |
4112 |
aClass notNil ifTrue:[ |
|
4113 |
aClass isMeta ifFalse:[ |
|
4114 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4115 |
'send #deinitialize to:' errorPrint. aClass name errorPrintCR. |
634 | 4116 |
]. |
4117 |
aClass deinitialize. |
|
4118 |
aClass update:#aboutToUnload with:nil from:self |
|
4119 |
] |
|
4120 |
] |
|
4121 |
] |
|
303 | 4122 |
] |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
4123 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4124 |
"Modified: 10.1.1997 / 17:56:50 / cg" |
303 | 4125 |
! |
4126 |
||
4127 |
invalidateModule:handle |
|
4128 |
"invalidate all of the classes code objects ..." |
|
4129 |
||
4130 |
|id| |
|
4131 |
||
4132 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4133 |
'invalidate module; name=' errorPrint. handle pathName errorPrint. |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4134 |
' id=' errorPrint. handle moduleID errorPrintCR. |
303 | 4135 |
]. |
4136 |
||
4137 |
id := handle moduleID. |
|
4138 |
%{ |
|
4139 |
__INVALIDATE_BY_ID(__intVal(id)); |
|
4140 |
%} |
|
4141 |
! |
|
4142 |
||
4143 |
loadStatusFor:className |
|
2456 | 4144 |
"ask VM if class-hierarchy has been completely loaded, and return the status. |
2705 | 4145 |
If className ist non-nil, check the load status of this class only, |
2456 | 4146 |
otherwise check the status of all known classes. |
4147 |
||
4148 |
Answer an array with the status symbol and optionally the name of |
|
4149 |
a class with a bad status." |
|
303 | 4150 |
|
4151 |
|checker checkSymbol statusCode status badClassName| |
|
4152 |
||
4153 |
checker := self. |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4154 |
checkSymbol := #classPresentCheck:. |
303 | 4155 |
|
4156 |
%{ /* NOREGISTER */ |
|
3737 | 4157 |
char *badName = NULL; |
2705 | 4158 |
char interestingClassName[512], *classNameP = 0; |
303 | 4159 |
|
1759
a49b7066594c
UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents:
1745
diff
changeset
|
4160 |
if (__isStringLike(className)) { |
3737 | 4161 |
strncpy(interestingClassName, __stringVal(className), sizeof(interestingClassName)); |
4162 |
classNameP = interestingClassName; |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4163 |
} |
2705 | 4164 |
statusCode = __MKSMALLINT(__check_registration__(classNameP, |
3737 | 4165 |
&checker, &checkSymbol, |
4166 |
&badName)); |
|
303 | 4167 |
if (badName) { |
3737 | 4168 |
badClassName = __MKSTRING(badName); |
303 | 4169 |
} |
4170 |
%}. |
|
4171 |
statusCode == 0 ifTrue:[ |
|
3737 | 4172 |
status := #ok |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4173 |
] ifFalse:[ statusCode == -1 ifTrue:[ |
3737 | 4174 |
status := #missingClass |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4175 |
] ifFalse:[ statusCode == -2 ifTrue:[ |
3737 | 4176 |
status := #versionMismatch |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4177 |
] ifFalse:[ statusCode == -3 ifTrue:[ |
3737 | 4178 |
status := #unregisteredSuperclass |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4179 |
] ifFalse:[ statusCode == -4 ifTrue:[ |
3737 | 4180 |
status := #tryAgain |
303 | 4181 |
] ifFalse:[ |
3737 | 4182 |
status := #loadFailed |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4183 |
] ] ] ] ]. |
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4184 |
|
303 | 4185 |
^ Array with:status with:badClassName. |
4186 |
! |
|
4187 |
||
4188 |
moduleInit:phase forceOld:forceOld interruptable:interruptable |
|
4189 |
"initialization phases after registration. |
|
1759
a49b7066594c
UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents:
1745
diff
changeset
|
4190 |
DANGER: Pure magic; internal only -> don't use in your programs." |
303 | 4191 |
|
1959 | 4192 |
self primModuleInit:phase forceOld:forceOld interruptable:interruptable |
4193 |
||
4194 |
"Modified: / 06-12-2006 / 13:09:43 / cg" |
|
303 | 4195 |
! |
4196 |
||
4197 |
performModuleInitAt:initAddr for:className identifyAs:handle |
|
4198 |
"Initialize a loaded smalltalk module." |
|
4199 |
||
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4200 |
^ self |
1010 | 4201 |
performModuleInitAt:initAddr invokeInitializeMethods:true for:className identifyAs:handle. |
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4202 |
|
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4203 |
! |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4204 |
|
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4205 |
performModuleInitAt:initAddr invokeInitializeMethods:invokeInitializeMethods for:className identifyAs:handle |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4206 |
"Initialize a loaded smalltalk module." |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4207 |
|
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4208 |
|status badClassName infoCollection info classNames classes |
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4209 |
stillTrying| |
303 | 4210 |
|
4211 |
" |
|
4212 |
need 4 passes to init: 0: let module register itself & create its pools/globals |
|
3721 | 4213 |
0b check if modules superclasses are all loaded |
4214 |
1: let it get var-refs to other pools/globals |
|
4215 |
2: let it install install class, methods and literals |
|
4216 |
3: let it send #initialize to its class object |
|
303 | 4217 |
" |
4218 |
||
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4219 |
Verbose ifTrue:[ |
3721 | 4220 |
'start' errorPrintCR |
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4221 |
]. |
3006 | 4222 |
|
2456 | 4223 |
[ |
3721 | 4224 |
stillTrying := false. |
4225 |
||
4226 |
"/ |
|
4227 |
"/ let it register itself |
|
4228 |
"/ and define its globals |
|
4229 |
"/ |
|
4230 |
Verbose ifTrue:[ |
|
4231 |
'phase 0 (module registration) ...' errorPrintCR |
|
4232 |
]. |
|
4233 |
self |
|
4234 |
saveCallInitFunctionAt:initAddr |
|
4235 |
in:nil |
|
4236 |
specialInit:true |
|
4237 |
forceOld:true |
|
4238 |
interruptable:false |
|
4239 |
argument:0 |
|
4240 |
identifyAs:handle |
|
4241 |
returnsObject:false. |
|
4242 |
||
4243 |
"/ |
|
4244 |
"/ check if superclasses are present |
|
4245 |
"/ |
|
4246 |
info := self loadStatusFor:className. |
|
4247 |
status := info at:1. |
|
4248 |
badClassName := info at:2. |
|
4249 |
||
4250 |
Verbose ifTrue:[ |
|
4251 |
'... info is ' errorPrint. info errorPrintCR |
|
4252 |
]. |
|
4253 |
||
4254 |
(status ~~ #ok) ifTrue:[ |
|
4255 |
(status == #missingClass) ifTrue:[ |
|
4256 |
('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR. |
|
4257 |
^ info |
|
4258 |
]. |
|
4259 |
(status == #versionMismatch) ifTrue:[ |
|
4260 |
('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR. |
|
4261 |
^ info |
|
4262 |
]. |
|
4263 |
(status == #unregisteredSuperclass) ifTrue:[ |
|
4264 |
('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR. |
|
4265 |
^ info |
|
4266 |
]. |
|
4267 |
(status == #tryAgain) ifTrue:[ |
|
4268 |
"/ tryAgain: |
|
4269 |
"/ must retry after initialization, to initialize |
|
4270 |
"/ sub-subclasses of autoloaded classes |
|
4271 |
"/ (sigh - class objects are created in phase 3, |
|
4272 |
"/ so we must first complete the initialization cycle, |
|
4273 |
"/ then do all again, for remaining modules) |
|
4274 |
stillTrying := true. |
|
4275 |
'ObjectFileLoader [info]: retry registration of: ' infoPrint. |
|
4276 |
(className ? 'a classLib') infoPrint. ' after init' infoPrintCR. |
|
4277 |
] ifFalse:[ |
|
4278 |
'ObjectFileLoader [error]: load failed: ' infoPrint. className infoPrintCR. |
|
4279 |
^ Array with:#loadFailed with:nil |
|
4280 |
]. |
|
4281 |
]. |
|
4282 |
||
4283 |
Smalltalk flushCachedClasses. |
|
4284 |
Class flushSubclassInfo. |
|
4285 |
"/ |
|
4286 |
"/ remaining initialization |
|
4287 |
"/ |
|
4288 |
||
4289 |
"/ module exports: declare module-globals & symbols ... |
|
4290 |
Verbose ifTrue:[ |
|
4291 |
'phase 1 (resolve globals) ...' errorPrintCR |
|
4292 |
]. |
|
4293 |
self moduleInit:1 forceOld:true interruptable:false. |
|
4294 |
||
4295 |
"/ module-imports: resolve globals ... |
|
4296 |
"/ create methods & install ... |
|
4297 |
Verbose ifTrue:[ |
|
4298 |
'phase 2 (create objects) ...' errorPrintCR |
|
4299 |
]. |
|
4300 |
self moduleInit:2 forceOld:true interruptable:false. |
|
4301 |
||
4302 |
Verbose ifTrue:[ |
|
4303 |
'stillTrying is ' errorPrint. stillTrying errorPrintCR |
|
4304 |
]. |
|
2456 | 4305 |
] doWhile:[stillTrying]. |
4306 |
||
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4307 |
Verbose ifTrue:[ |
3721 | 4308 |
'end' errorPrintCR |
303 | 4309 |
]. |
4310 |
||
4311 |
ObjectMemory flushCaches. |
|
4312 |
||
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4313 |
invokeInitializeMethods ifTrue:[ |
3721 | 4314 |
Verbose ifTrue:[ |
4315 |
'phase 3 (send #initialize) ...' errorPrintCR |
|
4316 |
]. |
|
4317 |
"/ initialize ... |
|
4318 |
self moduleInit:3 forceOld:false interruptable:true. |
|
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4319 |
]. |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4320 |
|
303 | 4321 |
"/ ask objectMemory for the classes we have just loaded |
4322 |
"/ and register them in the handle |
|
4323 |
||
4324 |
infoCollection := ObjectMemory binaryModuleInfo. |
|
4325 |
info := infoCollection at:handle moduleID ifAbsent:nil. |
|
4326 |
info isNil ifTrue:[ |
|
3721 | 4327 |
"/ mhmh registration failed - |
4328 |
'ObjectFileLoader [error]: registration failed: ' infoPrint. |
|
4329 |
(className ? 'some classLib') infoPrintCR. |
|
4330 |
^ Array with:#registrationFailed with:nil |
|
303 | 4331 |
]. |
4332 |
||
405
92cb91b82cf7
changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4333 |
classNames := info classNames. |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
4334 |
classNames notEmptyOrNil ifTrue:[ |
3721 | 4335 |
classes := OrderedCollection new:classNames size. |
4336 |
classNames do:[:eachClassName | |class| |
|
4337 |
class := Smalltalk classNamed:eachClassName. |
|
4338 |
class notNil ifTrue:[ |
|
4339 |
classes add:class. |
|
4340 |
]. |
|
4341 |
]. |
|
303 | 4342 |
]. |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
4343 |
classes notEmptyOrNil ifTrue:[ |
3721 | 4344 |
classes := classes asArray. |
4345 |
classes := classes , (classes collect:[:aClass | aClass class]). |
|
303 | 4346 |
]. |
4347 |
handle classes:classes. |
|
4348 |
||
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4349 |
"/ invokeinitializemethods iftrue:[ |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4350 |
"/ verbose iftrue:[ |
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4351 |
"/ 'phase 3 (send #initialize) ...' errorPrintCR |
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4352 |
"/ ]. |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4353 |
"/ "/ INITIALIZE ... |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4354 |
"/ self moduleinit:3 forceold:false interruptable:true. |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4355 |
"/ ]. |
881
ed4efb1b161e
perform moduleInit3 AFTER registering the module.
Claus Gittinger <cg@exept.de>
parents:
880
diff
changeset
|
4356 |
|
303 | 4357 |
^ Array with:#ok with:nil |
4358 |
||
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
4359 |
"Modified: / 29-07-2004 / 17:12:28 / stefan" |
2459 | 4360 |
"Modified: / 15-11-2010 / 13:20:11 / cg" |
303 | 4361 |
! |
4362 |
||
1959 | 4363 |
primModuleInit:phase forceOld:forceOld interruptable:interruptable |
4364 |
"initialization phases after registration. |
|
4365 |
DANGER: Pure magic; internal only -> don't use in your programs." |
|
4366 |
||
4367 |
%{ |
|
4368 |
int prevSpace, force; |
|
4369 |
int wasBlocked = 1; |
|
4370 |
||
4371 |
if (__isSmallInteger(phase)) { |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4372 |
if (interruptable != true) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4373 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4374 |
} |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4375 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4376 |
force = (forceOld == true); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4377 |
if (force) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4378 |
prevSpace = __allocForceSpace(OLDSPACE); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4379 |
} |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4380 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4381 |
__init_registered_modules__(__intVal(phase)); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4382 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4383 |
if (force) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4384 |
__allocForceSpace(prevSpace); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4385 |
} |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4386 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4387 |
if (! wasBlocked) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4388 |
__UNBLOCKINTERRUPTS(); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4389 |
} |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4390 |
RETURN (self); |
1959 | 4391 |
} |
4392 |
%}. |
|
4393 |
self primitiveFailed |
|
4394 |
||
4395 |
"Created: / 06-12-2006 / 13:09:24 / cg" |
|
4396 |
! |
|
4397 |
||
303 | 4398 |
revalidateModule:handle |
4399 |
"revalidate all of the classes code objects ..." |
|
4400 |
||
4401 |
|id| |
|
4402 |
||
4403 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4404 |
'revalidate module; name=' errorPrint. handle pathName errorPrint. |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4405 |
' id=' errorPrint. handle moduleID errorPrintCR. |
303 | 4406 |
]. |
4407 |
||
4408 |
id := handle moduleID. |
|
4409 |
%{ |
|
4410 |
__REVALIDATE_BY_ID(__intVal(id)); |
|
4411 |
%} |
|
4412 |
! |
|
4413 |
||
2459 | 4414 |
saveCallInitFunctionAt:address in:aFilenameOrNil specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject |
4415 |
OSSignalInterrupt handle:[:ex | |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4416 |
aFilenameOrNil notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4417 |
('ObjectFileLoader [warning]: SignalInterrupt from initFunction in %1' bindWith:(aFilenameOrNil asFilename pathName)) errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4418 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4419 |
'ObjectFileLoader [warning]: SignalInterrupt from initFunction' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4420 |
]. |
2459 | 4421 |
] do:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4422 |
^ self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4423 |
callInitFunctionAt:address |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4424 |
specialInit:special |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4425 |
forceOld:forceOld |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4426 |
interruptable:interruptable |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4427 |
argument:argument |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4428 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4429 |
returnsObject:returnsObject |
2459 | 4430 |
]. |
4431 |
||
4432 |
"Created: / 15-11-2010 / 13:21:59 / cg" |
|
4433 |
! |
|
4434 |
||
303 | 4435 |
unregisterModule:handle |
4436 |
"unregister classes in the VM. |
|
4437 |
This invalidates all of the classes code objects ..." |
|
4438 |
||
4439 |
|id| |
|
4440 |
||
4441 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4442 |
'unregister module; name=' errorPrint. handle pathName errorPrint. |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4443 |
' id=' errorPrint. handle moduleID errorPrintCR. |
303 | 4444 |
]. |
4445 |
||
4446 |
id := handle moduleID. |
|
4447 |
%{ |
|
4448 |
__UNREGISTER_BY_ID(__intVal(id)); |
|
4449 |
%} |
|
4450 |
! ! |
|
4451 |
||
2408 | 4452 |
!ObjectFileLoader class methodsFor:'under test - loading dlls'! |
4453 |
||
4454 |
loadObjectFiles:aSeqOfFiles |
|
4455 |
"load a sequence of DLLs... first load all DLLs with #moduleInit:0 |
|
2661 | 4456 |
then call #moduleInit:1, #moduleInit:2 and #moduleInit:3 for all loaded DLLs. |
4457 |
||
4458 |
*** UNDER TEST ... |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4459 |
used by ExpeccoStartup under windows. |
2408 | 4460 |
|
2661 | 4461 |
not supported is C,... |
2408 | 4462 |
" |
2661 | 4463 |
|
2408 | 4464 |
|filename handle initAddr className infoCollection handles info| |
4465 |
||
4466 |
aSeqOfFiles isEmptyOrNil ifTrue:[^ self]. |
|
4467 |
||
4468 |
handles := OrderedCollection new. |
|
4469 |
||
4470 |
Smalltalk flushCachedClasses. |
|
4471 |
Class flushSubclassInfo. |
|
4472 |
||
4473 |
aSeqOfFiles do:[:each| |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4474 |
filename := each asFilename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4475 |
handle := self handleForDynamicObject:filename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4476 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4477 |
handle isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4478 |
Smalltalk showSplashMessage:('loading ', filename baseName). |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4479 |
handle := self loadDynamicObject:filename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4480 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4481 |
handle notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4482 |
className := self initFunctionBasenameForFile:filename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4483 |
initAddr := self findInitFunction:className in:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4484 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4485 |
initAddr notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4486 |
[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4487 |
self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4488 |
saveCallInitFunctionAt:initAddr |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4489 |
in:filename |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4490 |
specialInit:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4491 |
forceOld:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4492 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4493 |
argument:0 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4494 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4495 |
returnsObject:false. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4496 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4497 |
info := self loadStatusFor:nil. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4498 |
(info first == #tryAgain) |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4499 |
] whileTrue. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4500 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4501 |
info first == #ok ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4502 |
handles add:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4503 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4504 |
( '%1: error during init: %2' bindWith:each with:info) printCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4505 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4506 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4507 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4508 |
]. |
2408 | 4509 |
]. |
2661 | 4510 |
Smalltalk showSplashMessage:('initializing modules-1...'). |
2408 | 4511 |
self moduleInit:1 forceOld:true interruptable:false. |
2661 | 4512 |
Smalltalk showSplashMessage:('initializing modules-2...'). |
2408 | 4513 |
self moduleInit:2 forceOld:true interruptable:false. |
4514 |
ObjectMemory flushCaches. |
|
2661 | 4515 |
Smalltalk showSplashMessage:('initializing modules-3...'). |
2408 | 4516 |
self moduleInit:3 forceOld:false interruptable:true. |
4517 |
||
4518 |
infoCollection := ObjectMemory binaryModuleInfo. |
|
4519 |
||
4520 |
handles do:[:each| |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4521 |
|classNames classes| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4522 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4523 |
info := infoCollection at:(handle moduleID) ifAbsent:nil. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4524 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4525 |
info isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4526 |
('error - nil info: %1' bindWith:handle ) printCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4527 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4528 |
classNames := info classNames. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4529 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4530 |
classNames notEmptyOrNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4531 |
classes := OrderedCollection new:classNames size. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4532 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4533 |
classNames do:[:eachClassName | |class| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4534 |
class := Smalltalk classNamed:eachClassName. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4535 |
class notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4536 |
classes add:class. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4537 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4538 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4539 |
classes notEmptyOrNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4540 |
classes := classes asArray. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4541 |
classes := classes , (classes collect:[:aClass | aClass class]). |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4542 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4543 |
handle classes:classes. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4544 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4545 |
]. |
2408 | 4546 |
]. |
2661 | 4547 |
Smalltalk showSplashMessage:('done loading modules.'). |
2408 | 4548 |
|
4549 |
" |
|
4550 |
|directory filename dlls| |
|
4551 |
||
4552 |
directory := 'C:\Dokumente und Einstellungen\Steffen Jung\work\exept\expecco\application' asFilename. |
|
4553 |
filename := directory construct:'modules.stx'. |
|
4554 |
||
4555 |
dlls := OrderedCollection new. |
|
4556 |
||
4557 |
filename readingLinesDo:[:aLine| |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4558 |
|line dllFile| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4559 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4560 |
line := aLine withoutSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4561 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4562 |
line size > 3 ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4563 |
line first ~~ $# ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4564 |
dllFile := directory construct:(line, '.dll'). |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4565 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4566 |
dllFile exists ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4567 |
dlls add:dllFile. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4568 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4569 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4570 |
] |
2408 | 4571 |
]. |
4572 |
ObjectFileLoader loadObjectFiles:dlls. |
|
4573 |
" |
|
2459 | 4574 |
|
2661 | 4575 |
"Modified: / 11-08-2011 / 17:25:52 / cg" |
2408 | 4576 |
! ! |
4577 |
||
369 | 4578 |
!ObjectFileLoader class methodsFor:'documentation'! |
148 | 4579 |
|
4580 |
version |
|
3721 | 4581 |
^ '$Header$' |
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
4582 |
! |
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
4583 |
|
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
4584 |
version_CVS |
3721 | 4585 |
^ '$Header$' |
148 | 4586 |
! ! |
1358 | 4587 |
|
2992 | 4588 |
|
0 | 4589 |
ObjectFileLoader initialize! |