author | Claus Gittinger <cg@exept.de> |
Wed, 18 May 2016 13:02:05 +0200 | |
changeset 3890 | b4ef457a02a2 |
parent 3737 | b7c743f08003 |
child 3892 | 92e78fd2023b |
child 3895 | eb4e8f03c257 |
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:'' |
18 |
classVariableNames:'MySymbolTable Verbose LastError LinkErrorMessage NextHandleID |
|
149
3dc42a5ab417
default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
19 |
LoadedObjects PreviouslyLoadedObjects ActuallyLoadedObjects |
2982 | 20 |
ErrorPrinting LastErrorNumber OldSpaceReserve |
21 |
CopyLibrariesWhenLoading' |
|
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:[ |
|
1258 |
Transcript showCR:' ... trying ' , libName , ' to resolve undefined symbols ...'. |
|
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:[ |
|
1267 |
Transcript showCR:('ObjectFileLoader [info]: still undefined symbols in ', pathName,'.'). |
|
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:[ |
|
1311 |
definitionClass |
|
1312 |
initialize; |
|
1313 |
loadMandatoryPreRequisitesAsAutoloaded:false. |
|
1314 |
]. |
|
1315 |
]. |
|
1316 |
] |
|
1317 |
]. |
|
3006 | 1318 |
]. |
1993
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1319 |
"look for explicit init (xxx_Init) function |
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1320 |
This is used in ST object files" |
b83da4907a07
more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents:
1988
diff
changeset
|
1321 |
|
3006 | 1322 |
initAddr := self findInitFunction:initFunctionName in:handle. |
141 | 1323 |
initAddr notNil ifTrue:[ |
3736 | 1324 |
Verbose ifTrue:[ |
1325 |
('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR. |
|
1326 |
]. |
|
1327 |
info := self |
|
1328 |
performModuleInitAt:initAddr |
|
1329 |
invokeInitializeMethods:invokeInitializeMethods |
|
1330 |
for:nil |
|
1331 |
identifyAs:handle. |
|
1332 |
status := info at:1. |
|
1333 |
status == #ok ifTrue:[ |
|
1334 |
didInit := true. |
|
1335 |
definitionClassName notNil ifTrue:[ |
|
1336 |
definitionClass := Smalltalk classNamed:definitionClassName. |
|
1337 |
] |
|
1338 |
] |
|
141 | 1339 |
] ifFalse:[ |
3736 | 1340 |
"look for explicit C-init (xxx__Init) function |
1341 |
This is used in C object files" |
|
1342 |
||
1343 |
initAddr := self findFunction:initFunctionName suffix:'__Init' in:handle. |
|
1344 |
initAddr notNil ifTrue:[ |
|
1345 |
isCModule := true. |
|
1346 |
||
1347 |
OSSignalInterrupt handle:[:ex | |
|
1348 |
('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , pathName) errorPrintCR. |
|
1349 |
status := #initFailed. |
|
1350 |
] do:[ |
|
1351 |
cRetVal := self |
|
1352 |
saveCallInitFunctionAt:initAddr |
|
1353 |
in:pathNameOrFilename |
|
1354 |
specialInit:false |
|
1355 |
forceOld:true |
|
1356 |
interruptable:false |
|
1357 |
argument:0 |
|
1358 |
identifyAs:handle |
|
1359 |
returnsObject:false. |
|
1360 |
(cRetVal < 0) ifTrue:[ |
|
1361 |
Verbose ifTrue:[ |
|
1362 |
'init function return failure ... unload' errorPrintCR. |
|
1363 |
]. |
|
1364 |
status := #initFailed. |
|
1365 |
] ifFalse:[ |
|
1366 |
didInit := true. |
|
1367 |
] |
|
1368 |
] |
|
1369 |
] ifFalse:[ |
|
1370 |
status := #noInitFunction. |
|
1371 |
||
1372 |
"look for any init-function(s); call them all" |
|
1373 |
Verbose ifTrue:[ |
|
1374 |
'no good init functions found; looking for candidates ...' errorPrintCR. |
|
1375 |
]. |
|
1376 |
initNames := self namesMatching:'*_Init' segment:'[tT?]' in:pathName. |
|
1377 |
initNames notNil ifTrue:[ |
|
1378 |
initNames do:[:aName | |
|
1379 |
initAddr := self getFunction:aName from:handle. |
|
1380 |
initAddr isNil ifTrue:[ |
|
1381 |
(aName startsWith:'_') ifTrue:[ |
|
1382 |
initAddr := self getFunction:(aName copyFrom:2) from:handle. |
|
1383 |
]. |
|
1384 |
]. |
|
1385 |
initAddr isNil ifTrue:[ |
|
1386 |
Transcript showCR:('no symbol: ',aName,' in ', pathName). |
|
1387 |
] ifFalse:[ |
|
1388 |
Verbose ifTrue:[ |
|
1389 |
('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR |
|
1390 |
]. |
|
1391 |
self |
|
1392 |
performModuleInitAt:initAddr |
|
1393 |
invokeInitializeMethods:invokeInitializeMethods |
|
1394 |
for:nil |
|
1395 |
identifyAs:handle. |
|
1396 |
didInit := true. |
|
1397 |
] |
|
1398 |
]. |
|
1399 |
]. |
|
1400 |
] |
|
141 | 1401 |
]. |
1402 |
||
2457
1927f463ca87
changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents:
2456
diff
changeset
|
1403 |
(invokeInitializeMethods and:[didInit not]) ifTrue:[ |
3736 | 1404 |
status == #noInitFunction ifTrue:[ |
1405 |
msg := 'no classLib init function found; assume load ok' |
|
1406 |
] ifFalse:[ |
|
1407 |
(status ~~ #registrationFailed |
|
1408 |
and:[status ~~ #initFailed |
|
1409 |
and:[status ~~ #missingClass |
|
1410 |
and:[status ~~ #versionMismatch]]]) |
|
1411 |
ifTrue:[ |
|
1412 |
self listUndefinedSymbolsIn:handle. |
|
1413 |
]. |
|
1414 |
||
1415 |
Verbose ifTrue:[ |
|
1416 |
'unloading, since init failed ...' errorPrintCR. |
|
1417 |
]. |
|
1418 |
||
1419 |
"/ give caller a chance to prevent unloading (to register later, when a prerequisite class comes) |
|
1420 |
status == #missingClass ifTrue:[ |
|
1421 |
self breakPoint:#sv. |
|
1422 |
doNotUnload := (SuperClassMissingErrorNotification query ? false). |
|
1423 |
] ifFalse:[ |
|
1424 |
status == #registrationFailed ifTrue:[ |
|
1425 |
self breakPoint:#sv. |
|
1426 |
doNotUnload := (RegistrationFailedErrorNotification query ? false). |
|
1427 |
] ifFalse:[ |
|
1428 |
doNotUnload := false. |
|
1429 |
]. |
|
1430 |
]. |
|
1431 |
doNotUnload ifFalse:[ |
|
1432 |
self unloadDynamicObject:handle. |
|
1433 |
Verbose ifTrue:[ |
|
1434 |
'unloaded.' errorPrintCR. |
|
1435 |
]. |
|
1436 |
handle := nil. |
|
1437 |
]. |
|
1438 |
||
1439 |
status == #initFailed ifTrue:[ |
|
1440 |
msg := 'module not loaded (init function signaled failure).' |
|
1441 |
] ifFalse:[ |
|
1442 |
status == #missingClass ifTrue:[ |
|
1443 |
msg := 'module not loaded (superclass missing: ' , (info at:2) , ').' |
|
1444 |
] ifFalse:[ |
|
1445 |
status == #registrationFailed ifTrue:[ |
|
1446 |
msg := 'module registration failed (incompatible object or missing superclass)' |
|
1447 |
] ifFalse:[ |
|
1448 |
status == #versionMismatch ifTrue:[ |
|
1449 |
msg := 'module registration failed (class version mismatch ' , (info at:2) printString , ')' |
|
1450 |
] ifFalse:[ |
|
1451 |
(self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:pathName) notNil ifTrue:[ |
|
1452 |
msg := 'module not loaded (unknown error reason).' |
|
1453 |
] ifFalse:[ |
|
1454 |
msg := 'module not loaded (no _Init entry in object file ?).' |
|
1455 |
] |
|
1456 |
] |
|
1457 |
]. |
|
1458 |
]. |
|
1459 |
]. |
|
1460 |
]. |
|
1461 |
msg := 'ObjectFileLoader [info]: <1p>: <2p>' expandMacrosWith:pathNameOrFilename asFilename baseName with:msg. |
|
1462 |
Smalltalk isStandAloneApp ifTrue:[ |
|
1463 |
msg errorPrintCR |
|
1464 |
] ifFalse:[ |
|
1465 |
Transcript showCR:msg |
|
1466 |
]. |
|
141 | 1467 |
]. |
1468 |
||
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1469 |
isCModule ifFalse:[ |
3736 | 1470 |
Smalltalk flushCachedClasses. |
1471 |
Class flushSubclassInfo. |
|
1472 |
||
1473 |
(definitionClass notNil and:[definitionClass isLoaded]) ifTrue:[ |
|
1474 |
definitionClass supportedOnPlatform ifTrue:[ |
|
1475 |
definitionClass loadAllClassesAsAutoloaded:true. |
|
1476 |
"/ load non-mandatory prerequisites |
|
1477 |
definitionClass loadPreRequisitesAsAutoloaded:true. |
|
1478 |
definitionClass projectIsLoaded:true. |
|
1479 |
]. |
|
1480 |
]. |
|
1481 |
Smalltalk isInitialized ifTrue:[ |
|
1482 |
"really don't know, if and what has changed ... |
|
1483 |
... but assume, that new classes have been installed." |
|
1484 |
Smalltalk changed:#postLoad. |
|
1485 |
]. |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
1486 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1487 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1488 |
|
2459 | 1489 |
"Modified: / 15-11-2010 / 13:19:26 / cg" |
141 | 1490 |
! |
1491 |
||
1492 |
unloadAllObsoleteObjectFiles |
|
1493 |
"unload all dynamically loaded object files for which the classes/method |
|
1494 |
has been already garbage collected." |
|
1495 |
||
1496 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1497 |
LoadedObjects values copy do:[:eachHandle | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1498 |
(eachHandle notNil and:[eachHandle isObsolete]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1499 |
self unloadDynamicObject:eachHandle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1500 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1501 |
] |
141 | 1502 |
]. |
1503 |
||
1504 |
" |
|
1505 |
ObjectFileLoader unloadAllObsoleteObjectFiles |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1506 |
" |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1507 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1508 |
"Modified: 5.12.1995 / 18:16:52 / cg" |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1509 |
! |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1510 |
|
141 | 1511 |
unloadObjectFile:aFileName |
1512 |
"unload an object file (.o-file) from the image. |
|
1513 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1514 |
objects of this module exist - in future versions, the system will keep |
|
1515 |
track of these. For now, use at your own risk. |
|
1516 |
(especially critical are blocks-functions)." |
|
1517 |
||
1518 |
|handle| |
|
1519 |
||
1520 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1521 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
141 | 1522 |
]. |
1523 |
handle isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1524 |
('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
|
1525 |
^ self |
141 | 1526 |
]. |
1527 |
||
2348
b2a3bb714bf6
comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents:
2346
diff
changeset
|
1528 |
"/ call the modules deInit-function and unload... |
141 | 1529 |
self unloadDynamicObject:handle |
1961 | 1530 |
|
1531 |
"Modified: / 06-12-2006 / 18:19:13 / cg" |
|
634 | 1532 |
! |
1533 |
||
1534 |
unloadObjectFileAndRemoveClasses:aFileName |
|
1535 |
"unload an object file (.o-file) from the image and remove all |
|
1536 |
corresponding classes from the system. |
|
1537 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1538 |
objects of this module exist - in future versions, the system will keep |
|
1539 |
track of these. For now, use at your own risk. |
|
1540 |
(especially critical are blocks-functions)." |
|
1541 |
||
1542 |
|handle| |
|
1543 |
||
1544 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1545 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
634 | 1546 |
]. |
1547 |
handle isNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1548 |
('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
|
1549 |
^ self |
634 | 1550 |
]. |
1551 |
handle isClassLibHandle ifFalse:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1552 |
self error:'Module is not a classLib module. Proceed to unload anyway' mayProceed:true. |
634 | 1553 |
]. |
1554 |
||
1555 |
"/ remove the classes ... |
|
1556 |
Class withoutUpdatingChangesDo:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1557 |
handle classes do:[:eachClass | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1558 |
(eachClass notNil and:[eachClass isMeta not]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1559 |
eachClass removeFromSystem. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1560 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
1561 |
] |
634 | 1562 |
]. |
1563 |
||
2348
b2a3bb714bf6
comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents:
2346
diff
changeset
|
1564 |
"/ call the modules deInit-function and unload... |
634 | 1565 |
self unloadDynamicObject:handle |
1566 |
||
1961 | 1567 |
"Modified: / 06-12-2006 / 18:19:19 / cg" |
141 | 1568 |
! ! |
1569 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1570 |
!ObjectFileLoader class methodsFor:'dynamic object queries'! |
141 | 1571 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1572 |
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
|
1573 |
"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
|
1574 |
|
609 | 1575 |
|initAddr className nm| |
1576 |
||
1577 |
"/ care for colons, as found in nameSpace classes ... |
|
3499 | 1578 |
nm := functionName asString. |
1579 |
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
|
1580 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1581 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1582 |
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
|
1583 |
" |
609 | 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 |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1587 |
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
|
1588 |
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
|
1589 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1590 |
"/ |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1591 |
"/ 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
|
1592 |
"/ (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
|
1593 |
"/ 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
|
1594 |
"/ |
609 | 1595 |
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
|
1596 |
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
|
1597 |
|
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1598 |
(functionName startsWith:'lib') ifTrue:[ |
3721 | 1599 |
className := functionName |
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1600 |
] ifFalse:[ |
3721 | 1601 |
" |
1602 |
look for reverse abbreviation - slow, because abbrevs are recursively read |
|
1603 |
" |
|
1604 |
className := Smalltalk classNameForFile:functionName. |
|
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1605 |
]. |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1606 |
className notNil ifTrue:[ |
3721 | 1607 |
initAddr := self getFunction:(className , suffix) from:handle. |
1608 |
initAddr notNil ifTrue:[^ initAddr]. |
|
1609 |
||
1610 |
initAddr := self getFunction:('_' , className , suffix) from:handle. |
|
1611 |
initAddr isNil ifTrue:[ |
|
1612 |
"/ |
|
1613 |
"/ special for broken ultrix nlist |
|
1614 |
"/ (will not find symbol with single underscore) |
|
1615 |
"/ workaround: add another underscore and retry |
|
1616 |
"/ |
|
1617 |
initAddr := self getFunction:('__' , className , suffix) from:handle. |
|
1618 |
]. |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1619 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1620 |
^ initAddr |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1621 |
|
2784
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1622 |
"Created: / 13-07-1996 / 00:38:01 / cg" |
6e2515a22a6c
changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents:
2767
diff
changeset
|
1623 |
"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
|
1624 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1625 |
|
3006 | 1626 |
findInitDefinitionFunction:functionName in:handle |
1627 |
"look for the initDefinition function and return its address or nil" |
|
1628 |
||
1629 |
^ self findFunction:functionName suffix:'_InitDefinition' in:handle |
|
1630 |
||
1631 |
"Modified: 13.7.1996 / 00:38:33 / cg" |
|
1632 |
! |
|
1633 |
||
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1634 |
findInitFunction:functionName in:handle |
3006 | 1635 |
"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
|
1636 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1637 |
^ 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
|
1638 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1639 |
"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
|
1640 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1641 |
|
1745 | 1642 |
getFunction:aStringOrSymbol from:handle |
141 | 1643 |
"return the address of a function from a dynamically loaded object file. |
1644 |
Handle must be the one returned previously from loadDynamicObject. |
|
1645 |
Return the address of the function, or nil on any error." |
|
1646 |
||
1745 | 1647 |
^ self getSymbol:aStringOrSymbol asString function:true from:handle |
141 | 1648 |
! |
1649 |
||
1650 |
getListOfUndefinedSymbolsFrom:aHandle |
|
1651 |
"return a collection of undefined symbols in a dynamically loaded object file. |
|
1652 |
Handle must be the one returned previously from loadDynamicObject. |
|
1653 |
Not all systems allow an object with undefined symbols to be |
|
1654 |
loaded (actually, only dld does)." |
|
1655 |
||
1656 |
|list| |
|
1657 |
||
1658 |
%{ /* STACK: 20000 */ |
|
1659 |
#ifdef GNU_DL |
|
1660 |
void (*func)(); |
|
1661 |
unsigned long addr; |
|
1662 |
char *name; |
|
1663 |
int nMax; |
|
1664 |
char **undefNames; |
|
1665 |
||
1666 |
undefNames = dld_list_undefined_sym(); |
|
1667 |
if (dld_undefined_sym_count > 0) { |
|
1668 |
char **nm; |
|
1669 |
int index; |
|
1670 |
int count = dld_undefined_sym_count; |
|
1671 |
||
1672 |
if (count > 100) count = 100; |
|
1673 |
list = __ARRAY_NEW_INT(count); |
|
1674 |
if (list) { |
|
1675 |
nm = undefNames; |
|
1676 |
for (index = 0; index < count; index++) { |
|
1677 |
OBJ s; |
|
1678 |
||
238 | 1679 |
s = __MKSTRING(*nm); |
1680 |
__ArrayInstPtr(list)->a_element[index] = s; |
|
141 | 1681 |
__STORE(list, s); |
1682 |
nm++; |
|
1683 |
} |
|
1684 |
free(undefNames); |
|
1685 |
} |
|
1686 |
} |
|
1687 |
#endif |
|
1688 |
||
1689 |
#ifdef DL1_6 |
|
1690 |
/* |
|
2998 | 1691 |
* don't know how to do it |
141 | 1692 |
*/ |
1693 |
#endif |
|
1694 |
||
1695 |
#ifdef SYSV4_DL |
|
1696 |
/* |
|
2998 | 1697 |
* don't know how to do it |
141 | 1698 |
*/ |
1699 |
#endif |
|
1700 |
||
1701 |
#ifdef SUN_DL |
|
1702 |
/* |
|
2998 | 1703 |
* don't know how to do it |
141 | 1704 |
*/ |
1705 |
#endif |
|
1706 |
||
1707 |
#ifdef NEXT_DL |
|
1708 |
/* |
|
2998 | 1709 |
* don't know how to do it |
141 | 1710 |
*/ |
1711 |
#endif |
|
180 | 1712 |
|
1713 |
#ifdef WIN_DL |
|
1714 |
/* |
|
2998 | 1715 |
* don't know how to do it |
180 | 1716 |
*/ |
1717 |
#endif |
|
1718 |
||
906 | 1719 |
#ifdef BEOS_DL |
1720 |
/* |
|
2998 | 1721 |
* don't know how to do it |
906 | 1722 |
*/ |
1723 |
#endif |
|
1724 |
||
141 | 1725 |
%}. |
1726 |
^ list |
|
1727 |
! |
|
1728 |
||
1729 |
getSymbol:aString function:isFunction from:aHandle |
|
1730 |
"return the address of a symbol/function from a dynamically loaded object file. |
|
1731 |
Handle must be the one returned previously from loadDynamicObject. |
|
1732 |
Return the address of the symbol, or nil on any error." |
|
1733 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1734 |
|sysHandle1 sysHandle2 pathName address| |
141 | 1735 |
|
1736 |
sysHandle1 := aHandle sysHandle1. |
|
1737 |
sysHandle2 := aHandle sysHandle2. |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1738 |
pathName := aHandle pathName. |
141 | 1739 |
|
1740 |
%{ /* STACK: 20000 */ |
|
1741 |
||
1742 |
#ifdef GNU_DL |
|
1743 |
{ |
|
1744 |
void (*func)(); |
|
2998 | 1745 |
unsigned INT addr; |
141 | 1746 |
char *name; |
1747 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
1748 |
if (__isStringLike(aString)) { |
3721 | 1749 |
name = (char *) __stringVal(aString); |
1750 |
if (isFunction == false) { |
|
1751 |
addr = dld_get_symbol(name); |
|
1752 |
if (addr) { |
|
1753 |
if (@global(Verbose) == true) { |
|
1754 |
console_printf("addr of %s = %x\n", name, addr); |
|
1755 |
} |
|
1756 |
address = __MKUINT( addr ); |
|
1757 |
} |
|
1758 |
} else { |
|
1759 |
func = (void (*) ()) dld_get_func(name); |
|
1760 |
if (func) { |
|
1761 |
if (@global(Verbose) == true) { |
|
1762 |
console_printf("addr of %s = %x\n", name, (INT)func); |
|
1763 |
} |
|
1764 |
if (dld_function_executable_p(name)) { |
|
1765 |
address = __MKUINT( (INT)func ); |
|
1766 |
} else { |
|
1767 |
char **undefNames; |
|
1768 |
char **nm; |
|
1769 |
int i; |
|
1770 |
||
1771 |
if (@global(Verbose) == true) { |
|
1772 |
console_printf ("function %s not executable\n", name); |
|
1773 |
dld_perror("not executable"); |
|
1774 |
||
1775 |
console_printf("undefined:\n"); |
|
1776 |
nm = undefNames = dld_list_undefined_sym(); |
|
1777 |
for (i=dld_undefined_sym_count; i; i--) { |
|
1778 |
console_printf(" %s\n", *nm++); |
|
1779 |
} |
|
1780 |
free(undefNames); |
|
1781 |
} |
|
1782 |
} |
|
1783 |
} else { |
|
1784 |
if (@global(Verbose) == true) { |
|
1785 |
console_printf ("function %s not found\n", name); |
|
1786 |
dld_perror("get_func"); |
|
1787 |
} |
|
1788 |
} |
|
1789 |
} |
|
141 | 1790 |
} |
1791 |
} |
|
1792 |
#endif /* GNU_DL */ |
|
1793 |
||
180 | 1794 |
#ifdef WIN_DL |
1795 |
{ |
|
1796 |
void *h; |
|
1797 |
void *addr; |
|
701 | 1798 |
INT val; |
180 | 1799 |
FARPROC entry; |
1800 |
HMODULE handle; |
|
1801 |
||
1802 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
3001 | 1803 |
# if __POINTER_SIZE__ == 8 |
3721 | 1804 |
val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1); |
3001 | 1805 |
# else |
3721 | 1806 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
3001 | 1807 |
# endif |
3721 | 1808 |
handle = (HMODULE)(val); |
1809 |
if (__isStringLike(aString)) { |
|
1810 |
if (@global(Verbose) == true) |
|
1811 |
console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle); |
|
1812 |
entry = GetProcAddress(handle, (char *) __stringVal(aString)); |
|
1813 |
if (entry != NULL) { |
|
1814 |
addr = (void *)entry; |
|
1815 |
if (@global(Verbose) == true) { |
|
1816 |
console_printf("GetProcAddr %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr); |
|
1817 |
} |
|
3723 | 1818 |
address = __MKUINT( (INT)addr ); |
3721 | 1819 |
} else { |
1820 |
if (@global(Verbose) == true) { |
|
1821 |
console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError()); |
|
1822 |
} |
|
1823 |
} |
|
1824 |
} |
|
180 | 1825 |
} |
1826 |
} |
|
1827 |
#endif |
|
1828 |
||
906 | 1829 |
#ifdef BEOS_DL |
1830 |
{ |
|
1831 |
void *h; |
|
1832 |
void *addr; |
|
1833 |
INT val; |
|
1834 |
void *handle; |
|
1835 |
||
1836 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
3001 | 1837 |
# if __POINTER_SIZE__ == 8 |
3721 | 1838 |
val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1); |
3001 | 1839 |
# else |
3721 | 1840 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
3001 | 1841 |
# endif |
3721 | 1842 |
handle = (void *)(val); |
1843 |
||
1844 |
if (__isStringLike(aString)) { |
|
1845 |
if (@global(Verbose) == true) |
|
3723 | 1846 |
console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle); |
3721 | 1847 |
entry = NULL; |
1848 |
get_image_symbol((image_id) handle, (char *) __stringVal(aString), B_SYMBOL_TYPE_TEXT, &entry); |
|
1849 |
if (entry != NULL) { |
|
1850 |
addr = (void *)entry; |
|
1851 |
if (@global(Verbose) == true) { |
|
1852 |
console_printf("get_image_symbol %s ok; addr = %x\n", __stringVal(aString), addr); |
|
1853 |
} |
|
3723 | 1854 |
address = __MKUINT( (INT)addr ); |
3721 | 1855 |
} else { |
1856 |
if (@global(Verbose) == true) { |
|
1857 |
console_printf("get_image_symbol %s error\n", __stringVal(aString)); |
|
1858 |
} |
|
1859 |
} |
|
1860 |
} |
|
906 | 1861 |
} |
1862 |
} |
|
1863 |
#endif |
|
1864 |
||
141 | 1865 |
#ifdef DL1_6 |
1866 |
{ |
|
1867 |
void *h; |
|
1868 |
void *addr; |
|
701 | 1869 |
INT val; |
141 | 1870 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
1871 |
if (__isStringLike(aString)) { |
3721 | 1872 |
if (__isStringLike(sysHandle1)) { |
1873 |
if (@global(Verbose) == true) |
|
1874 |
console_printf("get sym <%s> handle = %x\n", |
|
1875 |
__stringVal(aString), __stringVal(sysHandle1)); |
|
1876 |
addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString)); |
|
1877 |
if (addr) { |
|
1878 |
if (@global(Verbose) == true) |
|
1879 |
console_printf("addr = %x\n", addr); |
|
3723 | 1880 |
address = __MKUINT( (INT)addr ); |
3721 | 1881 |
} else { |
1882 |
if (@global(Verbose) == true) |
|
1883 |
console_printf("dl_getsymbol %s failed\n", __stringVal(aString)); |
|
1884 |
} |
|
1885 |
} |
|
141 | 1886 |
} |
1887 |
} |
|
1888 |
#endif |
|
1889 |
||
1890 |
#ifdef SYSV4_DL |
|
1891 |
{ |
|
1892 |
void *h; |
|
1893 |
void *addr; |
|
701 | 1894 |
INT val; |
141 | 1895 |
OBJ low = sysHandle1, hi = sysHandle2; |
701 | 1896 |
extern void *dlsym(); |
141 | 1897 |
|
1898 |
if (__bothSmallInteger(low, hi)) { |
|
3001 | 1899 |
# if __POINTER_SIZE__ == 8 |
3721 | 1900 |
val = (__intVal(hi) << 32) + __intVal(low); |
3001 | 1901 |
# else |
3721 | 1902 |
val = (__intVal(hi) << 16) + __intVal(low); |
3001 | 1903 |
# endif |
3721 | 1904 |
h = (void *)(val); |
1905 |
if (__isStringLike(aString)) { |
|
1906 |
if (@global(Verbose) == true) { |
|
1907 |
console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)h); |
|
1908 |
} |
|
1909 |
addr = dlsym(h, (char *) __stringVal(aString)); |
|
1910 |
if (addr) { |
|
1911 |
if (@global(Verbose) == true) { |
|
1912 |
console_printf("dlsym %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr); |
|
1913 |
} |
|
1914 |
address = __MKUINT( (INT)addr ); |
|
1915 |
} else { |
|
1916 |
if (@global(Verbose) == true) { |
|
1917 |
console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
|
1918 |
} |
|
1919 |
} |
|
1920 |
} |
|
141 | 1921 |
} |
1922 |
} |
|
1923 |
#endif |
|
1924 |
||
523 | 1925 |
#ifdef HPUX10_DL |
1926 |
{ |
|
1927 |
void *h; |
|
1928 |
void *addr; |
|
701 | 1929 |
INT val, ret; |
523 | 1930 |
OBJ low = sysHandle1, hi = sysHandle2; |
1931 |
||
1932 |
if (__bothSmallInteger(low, hi)) { |
|
3001 | 1933 |
# if __POINTER_SIZE__ == 8 |
3721 | 1934 |
val = (__intVal(hi) << 32) + __intVal(low); |
3001 | 1935 |
# else |
3721 | 1936 |
val = (_intVal(hi) << 16) + _intVal(low); |
3001 | 1937 |
# endif |
3721 | 1938 |
h = (void *)(val); |
1939 |
if (__isStringLike(aString)) { |
|
1940 |
if (@global(Verbose) == true) { |
|
1941 |
console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
|
1942 |
} |
|
1943 |
ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr); |
|
1944 |
if (ret != 0) { |
|
1945 |
if (@global(Verbose) == true) { |
|
1946 |
console_printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno); |
|
1947 |
} |
|
1948 |
} else { |
|
1949 |
if (@global(Verbose) == true) { |
|
1950 |
console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr); |
|
1951 |
} |
|
1952 |
address = __MKUINT( (INT)addr ); |
|
1953 |
} |
|
1954 |
} |
|
523 | 1955 |
} |
1956 |
} |
|
1957 |
#endif |
|
1958 |
||
1959 |
||
141 | 1960 |
#ifdef AIX_DL |
1961 |
{ |
|
1962 |
void *h; |
|
1963 |
void *addr; |
|
3001 | 1964 |
INT val; |
141 | 1965 |
struct nlist nl[2]; |
1966 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1967 |
char nameBuffer[256]; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1968 |
static struct funcDescriptor { |
3721 | 1969 |
unsigned vaddr; |
1970 |
unsigned long2; |
|
1971 |
unsigned long3; |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1972 |
} descriptor; |
141 | 1973 |
|
1974 |
if (__bothSmallInteger(low, hi) |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
1975 |
&& __isStringLike(aString) && __isStringLike(pathName)) { |
3001 | 1976 |
# if __POINTER_SIZE__ == 8 |
3721 | 1977 |
val = (__intVal(hi) << 32) + __intVal(low); |
3001 | 1978 |
# else |
3721 | 1979 |
val = (__intVal(hi) << 16) + __intVal(low); |
3001 | 1980 |
# endif |
3721 | 1981 |
h = (void *)(val); |
1982 |
||
1983 |
if (@global(Verbose) == true) { |
|
1984 |
console_printf("get sym <%s> handle = %x path= %s\n", |
|
1985 |
__stringVal(aString), h, __stringVal(pathName)); |
|
1986 |
} |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1987 |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1988 |
#define USE_ENTRY |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1989 |
#ifdef USE_ENTRY |
3721 | 1990 |
/* |
1991 |
* only works, if the entry-function is the Init function |
|
1992 |
* (i.e. linked with -e _xxx_Init) |
|
1993 |
*/ |
|
1994 |
if (@global(Verbose) == true) { |
|
1995 |
console_printf("returned handle as addr = %x\n", h); |
|
1996 |
} |
|
3723 | 1997 |
address = __MKUINT( (INT)(h) ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1998 |
#else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1999 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2000 |
# ifdef USE_DESCRIPTOR |
3721 | 2001 |
if (isFunction == true) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2002 |
# else |
3721 | 2003 |
if (0) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2004 |
# endif |
3721 | 2005 |
nameBuffer[0] = '.'; |
2006 |
strcpy(nameBuffer+1, aString); |
|
2007 |
nl[0].n_name = nameBuffer; |
|
2008 |
} else { |
|
2009 |
nl[0].n_name = __stringVal(aString); |
|
2010 |
} |
|
2011 |
nl[1].n_name = ""; |
|
2012 |
||
2013 |
if (nlist(__stringVal(pathName), &nl) == -1) { |
|
2014 |
if (@global(Verbose) == true) { |
|
2015 |
console_printf("nlist error\n"); |
|
2016 |
} |
|
2017 |
} else { |
|
2018 |
addr = (void *)((unsigned)nl[0].n_value + (unsigned)h); |
|
2019 |
||
2020 |
if (isFunction == true) { |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2021 |
# ifdef USE_DESCRIPTOR |
3721 | 2022 |
console_printf("daddr = %x\n", addr); |
2023 |
console_printf("daddr[0] = %x\n", ((long *)addr)[0]); |
|
2024 |
console_printf("daddr[1] = %x\n", ((long *)addr)[1]); |
|
2025 |
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
|
2026 |
# endif |
3721 | 2027 |
} |
2028 |
||
2029 |
if (@global(Verbose) == true) { |
|
2030 |
console_printf("value=%x section=%d type=%x sclass=%d\n", |
|
2031 |
nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass); |
|
2032 |
console_printf("vaddr = %x\n", addr); |
|
2033 |
} |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2034 |
# ifdef DOES_NOT_WORK |
3723 | 2035 |
address = __MKUINT( (INT)addr ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2036 |
# else |
3723 | 2037 |
descriptor.vaddr = (unsigned INT) addr; |
3721 | 2038 |
descriptor.long2 = 0; |
2039 |
descriptor.long3 = 0; |
|
3723 | 2040 |
address = __MKUINT( (INT)(&descriptor) ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2041 |
# endif |
3721 | 2042 |
} |
2998 | 2043 |
#endif /* don't USE_ENTRY */ |
141 | 2044 |
} |
2045 |
} |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
2046 |
#endif /* AIX_DL */ |
141 | 2047 |
|
523 | 2048 |
|
141 | 2049 |
#ifdef SUN_DL |
2050 |
{ |
|
2051 |
void *h; |
|
2052 |
void *addr; |
|
3723 | 2053 |
INT val; |
141 | 2054 |
OBJ low = sysHandle1, hi = sysHandle2; |
2055 |
||
2056 |
if (__bothSmallInteger(low, hi)) { |
|
3721 | 2057 |
val = (_intVal(hi) << 16) + _intVal(low); |
2058 |
h = (void *)(val); |
|
2059 |
if (__isStringLike(aString)) { |
|
2060 |
if (@global(Verbose) == true) { |
|
2061 |
console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
|
2062 |
} |
|
2063 |
addr = dlsym(h, __stringVal(aString)); |
|
2064 |
if (addr) { |
|
2065 |
if (@global(Verbose) == true) { |
|
2066 |
console_printf("addr = %x\n", addr); |
|
2067 |
} |
|
3723 | 2068 |
address = __MKUINT( (INT)addr ); |
3721 | 2069 |
} else { |
2070 |
if (@global(Verbose) == true) { |
|
2071 |
console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
|
2072 |
} |
|
2073 |
} |
|
2074 |
} |
|
141 | 2075 |
} |
2076 |
} |
|
2077 |
#endif |
|
2078 |
||
523 | 2079 |
|
141 | 2080 |
#ifdef NEXT_DL |
2081 |
{ |
|
2082 |
unsigned long addr; |
|
2083 |
long result; |
|
2084 |
NXStream *errOut; |
|
2085 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
2086 |
if (__isStringLike(aString)) { |
3721 | 2087 |
if (@global(Verbose) == true) { |
2088 |
console_printf("get sym <%s>\n", __stringVal(aString)); |
|
2089 |
} |
|
2090 |
errOut = NXOpenFile(2, 2); |
|
2091 |
result = rld_lookup(errOut, |
|
2092 |
(char *) __stringVal(aString), |
|
2093 |
&addr); |
|
2094 |
NXClose(errOut); |
|
2095 |
if (result) { |
|
2096 |
if (@global(Verbose) == true) { |
|
2097 |
console_printf("addr = %x\n", addr); |
|
2098 |
} |
|
3723 | 2099 |
address = __MKUINT( (INT)addr ); |
3721 | 2100 |
} |
141 | 2101 |
} |
2102 |
} |
|
2103 |
#endif |
|
180 | 2104 |
|
141 | 2105 |
%}. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2106 |
^ address |
141 | 2107 |
! |
2108 |
||
2109 |
hasUndefinedSymbolsIn:handle |
|
259 | 2110 |
"return true, if a module has undefined symbols in it. |
2111 |
This is only possible if the system supports loading |
|
2112 |
modules with undefined things in it - most do not" |
|
2113 |
||
141 | 2114 |
^ (self getListOfUndefinedSymbolsFrom:handle) size > 0 |
259 | 2115 |
|
2116 |
"Modified: 25.4.1996 / 09:47:27 / cg" |
|
141 | 2117 |
! |
2118 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2119 |
initFunctionBasenameForFile:pathNameOrFilename |
3006 | 2120 |
"return the expected initFunction's name, given a fileName" |
2121 |
||
2122 |
|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
|
2123 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2124 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2125 |
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
|
2126 |
" |
3006 | 2127 |
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
|
2128 |
suffixLen := 0. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2129 |
self validBinaryExtensions do:[:suffix | |
3721 | 2130 |
suffixLen == 0 ifTrue:[ |
2131 |
(fileName hasSuffix:suffix) ifTrue:[ |
|
2132 |
suffixLen := suffix size + 1 |
|
2133 |
] |
|
2134 |
] |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2135 |
]. |
3006 | 2136 |
name := fileName baseName. |
403 | 2137 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2138 |
suffixLen ~~ 0 ifTrue:[ |
3721 | 2139 |
name := name copyButLast:suffixLen |
3006 | 2140 |
] ifFalse:[ |
3721 | 2141 |
('ObjectFileLoader [warning]: invalid binary object file suffix in: ',fileName name) infoPrintCR. |
2142 |
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
|
2143 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2144 |
^ name. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2145 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2146 |
" |
3006 | 2147 |
ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.so' (unix) |
2148 |
ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.dll' (msdos) |
|
3721 | 2149 |
ObjectFileLoader initFunctionBasenameForFile:'demo.so' |
2150 |
ObjectFileLoader initFunctionBasenameForFile:'demo.o' |
|
2151 |
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
|
2152 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2153 |
|
784
c8742d9efcb6
suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents:
782
diff
changeset
|
2154 |
"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
|
2155 |
"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
|
2156 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2157 |
|
141 | 2158 |
isCPlusPlusObject:handle |
259 | 2159 |
"return true, if the loaded object is a c++ object module. |
2160 |
This is not yet fully implemented/supported." |
|
141 | 2161 |
|
2162 |
(self getSymbol:'__gnu_compiled_cplusplus' function:true from:handle) notNil ifTrue:[^ true]. |
|
2163 |
(self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true]. |
|
2164 |
(self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true]. |
|
2165 |
(self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true]. |
|
6 | 2166 |
^ false |
259 | 2167 |
|
2168 |
"Modified: 25.4.1996 / 09:48:19 / cg" |
|
0 | 2169 |
! |
2170 |
||
141 | 2171 |
isObjectiveCObject:handle |
259 | 2172 |
"return true, if the loaded object is an objective-C object module. |
2173 |
This is not yet implemented/supported" |
|
141 | 2174 |
|
2175 |
^ false |
|
259 | 2176 |
|
2177 |
"Modified: 25.4.1996 / 09:47:59 / cg" |
|
141 | 2178 |
! |
2179 |
||
2180 |
isSmalltalkObject:handle |
|
2181 |
"return true, if the loaded object is a smalltalk object module" |
|
2182 |
||
2183 |
"not yet implemented - stc_compiled_smalltalk is a static symbol, |
|
2184 |
not found in list - need nm-interface, or nlist-walker |
|
2185 |
" |
|
2186 |
^ true. |
|
2187 |
||
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
2188 |
"/ (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
|
2189 |
"/ (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
|
2190 |
"/ ^ false |
141 | 2191 |
! |
2192 |
||
2193 |
listUndefinedSymbolsIn:handle |
|
259 | 2194 |
"list undefined objects in a module on the transcript" |
2195 |
||
141 | 2196 |
|undefinedNames| |
2197 |
||
2198 |
undefinedNames := self getListOfUndefinedSymbolsFrom:handle. |
|
2199 |
undefinedNames size > 0 ifTrue:[ |
|
3721 | 2200 |
Transcript showCR:'ObjectFileLoader [info]: undefined:'. |
2201 |
undefinedNames do:[:aName | |
|
2202 |
Transcript showCR:' ' , aName |
|
2203 |
] |
|
141 | 2204 |
]. |
259 | 2205 |
|
272 | 2206 |
"Modified: 18.5.1996 / 15:43:45 / cg" |
141 | 2207 |
! |
2208 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2209 |
namesMatching:aPattern segment:segmentPattern in:aPathName |
521 | 2210 |
"search for entries which match a pattern. |
2211 |
This is obsolete & rubbish - it will vanish soon" |
|
141 | 2212 |
|
2213 |
|p l s addr segment name entry| |
|
2214 |
||
766 | 2215 |
OperatingSystem isVMSlike ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2216 |
"/ no nm command |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2217 |
^ nil |
766 | 2218 |
]. |
2219 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2220 |
"/ no nm command |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2221 |
^ nil |
609 | 2222 |
]. |
521 | 2223 |
OperatingSystem getOSType = 'aix' ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2224 |
"/ no useful nm info |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2225 |
^ nil |
749 | 2226 |
]. |
141 | 2227 |
|
2228 |
l := OrderedCollection new. |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2229 |
p := PipeStream readingFrom:(self nm:aPathName). |
141 | 2230 |
p isNil ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2231 |
('ObjectFileLoader [info]: cannot read names from ' , aPathName) infoPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2232 |
^ nil |
141 | 2233 |
]. |
2234 |
[p atEnd] whileFalse:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2235 |
entry := p nextLine. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2236 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2237 |
entry errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2238 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2239 |
entry notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2240 |
s := ReadStream on:entry. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2241 |
addr := s nextAlphaNumericWord. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2242 |
s skipSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2243 |
segment := s upToSeparator. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2244 |
s skipSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2245 |
name := s upToEnd withoutSeparators. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2246 |
(addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2247 |
(aPattern match:name) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2248 |
(segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2249 |
l add:name. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2250 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2251 |
('found name: ' , name) errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2252 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2253 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2254 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2255 |
name errorPrint. ' segment mismatch ' errorPrint. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2256 |
segmentPattern errorPrint. ' ' errorPrint. segment errorPrintCR. |
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 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2259 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2260 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2261 |
] |
0 | 2262 |
]. |
141 | 2263 |
p close. |
2264 |
^ l |
|
225 | 2265 |
|
749 | 2266 |
"Modified: / 27.7.1998 / 20:10:57 / cg" |
141 | 2267 |
! |
2268 |
||
2269 |
releaseSymbolTable |
|
2270 |
"this is needed on NeXT to forget loaded names. If this wasnt done, |
|
2271 |
the same class could not be loaded in again due to multiple defines. |
|
2272 |
On other architectures, this is not needed and therefore a noop." |
|
2273 |
||
2274 |
%{ |
|
2275 |
#ifdef NEXT_DL |
|
2276 |
NXStream *errOut; |
|
2277 |
||
2278 |
errOut = NXOpenFile(2, 2); |
|
2279 |
rld_unload_all(errOut, (long)0); |
|
2280 |
rld_load_basefile(errOut, "smalltalk"); |
|
2281 |
NXClose(errOut); |
|
2282 |
#endif |
|
2283 |
%} |
|
303 | 2284 |
! ! |
2285 |
||
369 | 2286 |
!ObjectFileLoader class methodsFor:'image save/restart'! |
303 | 2287 |
|
2288 |
invalidateAndRememberAllObjectFiles |
|
2289 |
"invalidate code refs into all dynamically loaded object files. |
|
2290 |
Required before writing a snapshot image." |
|
2291 |
||
2292 |
LoadedObjects notNil ifTrue:[ |
|
468 | 2293 |
ActuallyLoadedObjects := LoadedObjects. |
2294 |
self rememberAllObjectFiles. |
|
2295 |
ActuallyLoadedObjects keys do:[:aFileName | |
|
2296 |
|handle| |
|
2297 |
||
2298 |
handle := ActuallyLoadedObjects at:aFileName. |
|
2299 |
handle isNil ifTrue:[ |
|
2300 |
self error:'oops, no handle'. |
|
2301 |
] ifFalse:[ |
|
2302 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
2303 |
self invalidateModule:handle |
|
2304 |
] |
|
2305 |
] |
|
2306 |
]. |
|
2307 |
LoadedObjects := nil. |
|
303 | 2308 |
]. |
2309 |
||
2310 |
"Created: 5.10.1995 / 15:48:56 / claus" |
|
2311 |
"Modified: 5.10.1995 / 16:48:51 / claus" |
|
2312 |
"Modified: 12.7.1996 / 17:13:45 / cg" |
|
28 | 2313 |
! |
6 | 2314 |
|
303 | 2315 |
reloadAllRememberedObjectFiles |
2316 |
"reload all object modules as were loaded when the image was saved. |
|
2317 |
Some care has to be taken, if files are missing or otherwise corrupted." |
|
2318 |
||
2882
e7fb69ba1a54
Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents:
2806
diff
changeset
|
2319 |
|oldDummyMethod who newHandle |
e7fb69ba1a54
Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents:
2806
diff
changeset
|
2320 |
savedOldClasses functions saveOldMethodsPerClass anyModulesToInitialize m| |
303 | 2321 |
|
2322 |
PreviouslyLoadedObjects notNil ifTrue:[ |
|
3721 | 2323 |
anyModulesToInitialize := false. |
2324 |
||
2325 |
PreviouslyLoadedObjects do:[:entry | |
|
2326 |
|fileName handle cls sel| |
|
2327 |
||
2328 |
fileName := entry key. |
|
2329 |
handle := entry value. |
|
2330 |
handle moduleID:nil. |
|
2331 |
||
2332 |
handle isClassLibHandle ifTrue:[ |
|
2333 |
"/ ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR. |
|
2334 |
||
2335 |
"/ |
|
2336 |
"/ remember all byteCode methods (as added in the session) |
|
2337 |
"/ |
|
2338 |
savedOldClasses := IdentitySet new. |
|
2339 |
saveOldMethodsPerClass := IdentityDictionary new. |
|
2340 |
||
2341 |
handle classes do:[:eachClass | |
|
2342 |
(eachClass notNil and:[eachClass ~~ 0]) ifTrue:[ |
|
2343 |
saveOldMethodsPerClass at:eachClass put:eachClass methodDictionary copy. |
|
2344 |
savedOldClasses add:eachClass. |
|
2345 |
]. |
|
2346 |
]. |
|
2347 |
"/ |
|
2348 |
"/ load the class binary |
|
2349 |
"/ |
|
2350 |
handle := self loadObjectFile:fileName invokeInitializeMethods:false. |
|
2351 |
handle notNil ifTrue:[ |
|
2352 |
anyModulesToInitialize := true |
|
2353 |
]. |
|
2354 |
||
2355 |
"/ after reloading of the objectFile, |
|
2356 |
"/ some of the changes made in the previous life have to be |
|
2357 |
"/ redone here - otherwise, we will be left with the |
|
2358 |
"/ state contained in the loaded objectModule - instead of |
|
2359 |
"/ what we had when saving the image ... |
|
2360 |
||
2361 |
||
2362 |
"/ |
|
2363 |
"/ re-remove removed methods |
|
2364 |
"/ and re-change method categories |
|
2365 |
"/ |
|
2366 |
savedOldClasses do:[:oldClass | |
|
2367 |
|newClass oldMethods newMethodDict newMthd |
|
2368 |
oldCat oldClassVarString oldClassCategory| |
|
2369 |
||
2370 |
newClass := Smalltalk classNamed:(oldClass name). |
|
2371 |
newClass notNil ifTrue:[ |
|
2372 |
oldClassVarString := oldClass classVariableString. |
|
2373 |
newClass classVariableString ~= oldClassVarString ifTrue:[ |
|
2374 |
"/ there is no need to recreate the variable |
|
2375 |
"/ (its in the smalltalk dictionary) |
|
2376 |
newClass setClassVariableString:oldClassVarString |
|
2377 |
]. |
|
2378 |
newClass isMeta ifFalse:[ |
|
2379 |
newClass setSharedPoolNames:(oldClass sharedPoolNames). |
|
2380 |
oldClassCategory := oldClass category. |
|
2381 |
newClass category ~= oldClassCategory ifTrue:[ |
|
2382 |
newClass setCategory:oldClassCategory |
|
2383 |
] |
|
2384 |
]. |
|
2385 |
oldMethods := saveOldMethodsPerClass at:oldClass. |
|
2386 |
newMethodDict := newClass methodDictionary. |
|
2387 |
oldMethods keysAndValuesDo:[:selector :oldMethod| |
|
2388 |
oldMethod |
|
2389 |
code:nil; |
|
2390 |
mclass:self. |
|
2391 |
oldMethod byteCode isNil ifTrue:[ |
|
2392 |
"a compiled method, load the new code (addresses may have been changed)" |
|
2393 |
newMthd := newMethodDict at:selector ifAbsent:nil. |
|
2394 |
newMthd notNil ifTrue:[ |
|
2395 |
oldMethod code:newMthd code. |
|
2396 |
] ifFalse:[ |
|
2397 |
('ObjectFileLoader [warning]: ' , oldClass name , ' missing method: ', selector, '.') errorPrintCR. |
|
2398 |
]. |
|
2399 |
]. |
|
2400 |
]. |
|
2401 |
newClass setMethodDictionary:oldMethods. |
|
2402 |
]. |
|
2403 |
]. |
|
2404 |
||
2405 |
"/ |
|
2406 |
"/ validate old-classes vs. new classes. |
|
2407 |
"/ and if things look ok, get rid of old stuff |
|
2408 |
"/ and make instances become instances of the new class |
|
2409 |
"/ |
|
638 | 2410 |
"/ ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR. |
2411 |
||
3721 | 2412 |
savedOldClasses do:[:oldClass | |
2413 |
|newClass oldCat oldCVars| |
|
2414 |
||
2415 |
newClass := Smalltalk classNamed:(oldClass name). |
|
2416 |
newClass == oldClass ifTrue:[ |
|
474 | 2417 |
"/ ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR. |
3721 | 2418 |
] ifFalse:[ |
2419 |
(newClass isNil or:[newClass == oldClass]) ifTrue:[ |
|
2420 |
('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR. |
|
2421 |
] ifFalse:[ |
|
303 | 2422 |
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print. |
2423 |
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR. |
|
2424 |
||
3721 | 2425 |
oldClass instSize ~~ newClass instSize ifTrue:[ |
2426 |
('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR. |
|
2427 |
] ifFalse:[ |
|
2428 |
oldClass class instSize ~~ newClass class instSize ifTrue:[ |
|
2429 |
('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR. |
|
2430 |
] ifFalse:[ |
|
638 | 2431 |
"/ ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR. |
3721 | 2432 |
(oldCat := oldClass category) ~= newClass category ifTrue:[ |
2433 |
newClass setCategory:oldCat. |
|
2434 |
]. |
|
2435 |
(oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[ |
|
2436 |
newClass setClassVariableString:oldCVars |
|
2437 |
]. |
|
2438 |
"/ copy over the oldClasses class-instVars |
|
2439 |
(Class instSize + 1) to:(oldClass class instSize) do:[:idx | |
|
2440 |
newClass instVarAt:idx put:(oldClass instVarAt:idx) |
|
2441 |
]. |
|
2442 |
oldClass becomeSameAs:newClass |
|
638 | 2443 |
"/ oldClass become:newClass |
3721 | 2444 |
] |
2445 |
] |
|
2446 |
] |
|
2447 |
] |
|
2448 |
] |
|
2449 |
||
2450 |
] ifFalse:[ |
|
2451 |
handle isMethodHandle ifTrue:[ |
|
2452 |
oldDummyMethod := handle method. |
|
2453 |
(oldDummyMethod isMethod) ifFalse:[ |
|
2454 |
('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR |
|
2455 |
] ifTrue:[ |
|
2456 |
('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR. |
|
2457 |
who := oldDummyMethod who. |
|
2458 |
newHandle := self loadMethodObjectFile:fileName. |
|
2459 |
newHandle isNil ifTrue:[ |
|
2460 |
('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR. |
|
2461 |
handle moduleID:nil. |
|
2462 |
] ifFalse:[ |
|
2463 |
m := newHandle method. |
|
2464 |
oldDummyMethod sourceFilename notNil ifTrue:[ |
|
2465 |
m sourceFilename:(oldDummyMethod sourceFilename) |
|
2466 |
position:(oldDummyMethod sourcePosition). |
|
2467 |
] ifFalse:[ |
|
2468 |
m source:(oldDummyMethod source). |
|
2469 |
]. |
|
2470 |
m setPackage:(oldDummyMethod package). |
|
2471 |
who notNil ifTrue:[ |
|
2472 |
cls := who methodClass. |
|
2473 |
sel := who methodSelector. |
|
2474 |
m == (cls compiledMethodAt:sel) ifFalse:[ |
|
2475 |
'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR. |
|
2476 |
] ifTrue:[ |
|
303 | 2477 |
"/ cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod). |
3721 | 2478 |
] |
2479 |
]. |
|
2480 |
] |
|
2481 |
] |
|
2482 |
] ifFalse:[ |
|
2483 |
handle isFunctionObjectHandle ifTrue:[ |
|
2484 |
functions := handle functions. |
|
2485 |
functions isEmpty ifTrue:[ |
|
2486 |
('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR |
|
2487 |
] ifFalse:[ |
|
2488 |
newHandle := self loadDynamicObject:fileName. |
|
2489 |
newHandle isNil ifTrue:[ |
|
2490 |
('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR. |
|
2491 |
handle moduleID:nil. |
|
2492 |
] ifFalse:[ |
|
2493 |
('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR. |
|
2494 |
functions do:[:eachFunction | |addr| |
|
2495 |
addr := newHandle getFunctionAddress:(eachFunction name) into:eachFunction. |
|
2496 |
addr isNil ifTrue:[ |
|
2497 |
('ObjectFileLoader [info]: function: ''' , eachFunction name , ''' no longer present.') errorPrintCR. |
|
2498 |
eachFunction invalidate. |
|
2499 |
] ifFalse:[ |
|
2500 |
eachFunction setModuleHandle:newHandle. |
|
2501 |
('ObjectFileLoader [info]: rebound function: ''' , eachFunction name , '''.') infoPrintCR. |
|
2502 |
] |
|
2503 |
]. |
|
2504 |
handle becomeSameAs:newHandle. "/ the old handle is now void |
|
2505 |
] |
|
2506 |
] |
|
2507 |
] ifFalse:[ |
|
2508 |
('ObjectFileLoader [info]: ignore invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR. |
|
2509 |
] |
|
2510 |
] |
|
2511 |
] |
|
2512 |
]. |
|
2513 |
PreviouslyLoadedObjects := nil. |
|
2514 |
||
2515 |
"/ now, as we hopefully have all loaded, |
|
2516 |
"/ send #reinitializeAfterLoad to each of them |
|
2517 |
anyModulesToInitialize ifTrue:[ |
|
2518 |
AbortOperationRequest catch:[ |
|
2519 |
self moduleInit:4 forceOld:false interruptable:true. |
|
2520 |
] |
|
2521 |
] |
|
303 | 2522 |
] |
2523 |
||
2472
8ae818e74044
changed: #reloadAllRememberedObjectFiles
Claus Gittinger <cg@exept.de>
parents:
2459
diff
changeset
|
2524 |
"Modified: / 18-01-2011 / 20:42:57 / cg" |
303 | 2525 |
! |
2526 |
||
2527 |
rememberAllObjectFiles |
|
2528 |
"remember all loaded objectModules in the |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2529 |
PreviouslyLoadedObjects classVariable. |
303 | 2530 |
Called when an image is restarted to reload all modules which |
2531 |
were loaded in the previous life" |
|
2532 |
||
2533 |
LoadedObjects notNil ifTrue:[ |
|
2919 | 2534 |
PreviouslyLoadedObjects := OrderedCollection new. |
2535 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
2536 |
handle isObsolete ifTrue:[ |
|
2537 |
('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR |
|
2538 |
] ifFalse:[ |
|
2539 |
PreviouslyLoadedObjects add:(name -> handle) |
|
2540 |
] |
|
2541 |
]. |
|
2542 |
PreviouslyLoadedObjects sort:[:a :b | |
|
2543 |
|h1 h2| |
|
2544 |
||
2545 |
h1 := a value moduleID. |
|
2546 |
h2 := b value moduleID. |
|
2547 |
h1 isNil |
|
2548 |
ifTrue:[true] |
|
2549 |
ifFalse:[ |
|
2550 |
h2 isNil |
|
2551 |
ifTrue:[false] |
|
2552 |
ifFalse:[ |
|
2553 |
h1 < h2 |
|
2554 |
] |
|
2555 |
] |
|
2556 |
]. |
|
303 | 2557 |
] |
2558 |
||
2559 |
"Created: 5.12.1995 / 20:51:07 / cg" |
|
474 | 2560 |
"Modified: 10.1.1997 / 15:06:25 / cg" |
303 | 2561 |
! |
2562 |
||
2563 |
revalidateAllObjectFiles |
|
2564 |
"revalidate code refs into all dynamically loaded object files. |
|
2565 |
Required after writing a snapshot image." |
|
2566 |
||
2567 |
ActuallyLoadedObjects notNil ifTrue:[ |
|
468 | 2568 |
ActuallyLoadedObjects keys do:[:aFileName | |
2569 |
|handle| |
|
2570 |
||
2571 |
handle := ActuallyLoadedObjects at:aFileName. |
|
2572 |
handle isNil ifTrue:[ |
|
2573 |
self error:'oops, no handle'. |
|
2574 |
] ifFalse:[ |
|
2575 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
2576 |
self revalidateModule:handle |
|
2577 |
] |
|
2578 |
] |
|
2579 |
]. |
|
2580 |
LoadedObjects := ActuallyLoadedObjects. |
|
2581 |
ActuallyLoadedObjects := PreviouslyLoadedObjects := nil. |
|
28 | 2582 |
]. |
141 | 2583 |
|
303 | 2584 |
"Created: 5.10.1995 / 15:49:08 / claus" |
2585 |
"Modified: 5.10.1995 / 16:49:18 / claus" |
|
2586 |
"Modified: 12.7.1996 / 17:14:48 / cg" |
|
2587 |
! |
|
2588 |
||
2589 |
unloadAllObjectFiles |
|
2590 |
"unload all dynamically loaded object files from the image. |
|
2591 |
see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:" |
|
2592 |
||
2593 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2594 |
LoadedObjects values copy do:[:eachHandle | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2595 |
eachHandle notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2596 |
self unloadDynamicObject:eachHandle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2597 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
2598 |
] |
303 | 2599 |
]. |
2600 |
||
2601 |
" |
|
2602 |
ObjectFileLoader unloadAllObjectFiles |
|
2603 |
" |
|
2604 |
! |
|
2605 |
||
2606 |
unloadAndRememberAllObjectFiles |
|
2607 |
"remember all modules and unload them" |
|
2608 |
||
2609 |
LoadedObjects notNil ifTrue:[ |
|
468 | 2610 |
self rememberAllObjectFiles. |
2611 |
self unloadAllObjectFiles |
|
303 | 2612 |
] |
2613 |
||
2614 |
"Modified: 25.4.1996 / 09:46:27 / cg" |
|
0 | 2615 |
! ! |
2616 |
||
369 | 2617 |
!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
|
2618 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2619 |
createLoadableObjectFor:baseFileName |
259 | 2620 |
"given an oFile, arrange for it to be loadable. |
2621 |
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
|
2622 |
-shared option into a .so file; |
259 | 2623 |
DLD based loaders (linux a.out) can directly load a .o file; |
2624 |
Other systems may require more ..." |
|
2625 |
||
513 | 2626 |
|osType oFileName soFileName expFileName librunExpFileName |
3050 | 2627 |
needSharedObject ld ldArg expFile ok outfile output libDir libDirBasename |
3054 | 2628 |
errorMessage homeDir fmt| |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2629 |
|
750
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2630 |
osType := OperatingSystem getOSType. |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2631 |
|
2025
00f8564566e8
No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents:
2012
diff
changeset
|
2632 |
osType = #win32 ifTrue:[ |
3721 | 2633 |
self activityNotification:'generating shared object'. |
2634 |
ParserFlags linkArgs isNil ifTrue:[ |
|
2635 |
ld := self linkCommand , ' ' , baseFileName , '.obj'. |
|
2636 |
ld := ld |
|
2637 |
, ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL' |
|
2638 |
, ' /OUT:' , baseFileName , '.dll ' |
|
2025
00f8564566e8
No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents:
2012
diff
changeset
|
2639 |
"/ , ' /DEF:' , baseFileName , '.def'. |
3721 | 2640 |
] ifFalse:[ |
3011 | 2641 |
"/ libDir := ParserFlags libDirectory. |
2642 |
"/ (libDir notNil and:[libDir asFilename exists]) ifFalse:[ |
|
3721 | 2643 |
ParserFlags useBorlandC ifTrue:[ |
2644 |
libDirBasename := 'lib\bc' |
|
2645 |
] ifFalse:[ |
|
2646 |
ParserFlags useVisualC ifTrue:[ |
|
2647 |
libDirBasename := 'lib\vc' |
|
2648 |
] ifFalse:[ |
|
2649 |
(ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[ |
|
2650 |
libDirBasename := 'lib\mingw' |
|
2651 |
] ifFalse:[ |
|
2652 |
libDirBasename := 'lib\vc' |
|
2653 |
] |
|
2654 |
] |
|
2655 |
]. |
|
2656 |
homeDir := Smalltalk packagePath detect:[:p | (p asFilename / 'stx' / libDirBasename) exists] ifNone:nil. |
|
2657 |
homeDir notNil ifTrue:[ |
|
2658 |
libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName |
|
2659 |
]. |
|
2660 |
libDir isNil ifTrue:[ |
|
2661 |
"/ some fallback |
|
2662 |
libDir := #( '..' |
|
2663 |
'..\..' |
|
2664 |
'..\..\..' |
|
2665 |
'..\..\stx' |
|
2666 |
'..\..\..\stx' |
|
2667 |
) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil. |
|
2668 |
||
2669 |
libDir isNil ifTrue:[ |
|
2670 |
LastError := errorMessage := 'could not locate directory where .lib files are (',libDirBasename,')'. |
|
2671 |
ObjectFileLoadError raiseRequestErrorString:errorMessage. |
|
2672 |
^ nil |
|
2673 |
]. |
|
2674 |
]. |
|
3011 | 2675 |
"/ ]. |
2676 |
||
3721 | 2677 |
ParserFlags useBorlandC ifTrue:[ |
2678 |
ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). |
|
2679 |
ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. |
|
2680 |
ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. |
|
2681 |
ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). |
|
2682 |
ld := ld , ' ',libDir,'\cs32i.lib,,'. |
|
2683 |
] ifFalse:[ |
|
2684 |
ParserFlags useVisualC ifTrue:[ |
|
2685 |
"/ todo: fix for correct link libs |
|
2686 |
ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). |
|
2687 |
ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. |
|
2688 |
ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. |
|
2689 |
ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). |
|
2690 |
ld := ld , ' ',libDir,'\cs32i.lib,,'. |
|
2691 |
] ifFalse:[ |
|
2692 |
(ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[ |
|
2693 |
ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). |
|
2694 |
ld := ld , ' -shared -o ',baseFileName,'.dll '. |
|
2695 |
ld := ld , baseFileName,'.obj '. |
|
2696 |
ld := ld , libDir,'\librun.lib '. |
|
2697 |
ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). |
|
2698 |
] ifFalse:[ |
|
2699 |
ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'. |
|
2700 |
LastError := 'for dynamic objects, only borlandC is (currently) supported'. |
|
2701 |
^ nil |
|
2702 |
] |
|
2703 |
] |
|
2704 |
] |
|
2705 |
]. |
|
2706 |
||
2707 |
outfile := (baseFileName , '.out'). |
|
2708 |
(Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ |
|
2709 |
Transcript showCR:('executing: ',ld). |
|
2710 |
]. |
|
2711 |
||
2712 |
ok := OperatingSystem executeCommand:(ld , ' >' , outfile). |
|
2713 |
ok ifFalse:[ |
|
2714 |
output := (baseFileName , '.out') asFilename contentsOfEntireFile. |
|
2715 |
Transcript showCR:output; endEntry. |
|
2716 |
Transcript showCR:'Failed linkCommand:'. |
|
2717 |
Transcript showCR:ld. |
|
2718 |
Transcript showCR:'ParserFlags are:'. |
|
2719 |
Transcript showCR:ParserFlags. |
|
2720 |
]. |
|
2721 |
||
2722 |
#('.obj' '.out' '.tds' '.ilc' '.ild' |
|
2723 |
'.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix| |
|
2724 |
(baseFileName , eachSuffix) asFilename delete. |
|
2725 |
]. |
|
2726 |
||
2727 |
ok ifFalse:[ |
|
2728 |
LastError := output. |
|
2729 |
"/ ObjectFileLoadError raiseRequestErrorString:'link failed'. |
|
2730 |
^ nil |
|
2731 |
]. |
|
2732 |
oFileName := (baseFileName , self sharedLibraryExtension) asFilename name. |
|
2733 |
^ oFileName |
|
750
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2734 |
]. |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2735 |
|
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2736 |
"/ UNIX systems |
00bfa36237fb
changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2737 |
|
2653
e228edb0b67a
changed: #createLoadableObjectFor:
Stefan Vogel <sv@exept.de>
parents:
2651
diff
changeset
|
2738 |
ld := self linkCommand ? 'ld'. |
188 | 2739 |
needSharedObject := false. |
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2740 |
|
3054 | 2741 |
fmt := ObjectFileLoader loadableBinaryObjectFormat. |
2742 |
(fmt == #elf |
|
2743 |
or:[ fmt == #macho ]) ifTrue:[ |
|
3721 | 2744 |
" |
2745 |
link it to a shared object with 'ld -shared' |
|
2746 |
" |
|
2747 |
needSharedObject := true. |
|
2748 |
ld := self linkCommand ? 'cc'. |
|
2749 |
ldArg := self linkSharedArgs. |
|
2750 |
ldArg isNil ifTrue:[ |
|
2751 |
"/ some default |
|
2752 |
ExternalAddress pointerSize == 4 ifTrue:[ |
|
2753 |
ldArg := '-m32 -shared'. |
|
2754 |
] ifFalse:[ |
|
2755 |
ldArg := '--shared'. |
|
2756 |
] |
|
2757 |
] |
|
3052 | 2758 |
]. |
2759 |
||
2935 | 2760 |
osType = #irix ifTrue:[ |
3721 | 2761 |
" |
2762 |
link it to a shared object with 'ld -shared' |
|
2763 |
" |
|
2764 |
needSharedObject := true. |
|
2765 |
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
|
2766 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2767 |
|
2935 | 2768 |
osType = #'sys5_4' ifTrue:[ |
3721 | 2769 |
" |
2770 |
link it to a shared object with 'ld -G' |
|
2771 |
" |
|
2772 |
needSharedObject := true. |
|
2773 |
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
|
2774 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2775 |
|
2935 | 2776 |
osType = #solaris ifTrue:[ |
3721 | 2777 |
" |
2778 |
link it to a shared object with 'ld -G -B dynamic' |
|
2779 |
" |
|
2780 |
needSharedObject := true. |
|
2781 |
ldArg := self linkSharedArgs ? '-G -Bdynamic'. |
|
741 | 2782 |
]. |
2783 |
||
2935 | 2784 |
osType = #hpux ifTrue:[ |
3721 | 2785 |
" |
2786 |
link it to a shared object with 'ld -b -B immediate' |
|
2787 |
" |
|
2788 |
needSharedObject := true. |
|
2789 |
ldArg := self linkSharedArgs ? '-b -B immediate'. |
|
722
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2790 |
]. |
add7cabbd2bb
fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents:
716
diff
changeset
|
2791 |
|
2935 | 2792 |
osType = #aix ifTrue:[ |
3721 | 2793 |
self activityNotification:'create export file'. |
2794 |
||
2795 |
"/ create an exports file. |
|
2796 |
expFileName := './' , baseFileName , '.exp'. |
|
2797 |
[ |
|
2798 |
expFile := expFileName asFilename writeStream. |
|
2799 |
expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension). |
|
2800 |
expFile cr. |
|
2801 |
expFile nextPutAll:'_' , baseFileName , '_Init'. |
|
2802 |
expFile close. |
|
2803 |
] on:FileStream openErrorSignal do:[:ex| "do nothing"]. |
|
2804 |
||
2805 |
self activityNotification:'generating shared object'. |
|
2806 |
||
2807 |
" |
|
2808 |
link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE' |
|
2809 |
" |
|
2810 |
needSharedObject := true. |
|
2811 |
ld := 'cc'. |
|
2812 |
librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'. |
|
2813 |
librunExpFileName isNil ifTrue:[ |
|
2814 |
LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'. |
|
2815 |
^ nil |
|
2816 |
]. |
|
2817 |
||
2818 |
ldArg := '-bI:' , librunExpFileName , |
|
2819 |
' -bE:' , baseFileName , '.exp' , |
|
2820 |
' -bM:SRE -e _' , baseFileName , '_Init'. |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2821 |
]. |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2822 |
|
2648
2d046cf8c90e
changed: #createLoadableObjectFor:
Stefan Vogel <sv@exept.de>
parents:
2627
diff
changeset
|
2823 |
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
|
2824 |
needSharedObject ifTrue:[ |
3721 | 2825 |
self activityNotification:'generating shared object'. |
2826 |
||
2827 |
soFileName := baseFileName , self sharedLibraryExtension. |
|
2828 |
OperatingSystem removeFile:soFileName. |
|
2829 |
ld := ld , ' ' , ldArg , ' ', (ParserFlags linkArgs ? '') , |
|
2830 |
' -o ' , soFileName , ' ' , oFileName , ' ', |
|
2831 |
((ParserFlags searchedLibraries ? #()) asStringCollection asStringWith: $ ). |
|
2832 |
||
2833 |
(Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ |
|
2834 |
Transcript showCR:('linking with: ',ld). |
|
2835 |
]. |
|
2836 |
ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1'). |
|
2837 |
||
2838 |
ok ifFalse:[ |
|
2839 |
output := 'errorOutput' asFilename contentsOfEntireFile. |
|
2840 |
Transcript showCR:'linker error message:'. |
|
2841 |
Transcript showCR:output. |
|
2842 |
Transcript showCR:'linker command:'. |
|
2843 |
Transcript showCR:ld; endEntry. |
|
2844 |
]. |
|
2845 |
||
2846 |
OperatingSystem removeFile:oFileName. |
|
2847 |
expFileName notNil ifTrue:[ |
|
2848 |
OperatingSystem removeFile:expFileName |
|
2849 |
]. |
|
2850 |
^ soFileName. |
|
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2851 |
]. |
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 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2854 |
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
|
2855 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2856 |
^ oFileName |
698 | 2857 |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2858 |
"Modified: / 29-07-2004 / 17:29:44 / stefan" |
2932
d61b51867682
changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
2859 |
"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
|
2860 |
! ! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2861 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2862 |
!ObjectFileLoader class methodsFor:'lowlevel object loading'! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2863 |
|
633 | 2864 |
initializeLoader |
2865 |
"initialize dynamic loader if required" |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
2866 |
|
633 | 2867 |
|stxName stxPathName| |
2868 |
||
2869 |
stxPathName := OperatingSystem pathOfSTXExecutable. |
|
2870 |
%{ |
|
2871 |
#ifdef GNU_DL |
|
2872 |
{ |
|
2873 |
static alreadyInitialized = 0; |
|
2874 |
extern dld_ignore_redefinitions; |
|
2875 |
||
2876 |
if (! alreadyInitialized) { |
|
2877 |
alreadyInitialized = 1; |
|
2878 |
||
2879 |
if (@global(Verbose) == true) { |
|
1975 | 2880 |
console_printf ("dld_init(%s)\n", __stringVal(stxPathName)); |
633 | 2881 |
} |
2882 |
/* |
|
2883 |
* dld requires the running executables name, |
|
2884 |
* to resolve symbols. |
|
2885 |
*/ |
|
2886 |
(void) dld_init (__stringVal(stxPathName)); |
|
2887 |
dld_ignore_redefinitions = 1; |
|
2888 |
} |
|
2889 |
} |
|
2890 |
#endif |
|
2891 |
%}. |
|
2892 |
! |
|
2893 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
2894 |
loadDynamicObject:pathNameOrFilename |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2895 |
"load an object-file (load/map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2896 |
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
|
2897 |
No bindings or automatic initializations are done |
472 | 2898 |
- only a pure (low-level) load is performed. |
2899 |
For class-files or C-objects to be loaded with this method, |
|
2900 |
it is your responsibility to fetch any init-functions and |
|
2901 |
call them as appropriate. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2902 |
This function is not supported on all architectures. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2903 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2904 |
|
2989 | 2905 |
|fn handle buffer pathName tempFile encodedPathName| |
2982 | 2906 |
|
2907 |
fn := pathNameOrFilename asFilename. |
|
2908 |
fn exists ifTrue:[ |
|
2993 | 2909 |
pathName := fn pathName. |
2910 |
self copyLibrariesWhenLoading ifTrue:[ |
|
2911 |
fn copyTo:(tempFile := ParserFlags stcModulePath asFilename construct:fn baseName). |
|
2912 |
pathName := tempFile pathName. |
|
2913 |
]. |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
2914 |
] ifFalse:[ |
2993 | 2915 |
"/ something like "kernel32.dll"; must be along the PATH setting |
2916 |
pathName := pathNameOrFilename asString. |
|
2746
9980d2b9b42c
fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
2917 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2918 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2919 |
Verbose ifTrue:[ |
2993 | 2920 |
('loadDynamic: ',pathNameOrFilename asString,' (',pathName asString,')...') errorPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2921 |
]. |
2989 | 2922 |
encodedPathName := OperatingSystem encodePath:pathName. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2923 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2924 |
"/ already loaded ? |
2989 | 2925 |
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
|
2926 |
handle notNil ifTrue:[ |
2993 | 2927 |
Verbose ifTrue:[ |
2928 |
('... ' , pathName , ' already loaded.') errorPrintCR. |
|
2929 |
]. |
|
2930 |
^ handle |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2931 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2932 |
|
759 | 2933 |
Verbose ifTrue:[ |
2993 | 2934 |
('initializeLoader...') errorPrintCR |
759 | 2935 |
]. |
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
|
2936 |
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
|
2937 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2938 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2939 |
"/ the 1st two entries are system dependent; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2940 |
"/ entry 3 is the pathName |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2941 |
"/ entry 4 is a unique ID |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2942 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2943 |
buffer := Array new:4. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2944 |
buffer at:3 put:pathName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2945 |
buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2946 |
|
759 | 2947 |
Verbose ifTrue:[ |
2993 | 2948 |
('primLoadDynamicObject...') errorPrintCR |
759 | 2949 |
]. |
2950 |
||
2989 | 2951 |
buffer := self primLoadDynamicObject:encodedPathName into:buffer. |
759 | 2952 |
Verbose ifTrue:[ |
2993 | 2953 |
('done') errorPrintCR |
759 | 2954 |
]. |
2955 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2956 |
buffer isNil ifTrue:[ |
2993 | 2957 |
LastError == #notImplemented ifTrue:[ |
2958 |
'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR. |
|
2959 |
] ifFalse:[ |
|
2960 |
LastError == #linkError ifTrue:[ |
|
2961 |
LinkErrorMessage notNil ifTrue:[ |
|
2962 |
('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR. |
|
2963 |
] ifFalse:[ |
|
2964 |
('ObjectFileLoader [warning]: load error') infoPrintCR. |
|
2965 |
]. |
|
2966 |
]. |
|
2967 |
]. |
|
2968 |
('ObjectFileLoader [warning]: failed to load: ' , pathName) infoPrintCR. |
|
2969 |
Transcript showCR:('ObjectFileLoader [warning]: failed to load: ' , pathName). |
|
2970 |
^ nil |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2971 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2972 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2973 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2974 |
remember loaded object for later unloading |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2975 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2976 |
handle := ObjectFileHandle new. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2977 |
handle sysHandle1:(buffer at:1). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2978 |
handle sysHandle2:(buffer at:2). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2979 |
handle pathName:(buffer at:3). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2980 |
handle moduleID:(buffer at:4). |
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 isNil ifTrue:[ |
2993 | 2983 |
LoadedObjects := Dictionary new. |
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 |
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
|
2986 |
"/ Smalltalk flushCachedClasses. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2987 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2988 |
Verbose ifTrue:[ |
2993 | 2989 |
('loadDynamic ok; handle is: ' , handle printString) errorPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2990 |
]. |
2767
12da7f27dcce
changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents:
2746
diff
changeset
|
2991 |
"/ ObjectMemory garbageCollect. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2992 |
|
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 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2995 |
"sys5.4: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2996 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2997 |
handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2998 |
ObjectFileLoader getFunction:'module1' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2999 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3000 |
"next: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3001 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3002 |
handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3003 |
ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3004 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3005 |
"GLD: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3006 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3007 |
handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3008 |
ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle |
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 |
|
2767
12da7f27dcce
changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents:
2746
diff
changeset
|
3011 |
"Modified: / 06-12-2011 / 15:42:16 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3012 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3013 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3014 |
loadModulesFromListOfUndefined:list |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3015 |
"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
|
3016 |
return a list of handles of loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3017 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3018 |
|inits classNames| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3019 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3020 |
inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3021 |
inits notNil ifTrue:[ |
634 | 3022 |
classNames := inits collect:[:symbol | |
3023 |
(symbol startsWith:'___') ifTrue:[ |
|
3024 |
symbol copyFrom:4 to:(symbol size - 5) |
|
3025 |
] ifFalse:[ |
|
3026 |
(symbol startsWith:'__') ifTrue:[ |
|
3027 |
symbol copyFrom:3 to:(symbol size - 5) |
|
3028 |
] ifFalse:[ |
|
3029 |
(symbol startsWith:'_') ifTrue:[ |
|
3030 |
symbol copyFrom:2 to:(symbol size - 5) |
|
3031 |
] ifFalse:[ |
|
3032 |
symbol |
|
3033 |
] |
|
3034 |
] |
|
3035 |
] |
|
3036 |
]. |
|
3037 |
" |
|
3038 |
autoload those classes |
|
3039 |
" |
|
3040 |
classNames do:[:aClassName | |
|
3041 |
|cls| |
|
3042 |
||
3043 |
(cls := Smalltalk classNamed:aClassName) notNil ifTrue:[ |
|
3044 |
'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR. |
|
3045 |
cls autoload |
|
3046 |
] |
|
3047 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3048 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3049 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3050 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3051 |
"Modified: 10.1.1997 / 17:58:23 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3052 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3053 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3054 |
primLoadDynamicObject:pathName into:anInfoBuffer |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3055 |
"load an object-file (map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3056 |
Return an OS-handle (whatever that is) - where some space |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3057 |
(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
|
3058 |
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
|
3059 |
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
|
3060 |
(instead, only pass around handles transparently). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3061 |
This function is not supported on all architectures." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3062 |
|
1760
09a5b2b97f29
WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents:
1759
diff
changeset
|
3063 |
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3064 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3065 |
if (! __isArray(anInfoBuffer) |
646
02b5ea95f888
eliminated some single-underscore macro refs (stringSize, arraySize ...)
Claus Gittinger <cg@exept.de>
parents:
645
diff
changeset
|
3066 |
|| (__arraySize(anInfoBuffer) < 3)) { |
3721 | 3067 |
RETURN(nil); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3068 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3069 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3070 |
#ifdef GNU_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3071 |
{ |
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3072 |
if (__isStringLike(pathName)) { |
3721 | 3073 |
if (dld_link(__stringVal(pathName))) { |
3074 |
if (@global(Verbose) == true) { |
|
3075 |
console_printf ("link file %s failed\n", __stringVal(pathName)); |
|
3076 |
} |
|
3077 |
if (@global(ErrorPrinting) == true) { |
|
3078 |
dld_perror("ObjectFileLoader - DLD error cant link"); |
|
3079 |
} |
|
3080 |
@global(LastError) = @symbol(linkError); |
|
3081 |
@global(LinkErrorMessage) = __MKSTRING("DLD error"); |
|
3082 |
RETURN ( nil ); |
|
3083 |
} |
|
3084 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
|
3085 |
__STORE(anInfoBuffer, pathName); |
|
3086 |
RETURN ( anInfoBuffer ); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3087 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3088 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3089 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3090 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3091 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3092 |
#ifdef WIN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3093 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3094 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3095 |
int err; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3096 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3097 |
if (__isStringLike(pathName)) { |
3721 | 3098 |
if (@global(Verbose) == true) { |
3099 |
console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName)); |
|
3100 |
console_fflush(stderr); |
|
3101 |
} |
|
3102 |
// |
|
3103 |
// LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also |
|
3104 |
// in the directory of the loaded library, if an absolute path to |
|
3105 |
// the library has been provided. |
|
3106 |
// Note: this does not work for redirected library symbols, since they are |
|
3107 |
// resolved ad symbol lookup time and not at library load time |
|
3108 |
// |
|
3109 |
handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
|
3110 |
if (@global(Verbose) == true) { |
|
3722 | 3111 |
console_fprintf(stderr, "ObjectFileLoader [info]: handle: %"_lx_"\n", (INT)handle); |
3721 | 3112 |
console_fflush(stderr); |
3113 |
} |
|
3114 |
if (handle == NULL) { |
|
3115 |
char *msg; |
|
3116 |
||
3117 |
err = GetLastError(); |
|
3118 |
if ((@global(ErrorPrinting) == true) |
|
3119 |
|| (@global(Verbose) == true)) { |
|
3120 |
console_fprintf (stderr, |
|
3121 |
"ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n", |
|
3122 |
__stringVal(pathName), err); |
|
3123 |
} |
|
3124 |
@global(LastError) = @symbol(loadError);; |
|
3125 |
@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err)); |
|
3126 |
switch (err) { |
|
3127 |
case ERROR_BAD_FORMAT: |
|
3128 |
msg = "LoadLibrary error - bad format"; |
|
3129 |
default: |
|
3130 |
msg = "LoadLibrary error"; |
|
3131 |
break; |
|
3132 |
} |
|
3133 |
@global(LinkErrorMessage) = __MKSTRING(msg); |
|
3134 |
RETURN ( nil ); |
|
3135 |
} |
|
3001 | 3136 |
# if __POINTER_SIZE__ == 8 |
3721 | 3137 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFFL ); |
3138 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFFL ); |
|
3001 | 3139 |
# else |
3721 | 3140 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF ); |
3141 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3001 | 3142 |
# endif |
3721 | 3143 |
RETURN ( anInfoBuffer ); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3144 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3145 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3146 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3147 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3148 |
|
906 | 3149 |
#ifdef BEOS_DL |
3150 |
{ |
|
3151 |
void *handle; |
|
3152 |
int err; |
|
3153 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3154 |
if (__isStringLike(pathName)) { |
3721 | 3155 |
if (@global(Verbose) == true) { |
3156 |
console_fprintf(stderr, "ObjectFileLoader [info]: loading : %s...\n", __stringVal(pathName)); |
|
3157 |
console_fflush(stderr); |
|
3158 |
} |
|
3159 |
handle = load_add_on(__stringVal(pathName)); |
|
3160 |
if (@global(Verbose) == true) { |
|
3161 |
console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle); |
|
3162 |
console_fflush(stderr); |
|
3163 |
} |
|
3164 |
if (handle == NULL) { |
|
3165 |
char *msg; |
|
3166 |
||
3167 |
@global(LastError) = @symbol(linkError); |
|
3168 |
@global(LinkErrorMessage) = __MKSTRING("unknown error"); |
|
3169 |
RETURN ( nil ); |
|
3170 |
} |
|
3001 | 3171 |
# if __POINTER_SIZE__ == 8 |
3721 | 3172 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF ); |
3173 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF ); |
|
3001 | 3174 |
# else |
3721 | 3175 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF ); |
3176 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3177 |
RETURN ( anInfoBuffer ); |
|
3001 | 3178 |
# endif |
906 | 3179 |
} |
3180 |
RETURN ( nil ); |
|
3181 |
} |
|
3182 |
#endif |
|
3183 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3184 |
#ifdef DL1_6 |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3185 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3186 |
extern char *__myName__; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3187 |
char *ldname; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3188 |
OBJ tmpName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3189 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3190 |
if (__isStringLike(pathName)) { |
3721 | 3191 |
if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) { |
3192 |
if (@global(Verbose) == true) { |
|
3193 |
console_printf ("link file %s failed\n", __stringVal(pathName)); |
|
3194 |
} |
|
3195 |
@global(LinkErrorMessage) = __MKSTRING("dl_load error"); |
|
3196 |
RETURN ( nil ); |
|
3197 |
} |
|
3198 |
/* |
|
3199 |
* returns the name of the temporary ld-file |
|
3200 |
* use that as handle ... |
|
3201 |
*/ |
|
3202 |
tmpName = __MKSTRING(ldname); |
|
3203 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName; |
|
3204 |
__STORE(anInfoBuffer, tmpName); |
|
3205 |
RETURN ( anInfoBuffer ); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3206 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3207 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3208 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3209 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3210 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3211 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3212 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3213 |
char *objName, *libPath; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3214 |
int *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3215 |
extern errno; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3216 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3217 |
if (__isStringLike(pathName)) { |
3721 | 3218 |
objName = __stringVal(pathName); |
3219 |
||
3220 |
if (__isStringLike(@global(LibPath))) { |
|
3221 |
libPath = __stringVal(@global(LibPath)); |
|
3222 |
} else { |
|
3223 |
libPath = (char *)0; |
|
3224 |
} |
|
3225 |
if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) { |
|
3226 |
if (@global(Verbose) == true) { |
|
3227 |
char *messages[64]; |
|
3228 |
int i; |
|
3229 |
||
3230 |
console_fprintf (stderr, |
|
3231 |
"ObjectFileLoader [info]: load file %s failed errno=%d\n", |
|
3232 |
objName, errno); |
|
3233 |
||
3234 |
switch (errno) { |
|
3235 |
case ENOEXEC: |
|
3236 |
console_fprintf(stderr, " load messages:\n"); |
|
3237 |
loadquery(L_GETMESSAGES, messages, sizeof(messages)); |
|
3238 |
for (i=0; messages[i]; i++) { |
|
3239 |
console_fprintf(stderr, " %s\n", messages[i]); |
|
3240 |
} |
|
3241 |
break; |
|
3242 |
} |
|
3243 |
} else { |
|
3244 |
if (@global(ErrorPrinting) == true) { |
|
3245 |
console_fprintf (stderr, |
|
3246 |
"ObjectFileLoader [warning]: load file %s failed errno=%d\n", |
|
3247 |
objName, errno); |
|
3248 |
} |
|
3249 |
} |
|
3250 |
@global(LinkErrorMessage) = __MKSTRING("load error"); |
|
3251 |
RETURN ( nil ); |
|
3252 |
} |
|
3253 |
if (@global(Verbose) == true) { |
|
3254 |
console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle); |
|
3255 |
} |
|
3001 | 3256 |
|
3257 |
# if __POINTER_SIZE__ == 8 |
|
3721 | 3258 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF ); |
3259 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF ); |
|
3001 | 3260 |
# else |
3721 | 3261 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF ); |
3262 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3001 | 3263 |
# endif |
3721 | 3264 |
RETURN (anInfoBuffer); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3265 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3266 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3267 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3268 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3269 |
|
523 | 3270 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3271 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3272 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3273 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3274 |
char *nm; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3275 |
char *errMsg; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3276 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3277 |
if ((pathName == nil) || __isStringLike(pathName)) { |
3721 | 3278 |
INT lowHandle, hiHandle; |
3279 |
||
3280 |
handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW); |
|
3281 |
||
3282 |
if (! handle) { |
|
3283 |
errMsg = (char *) dlerror(); |
|
3284 |
if (@global(ErrorPrinting) == true) { |
|
3285 |
console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName)); |
|
3286 |
console_fprintf(stderr, " <%s>\n", errMsg); |
|
3287 |
} |
|
3288 |
@global(LastError) = @symbol(linkError); |
|
3289 |
@global(LinkErrorMessage) = __MKSTRING(errMsg); |
|
3290 |
RETURN (nil); |
|
3291 |
} |
|
3292 |
||
3293 |
if (@global(Verbose) == true) { |
|
3294 |
console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle); |
|
3295 |
} |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3296 |
|
1607
074a99bb9a50
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
3297 |
#if __POINTER_SIZE__ == 8 |
3721 | 3298 |
lowHandle = (INT)handle & 0xFFFFFFFFL; |
3299 |
hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL; |
|
701 | 3300 |
#else |
3721 | 3301 |
lowHandle = (INT)handle & 0xFFFF; |
3302 |
hiHandle = ((INT)handle >> 16) & 0xFFFF; |
|
701 | 3303 |
#endif |
3721 | 3304 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle); |
3305 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle); |
|
3306 |
RETURN (anInfoBuffer); |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3307 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3308 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3309 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3310 |
|
523 | 3311 |
|
3312 |
#ifdef HPUX10_DL |
|
3313 |
{ |
|
3314 |
void *handle; |
|
3315 |
char *nm; |
|
3316 |
char *errMsg; |
|
3317 |
||
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3318 |
if (__isStringLike(pathName)) { |
3721 | 3319 |
handle = (void *)shl_load(__stringVal(pathName), |
3320 |
BIND_IMMEDIATE, 0L /* address */); |
|
3321 |
||
3322 |
if (! handle) { |
|
3323 |
if (@global(ErrorPrinting) == true) { |
|
3324 |
console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName)); |
|
3325 |
} |
|
3326 |
@global(LastError) = @symbol(linkError); |
|
3327 |
switch (errno) { |
|
3328 |
case ENOEXEC: |
|
3329 |
errMsg = "not a shared library"; |
|
3330 |
break; |
|
3331 |
case ENOSYM: |
|
3332 |
errMsg = "undefined symbols"; |
|
3333 |
break; |
|
3334 |
case ENOMEM: |
|
3335 |
errMsg = "out of memory"; |
|
3336 |
break; |
|
3337 |
case ENOENT: |
|
3338 |
errMsg = "non existing library"; |
|
3339 |
break; |
|
3340 |
case EACCES: |
|
3341 |
errMsg = "permission denied"; |
|
3342 |
break; |
|
3343 |
default: |
|
3344 |
errMsg = "unspecified error"; |
|
3345 |
break; |
|
3346 |
} |
|
3347 |
@global(LinkErrorMessage) = __MKSTRING(errMsg); |
|
3348 |
RETURN (nil); |
|
3349 |
} |
|
3350 |
||
3351 |
if (@global(Verbose) == true) { |
|
3352 |
console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle); |
|
3353 |
} |
|
3001 | 3354 |
|
3355 |
# if __POINTER_SIZE__ == 8 |
|
3721 | 3356 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF ); |
3357 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF ); |
|
3001 | 3358 |
# else |
3721 | 3359 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF); |
3360 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF ); |
|
3361 |
RETURN (anInfoBuffer); |
|
3001 | 3362 |
# endif |
523 | 3363 |
} |
3364 |
} |
|
3365 |
#endif |
|
3366 |
||
3367 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3368 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3369 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3370 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3371 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3372 |
if ((pathName == nil) || __isStringLike(pathName)) { |
3721 | 3373 |
if (pathName == nil) |
3374 |
handle = dlopen((char *)0, 1); |
|
3375 |
else |
|
3376 |
handle = dlopen(__stringVal(pathName), 1); |
|
3377 |
||
3378 |
if (! handle) { |
|
3379 |
if (@global(ErrorPrinting) == true) { |
|
3380 |
console_fprintf(stderr, "dlopen %s error: <%s>\n", |
|
3381 |
__stringVal(pathName), dlerror()); |
|
3382 |
} |
|
3383 |
@global(LastError) = @symbol(linkError); |
|
3384 |
@global(LinkErrorMessage) = __MKSTRING("dlopen error"); |
|
3385 |
RETURN (nil); |
|
3386 |
} |
|
3387 |
||
3388 |
if (@global(Verbose) == true) { |
|
3389 |
console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle); |
|
3390 |
} |
|
3391 |
||
3392 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
|
3393 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
|
3394 |
RETURN (anInfoBuffer); |
|
470
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 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3397 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3398 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3399 |
#ifdef NEXT_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3400 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3401 |
long result; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3402 |
char *files[2]; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3403 |
NXStream *errOut; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3404 |
|
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3405 |
if (__isStringLike(pathName)) { |
3721 | 3406 |
files[0] = (char *) __stringVal(pathName); |
3407 |
files[1] = (char *) 0; |
|
3408 |
errOut = NXOpenFile(2, 2); |
|
3409 |
result = rld_load(errOut, |
|
3410 |
(struct mach_header **)0, |
|
3411 |
files, |
|
3412 |
(char *)0); |
|
3413 |
NXClose(errOut); |
|
3414 |
if (! result) { |
|
3415 |
@global(LinkErrorMessage) = __MKSTRING("rld_load error"); |
|
3416 |
@global(LastError) = @symbol(linkError); |
|
3417 |
if (@global(ErrorPrinting) == true) { |
|
3418 |
console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName)); |
|
3419 |
} |
|
3420 |
RETURN (nil); |
|
3421 |
} |
|
3422 |
||
3423 |
if (@global(Verbose) == true) |
|
3424 |
console_printf("rld_load %s ok\n", __stringVal(pathName)); |
|
3425 |
||
3426 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
|
3427 |
__STORE(anInfoBuffer, pathName); |
|
3428 |
RETURN ( anInfoBuffer ); |
|
470
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 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3431 |
#endif |
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 |
LastError := #notImplemented. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3434 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3435 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3436 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3437 |
primUnloadDynamicObject:aHandle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3438 |
"unload an object-file (unmap from my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3439 |
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
|
3440 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3441 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3442 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3443 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3444 |
|sysHandle1 sysHandle2| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3445 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3446 |
sysHandle1 := aHandle sysHandle1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3447 |
sysHandle2 := aHandle sysHandle2. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3448 |
|
1760
09a5b2b97f29
WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents:
1759
diff
changeset
|
3449 |
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3450 |
#ifdef GNU_DL |
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
3451 |
if (__isStringLike(sysHandle1)) { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3452 |
if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3453 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3454 |
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
|
3455 |
dld_perror("cant unlink"); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3456 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3457 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3458 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3459 |
RETURN (true); |
470
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 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3462 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3463 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3464 |
#ifdef WIN_DL |
3721 | 3465 |
INT val; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3466 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3467 |
int err; |
771 | 3468 |
jmp_buf exitJmpBuf; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3469 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3470 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
3721 | 3471 |
# if __POINTER_SIZE__ == 8 |
3472 |
val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1); |
|
3473 |
# else |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3474 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
3721 | 3475 |
# endif |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3476 |
handle = (HINSTANCE)(val); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3477 |
|
3722 | 3478 |
if (setjmp(exitJmpBuf)) { |
3479 |
__setAtExitLongJmp(exitJmpBuf); |
|
3480 |
if (@global(Verbose) == true) { |
|
3481 |
console_fprintf (stderr, |
|
3482 |
"ObjectFileLoader [info]: FreeLibrary %s handle: %"_lx_"\n", |
|
3483 |
__stringVal(sysHandle1), (INT)handle); |
|
3484 |
} |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3485 |
if (FreeLibrary(handle) != TRUE) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3486 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3487 |
err = GetLastError(); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3488 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3489 |
console_fprintf (stderr, |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3490 |
"ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n", |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3491 |
__stringVal(sysHandle1), err); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3492 |
} |
2923
10853691e2f2
oops - missing MKINT (may lead to crash in GC after unloading objects)
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
3493 |
@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err)); |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3494 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3495 |
} |
771 | 3496 |
} else { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3497 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3498 |
console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n"); |
771 | 3499 |
} |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3500 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3501 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3502 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3503 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3504 |
|
906 | 3505 |
#ifdef BEOS_DL |
3506 |
int val; |
|
3507 |
void *handle; |
|
3508 |
int ok, err; |
|
3509 |
jmp_buf exitJmpBuf; |
|
3510 |
||
3511 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3512 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3513 |
handle = (HINSTANCE)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3514 |
|
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3515 |
if (setjmp(exitJmpBuf)) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3516 |
__setAtExitLongJmp(exitJmpBuf); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3517 |
ok = unload_add_on((image_id) handle); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3518 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3519 |
if (ok != 0) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3520 |
@global(LastErrorNumber) = __MKSMALLINT(ok); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3521 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3522 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3523 |
} else { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3524 |
__setAtExitLongJmp(0); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3525 |
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
|
3526 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3527 |
RETURN (true); |
906 | 3528 |
} |
3529 |
RETURN (false); |
|
3530 |
#endif |
|
3531 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3532 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3533 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3534 |
void *h; |
701 | 3535 |
INT val; |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3536 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3537 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3538 |
if (__bothSmallInteger(low, hi)) { |
1607
074a99bb9a50
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
3539 |
#if __POINTER_SIZE__ == 8 |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3540 |
val = (__intVal(hi) << 32) + __intVal(low); |
701 | 3541 |
#else |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3542 |
val = (_intVal(hi) << 16) + _intVal(low); |
701 | 3543 |
#endif |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3544 |
h = (void *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3545 |
if (@global(Verbose) == true) |
2998 | 3546 |
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
|
3547 |
if (dlclose(h) != 0) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3548 |
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
|
3549 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3550 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3551 |
RETURN (true); |
470
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 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3554 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3555 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3556 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3557 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3558 |
void *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3559 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3560 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3561 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3562 |
if (__bothSmallInteger(low, hi)) { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3563 |
val = (_intVal(hi) << 16) + _intVal(low); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3564 |
h = (void *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3565 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3566 |
console_printf("close handle = %x\n", h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3567 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3568 |
dlclose(h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3569 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3570 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3571 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3572 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3573 |
|
523 | 3574 |
#ifdef HPUX10_DL |
3575 |
{ |
|
3576 |
int *h; |
|
3577 |
int val; |
|
3578 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
3579 |
||
3580 |
if (__bothSmallInteger(low, hi)) { |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3581 |
val = (_intVal(hi) << 16) + _intVal(low); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3582 |
h = (void *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3583 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3584 |
console_printf("unload handle = %x\n", h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3585 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3586 |
shl_unload(h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3587 |
RETURN (true); |
523 | 3588 |
} |
3589 |
} |
|
3590 |
#endif |
|
3591 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3592 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3593 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3594 |
int *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3595 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3596 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3597 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3598 |
if (__bothSmallInteger(low, hi)) { |
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3599 |
val = (_intVal(hi) << 16) + _intVal(low); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3600 |
h = (int *)(val); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3601 |
if (@global(Verbose) == true) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3602 |
console_printf("unload handle = %x\n", h); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3603 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3604 |
if ( unload(h) != 0) { |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3605 |
console_fprintf(stderr, "unload failed\n"); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3606 |
RETURN (false); |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3607 |
} |
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
3608 |
RETURN (true); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3609 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3610 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3611 |
#endif |
529
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3612 |
|
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3613 |
#ifdef NEXT_DL |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3614 |
{ |
1975 | 3615 |
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
|
3616 |
} |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
3617 |
#endif |
470
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 |
^ false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3620 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3621 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3622 |
unloadDynamicObject:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3623 |
"close an object-file (unmap from my address space) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3624 |
and remove the entry from the remembered object file set. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3625 |
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
|
3626 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3627 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3628 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3629 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3630 |
|key fileName functionName deInitAddr m| |
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 |
Verbose ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3633 |
'unload module name=' errorPrint. handle pathName errorPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3634 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3635 |
|
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3636 |
handle isUnknownHandle ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3637 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3638 |
'module type is not known - assume uninitialized classLib' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3639 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3640 |
self unregisterModule:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3641 |
handle makeClassLibHandle. |
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3642 |
] ifFalse:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3643 |
handle isClassLibHandle ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3644 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3645 |
'a classLib - deinit classes' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3646 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3647 |
self deinitializeClassesFromModule:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3648 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3649 |
'unregister' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3650 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3651 |
self unregisterModule:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3652 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3653 |
handle isMethodHandle ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3654 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3655 |
'a methodHandle - unregister' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3656 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3657 |
self unregisterModule:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3658 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3659 |
handle isFunctionObjectHandle ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3660 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3661 |
'a functionObject - fixup functionRefs' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3662 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3663 |
handle functions do:[:f | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3664 |
f notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3665 |
f invalidate |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3666 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3667 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3668 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3669 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3670 |
"/ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3671 |
"/ call its deInit function (if present) |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3672 |
"/ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3673 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3674 |
'search for deInit function...' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3675 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3676 |
fileName := handle pathName asFilename baseName. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3677 |
functionName := self initFunctionBasenameForFile:fileName. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3678 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3679 |
deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3680 |
deInitAddr notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3681 |
Verbose ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3682 |
'invoke deInit function...' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3683 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3684 |
self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3685 |
saveCallInitFunctionAt:deInitAddr |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3686 |
in:fileName |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3687 |
specialInit:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3688 |
forceOld:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3689 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3690 |
argument:0 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3691 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3692 |
returnsObject:false. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3693 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3694 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3695 |
]. |
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3696 |
]. |
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3697 |
|
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3698 |
Verbose ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3699 |
'cleanup done - now unload...' errorPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3700 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3701 |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3702 |
^ self. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3703 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3704 |
"/ now, really unload |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3705 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3706 |
(self primUnloadDynamicObject:handle) ifFalse:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3707 |
^ self error:'unloadDynamic failed' mayProceed:true |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3708 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3709 |
|
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3710 |
Verbose ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3711 |
'unload done ...' errorPrintCR. |
966
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3712 |
]. |
0da15d671aef
proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
3713 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3714 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3715 |
"/ remove from loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3716 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3717 |
LoadedObjects notNil ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3718 |
key := LoadedObjects keyAtEqualValue:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3719 |
key notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3720 |
LoadedObjects removeKey:key |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3721 |
] |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3722 |
]. |
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 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3725 |
for individual methods, we keep the methodObject, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3726 |
but make it unexecutable. Its still visible in the browser. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3727 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3728 |
handle isMethodHandle ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3729 |
((m := handle method) notNil |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3730 |
and:[m ~~ 0]) ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3731 |
m makeUnloaded. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3732 |
] |
791
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3733 |
]. |
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 isClassLibHandle ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3736 |
Smalltalk flushCachedClasses. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3737 |
Class flushSubclassInfo. |
791
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 isMethodHandle ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3740 |
ObjectMemory flushCaches. |
791
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3741 |
]. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3742 |
|
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3743 |
handle moduleID:nil. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3744 |
handle sysHandle1:nil. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3745 |
handle sysHandle2:nil. |
655e20eb35d7
flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents:
790
diff
changeset
|
3746 |
|
2459 | 3747 |
"Modified: / 15-11-2010 / 13:20:20 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3748 |
! ! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3749 |
|
369 | 3750 |
!ObjectFileLoader class methodsFor:'queries'! |
141 | 3751 |
|
3556 | 3752 |
binaryClassFilenameForPackage:aPackageId inDirectory:packageDirOrNil |
3753 |
|shLibName exeDir binaryClassLibraryFilename| |
|
3754 |
||
3755 |
"Is there a shared library (.dll or .so) ?" |
|
3756 |
shLibName := aPackageId asPackageId libraryName asFilename |
|
3721 | 3757 |
withSuffix:self sharedLibrarySuffix. |
3556 | 3758 |
|
3759 |
exeDir := OperatingSystem pathOfSTXExecutable asFilename directory. |
|
3760 |
binaryClassLibraryFilename := exeDir / shLibName. |
|
3761 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3721 | 3762 |
exeDir baseName = 'bin' ifTrue:[ |
3763 |
binaryClassLibraryFilename := exeDir directory / 'lib' / shLibName. |
|
3764 |
]. |
|
3765 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3766 |
binaryClassLibraryFilename := exeDir directory / 'plugin' / shLibName. |
|
3767 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3556 | 3768 |
"/ binaryClassLibraryFilename := Filename currentDirectory / shLibName. |
3769 |
"/ binaryClassLibraryFilename exists ifFalse:[ |
|
3721 | 3770 |
packageDirOrNil notNil ifTrue:[ |
3771 |
binaryClassLibraryFilename := packageDirOrNil / shLibName. |
|
3772 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3773 |
"/ mhmh - is this a good idea ? (temporary kludge) |
|
3774 |
ExternalAddress pointerSize == 4 ifTrue:[ |
|
3775 |
binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName. |
|
3776 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3777 |
binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName. |
|
3778 |
] |
|
3779 |
] ifFalse:[ |
|
3780 |
binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName. |
|
3781 |
]. |
|
3782 |
] |
|
3783 |
] |
|
3556 | 3784 |
"/ ]. |
3721 | 3785 |
]. |
3786 |
]. |
|
3787 |
packageDirOrNil notNil ifTrue:[ |
|
3788 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3789 |
"/ look in package directory |
|
3790 |
binaryClassLibraryFilename := packageDirOrNil / shLibName. |
|
3791 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3792 |
ExternalAddress pointerSize == 4 ifTrue:[ |
|
3793 |
binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName. |
|
3794 |
binaryClassLibraryFilename exists ifFalse:[ |
|
3795 |
binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName. |
|
3796 |
] |
|
3797 |
] ifFalse:[ |
|
3798 |
binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName. |
|
3799 |
]. |
|
3800 |
]. |
|
3801 |
]. |
|
3802 |
]. |
|
3556 | 3803 |
]. |
3804 |
^ binaryClassLibraryFilename |
|
3805 |
! |
|
3806 |
||
141 | 3807 |
canLoadObjectFiles |
259 | 3808 |
"return true, if dynamic loading is possible. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3809 |
Currently, only ELF based systems, AIX and linux a.out can do this." |
141 | 3810 |
|
3811 |
self primCanLoadObjectFiles ifTrue:[^true]. |
|
3812 |
||
3813 |
"/ can add a return true here, if I ever get manual loading to work |
|
3814 |
"/ for some specific machine |
|
3815 |
^ false |
|
259 | 3816 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3817 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3818 |
ObjectFileLoader canLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3819 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3820 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3821 |
"Modified: 8.1.1997 / 18:13:01 / cg" |
141 | 3822 |
! |
3823 |
||
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3824 |
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
|
3825 |
"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
|
3826 |
|
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3827 |
|pathName| |
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3828 |
|
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 isNil ifTrue:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3830 |
^ 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
|
3831 |
]. |
2407
8fb1437d983a
Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents:
2405
diff
changeset
|
3832 |
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
|
3833 |
^ 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
|
3834 |
! |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
3835 |
|
2393 | 3836 |
handleFromID:id |
3837 |
"given an id, return the pathName, or nil for static modules" |
|
3838 |
||
3839 |
LoadedObjects notNil ifTrue:[ |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3840 |
LoadedObjects keysAndValuesDo:[:name :handle | |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3841 |
handle moduleID == id ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3842 |
^ handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3843 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
3844 |
]. |
2393 | 3845 |
]. |
3846 |
^ nil |
|
3847 |
||
3848 |
" |
|
3849 |
ObjectFileLoader handleFromID:1 |
|
3850 |
" |
|
3851 |
||
3852 |
"Modified: 28.8.1995 / 18:08:28 / claus" |
|
3853 |
! |
|
3854 |
||
141 | 3855 |
loadedObjectFiles |
3856 |
"return a collection containing the names of all |
|
3857 |
dynamically loaded objects." |
|
3858 |
||
3859 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
3860 |
^ LoadedObjects keys copy |
|
3861 |
||
3862 |
" |
|
3863 |
ObjectFileLoader loadedObjectFiles |
|
3864 |
" |
|
3865 |
! |
|
3866 |
||
3867 |
loadedObjectHandles |
|
3868 |
"return a collection of all handles" |
|
3869 |
||
3870 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3871 |
^ LoadedObjects |
141 | 3872 |
|
3873 |
" |
|
3874 |
ObjectFileLoader loadedObjectHandles |
|
3875 |
" |
|
3876 |
||
3877 |
"Created: 17.9.1995 / 14:28:55 / claus" |
|
3878 |
"Modified: 17.9.1995 / 16:13:48 / claus" |
|
3879 |
! |
|
3880 |
||
3881 |
loadedObjectHandlesDo:aBlock |
|
3882 |
"enumerate all handles" |
|
3883 |
||
3884 |
LoadedObjects notNil ifTrue:[ |
|
3885 |
LoadedObjects copy do:aBlock. |
|
3886 |
]. |
|
3887 |
||
3888 |
" |
|
3889 |
ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL] |
|
3890 |
" |
|
3891 |
||
3892 |
"Created: 14.9.1995 / 22:03:13 / claus" |
|
3893 |
"Modified: 14.9.1995 / 22:32:48 / claus" |
|
3894 |
! |
|
3895 |
||
1602 | 3896 |
moduleNamed:aNameString |
3897 |
"return the module named aNameString" |
|
3898 |
||
3899 |
|moduleDescriptor| |
|
3900 |
||
1906 | 3901 |
moduleDescriptor := |
3902 |
ObjectMemory binaryModuleInfo |
|
3903 |
detect:[:eachModuleDescriptor | eachModuleDescriptor libraryName = aNameString] |
|
3904 |
ifNone:[^ nil]. |
|
1742 | 3905 |
|
3906 |
^ LoadedObjects at:(moduleDescriptor pathName) ifAbsent:[]. |
|
1602 | 3907 |
|
3908 |
" |
|
3909 |
ObjectFileLoader moduleNamed:'ctypes' |
|
3910 |
" |
|
3911 |
! |
|
3912 |
||
141 | 3913 |
pathNameFromID:id |
3914 |
"given an id, return the pathName, or nil for static modules" |
|
3915 |
||
3916 |
LoadedObjects notNil ifTrue:[ |
|
3917 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
3918 |
handle moduleID == id ifTrue:[ |
|
3919 |
^ handle pathName |
|
3920 |
] |
|
3921 |
]. |
|
3922 |
]. |
|
3923 |
^ nil |
|
3924 |
||
3925 |
" |
|
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3926 |
ObjectFileLoader pathNameFromID:1 |
141 | 3927 |
" |
3928 |
||
3929 |
"Modified: 28.8.1995 / 18:08:28 / claus" |
|
3930 |
! |
|
3931 |
||
3932 |
primCanLoadObjectFiles |
|
3933 |
"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
|
3934 |
|
141 | 3935 |
%{ /* NOCONTEXT */ |
3936 |
#ifdef HAS_DL |
|
3937 |
# if !defined(OS_DEFINE) || defined(unknownOS) |
|
1975 | 3938 |
console_fprintf(stderr, "*** OS_DEFINE not correct\n"); |
141 | 3939 |
# else |
3940 |
# if !defined(CPU_DEFINE) || defined(unknownCPU) |
|
1975 | 3941 |
console_fprintf(stderr, "*** CPU_DEFINE not correct\n"); |
141 | 3942 |
# else |
3943 |
RETURN (true); |
|
3944 |
# endif |
|
3945 |
# endif |
|
3946 |
#endif |
|
3947 |
%}. |
|
3948 |
^ false |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3949 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3950 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3951 |
ObjectFileLoader primCanLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
3952 |
" |
20 | 3953 |
! ! |
3954 |
||
3556 | 3955 |
!ObjectFileLoader class methodsFor:'signal access'! |
3956 |
||
3957 |
objectFileLoadErrorNotification |
|
3958 |
^ ObjectFileLoadErrorNotification |
|
3959 |
! ! |
|
3960 |
||
369 | 3961 |
!ObjectFileLoader class methodsFor:'st object file handling'! |
303 | 3962 |
|
3963 |
callInitFunctionAt:address specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject |
|
3964 |
"call a function at address - a very dangerous operation. |
|
3965 |
This is needed to call the classes init-function after loading in a |
|
3966 |
class-object file or to call the CTORS when c++ modules are loaded. |
|
3967 |
ForceOld (if true) will have the memory manager |
|
3968 |
allocate things in oldSpace instead of newSpace. |
|
3969 |
If special is true, this is a smalltalk moduleInit (i.e. pass the vm-entries table); |
|
3970 |
otherwise, its called without arguments. |
|
3971 |
If its a smalltalk-moduleInit, it may be either for a classPackage (which should |
|
3972 |
install all of its classes) or for a single incrementally compiled methdod |
|
3973 |
(it should then NOT install it, but return the method object instead). |
|
3974 |
||
3975 |
DANGER: Internal & highly specialized. Dont use in your programs. |
|
1906 | 3976 |
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
|
3977 |
|
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3978 |
|moduleID retVal oldSpaceReserve| |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3979 |
|
303 | 3980 |
handle notNil ifTrue:[ |
1906 | 3981 |
moduleID := handle moduleID |
303 | 3982 |
]. |
1018
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3983 |
"/ |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3984 |
"/ 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
|
3985 |
"/ 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
|
3986 |
"/ 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
|
3987 |
"/ 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
|
3988 |
"/ 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
|
3989 |
"/ (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
|
3990 |
"/ |
011f0c9fa19d
more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents:
1014
diff
changeset
|
3991 |
oldSpaceReserve := OldSpaceReserve ? (1024*1024). |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3992 |
|
1033
f5bad5027056
More Stack when calling init function.
Stefan Vogel <sv@exept.de>
parents:
1024
diff
changeset
|
3993 |
%{ /* CALLSSTACK: 128000 */ |
303 | 3994 |
OBJ (*addr)(); |
3995 |
int prevSpace, force; |
|
591 | 3996 |
INT arg = 0, ret = 0; |
303 | 3997 |
int wasBlocked = 1; |
3998 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3999 |
if (__isInteger(address)) { |
1906 | 4000 |
if (_isSmallInteger(argument)) { |
4001 |
arg = __intVal(argument); |
|
4002 |
||
4003 |
addr = (OBJFUNC)(__longIntVal(address)); |
|
4004 |
||
4005 |
/* |
|
4006 |
* allow function to be interrupted |
|
4007 |
*/ |
|
4008 |
if (interruptable != true) { |
|
4009 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
|
4010 |
} |
|
4011 |
||
4012 |
force = (forceOld == true); |
|
4013 |
if (force) { |
|
4014 |
int reserve = __intVal(oldSpaceReserve); |
|
4015 |
if ((__oldSpaceSize() - __oldSpaceUsed()) < reserve) { |
|
4016 |
__moreOldSpace(__thisContext, reserve); |
|
4017 |
} |
|
4018 |
prevSpace = __allocForceSpace(OLDSPACE); |
|
4019 |
} |
|
4020 |
||
4021 |
if (@global(Verbose) == true) { |
|
2339
e08285b13360
Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents:
2334
diff
changeset
|
4022 |
console_printf("calling initfunc %lx(%lx) ...\n", (long)addr, (long)arg); |
1906 | 4023 |
} |
4024 |
||
4025 |
if (special == true) { |
|
4026 |
if (__isSmallInteger(moduleID)) { |
|
4027 |
__SET_MODULE_ID(__intVal(moduleID)); |
|
4028 |
} |
|
4029 |
retVal = (*addr)(arg, __pRT__); |
|
4030 |
__SET_MODULE_ID(0); |
|
4031 |
if (returnsObject != true) { |
|
4032 |
retVal = nil; |
|
4033 |
} |
|
4034 |
} else { |
|
4035 |
if (returnsObject == true) { |
|
4036 |
retVal = (*addr)(arg); |
|
4037 |
} else { |
|
4038 |
ret = (INT) ((*addr)(arg)); |
|
4039 |
retVal = __mkSmallInteger(ret); |
|
4040 |
} |
|
4041 |
} |
|
4042 |
||
4043 |
if (force) { |
|
4044 |
__allocForceSpace(prevSpace); |
|
4045 |
} |
|
4046 |
||
4047 |
if (! wasBlocked) { |
|
4048 |
__UNBLOCKINTERRUPTS(); |
|
4049 |
} |
|
4050 |
RETURN (retVal); |
|
4051 |
} |
|
303 | 4052 |
} |
4053 |
%}. |
|
4054 |
self primitiveFailed |
|
4055 |
! |
|
4056 |
||
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
|
4057 |
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
|
4058 |
"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
|
4059 |
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
|
4060 |
(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
|
4061 |
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
|
4062 |
|
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 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
|
4064 |
|
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 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
|
4066 |
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
|
4067 |
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
|
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 |
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
|
4070 |
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
|
4071 |
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
|
4072 |
] 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
|
4073 |
'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
|
4074 |
^ 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
|
4075 |
] |
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 |
]. |
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 |
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
|
4079 |
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
|
4080 |
('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
|
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 |
"/ 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
|
4083 |
^ 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
|
4084 |
]. |
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 |
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
|
4087 |
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
|
4088 |
('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
|
4089 |
]. |
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 |
|
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 |
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
|
4092 |
(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
|
4093 |
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
|
4094 |
('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
|
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 |
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
|
4097 |
^ 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
|
4098 |
]. |
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 |
|
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 |
('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
|
4102 |
^ 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
|
4103 |
|
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4104 |
"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
|
4105 |
! |
6d075e94c774
Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents:
1975
diff
changeset
|
4106 |
|
303 | 4107 |
deinitializeClassesFromModule:handle |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
4108 |
"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
|
4109 |
to all classes of a module." |
303 | 4110 |
|
4111 |
|classes| |
|
4112 |
||
4113 |
classes := handle classes. |
|
4114 |
classes notNil ifTrue:[ |
|
634 | 4115 |
classes do:[:aClass | |
4116 |
aClass notNil ifTrue:[ |
|
4117 |
aClass isMeta ifFalse:[ |
|
4118 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4119 |
'send #deinitialize to:' errorPrint. aClass name errorPrintCR. |
634 | 4120 |
]. |
4121 |
aClass deinitialize. |
|
4122 |
aClass update:#aboutToUnload with:nil from:self |
|
4123 |
] |
|
4124 |
] |
|
4125 |
] |
|
303 | 4126 |
] |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
4127 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4128 |
"Modified: 10.1.1997 / 17:56:50 / cg" |
303 | 4129 |
! |
4130 |
||
4131 |
invalidateModule:handle |
|
4132 |
"invalidate all of the classes code objects ..." |
|
4133 |
||
4134 |
|id| |
|
4135 |
||
4136 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4137 |
'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
|
4138 |
' id=' errorPrint. handle moduleID errorPrintCR. |
303 | 4139 |
]. |
4140 |
||
4141 |
id := handle moduleID. |
|
4142 |
%{ |
|
4143 |
__INVALIDATE_BY_ID(__intVal(id)); |
|
4144 |
%} |
|
4145 |
! |
|
4146 |
||
4147 |
loadStatusFor:className |
|
2456 | 4148 |
"ask VM if class-hierarchy has been completely loaded, and return the status. |
2705 | 4149 |
If className ist non-nil, check the load status of this class only, |
2456 | 4150 |
otherwise check the status of all known classes. |
4151 |
||
4152 |
Answer an array with the status symbol and optionally the name of |
|
4153 |
a class with a bad status." |
|
303 | 4154 |
|
4155 |
|checker checkSymbol statusCode status badClassName| |
|
4156 |
||
4157 |
checker := self. |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4158 |
checkSymbol := #classPresentCheck:. |
303 | 4159 |
|
4160 |
%{ /* NOREGISTER */ |
|
3737 | 4161 |
char *badName = NULL; |
2705 | 4162 |
char interestingClassName[512], *classNameP = 0; |
303 | 4163 |
|
1759
a49b7066594c
UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents:
1745
diff
changeset
|
4164 |
if (__isStringLike(className)) { |
3737 | 4165 |
strncpy(interestingClassName, __stringVal(className), sizeof(interestingClassName)); |
4166 |
classNameP = interestingClassName; |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4167 |
} |
2705 | 4168 |
statusCode = __MKSMALLINT(__check_registration__(classNameP, |
3737 | 4169 |
&checker, &checkSymbol, |
4170 |
&badName)); |
|
303 | 4171 |
if (badName) { |
3737 | 4172 |
badClassName = __MKSTRING(badName); |
303 | 4173 |
} |
4174 |
%}. |
|
4175 |
statusCode == 0 ifTrue:[ |
|
3737 | 4176 |
status := #ok |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4177 |
] ifFalse:[ statusCode == -1 ifTrue:[ |
3737 | 4178 |
status := #missingClass |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4179 |
] ifFalse:[ statusCode == -2 ifTrue:[ |
3737 | 4180 |
status := #versionMismatch |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4181 |
] ifFalse:[ statusCode == -3 ifTrue:[ |
3737 | 4182 |
status := #unregisteredSuperclass |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4183 |
] ifFalse:[ statusCode == -4 ifTrue:[ |
3737 | 4184 |
status := #tryAgain |
303 | 4185 |
] ifFalse:[ |
3737 | 4186 |
status := #loadFailed |
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4187 |
] ] ] ] ]. |
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4188 |
|
303 | 4189 |
^ Array with:status with:badClassName. |
4190 |
! |
|
4191 |
||
4192 |
moduleInit:phase forceOld:forceOld interruptable:interruptable |
|
4193 |
"initialization phases after registration. |
|
1759
a49b7066594c
UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents:
1745
diff
changeset
|
4194 |
DANGER: Pure magic; internal only -> don't use in your programs." |
303 | 4195 |
|
1959 | 4196 |
self primModuleInit:phase forceOld:forceOld interruptable:interruptable |
4197 |
||
4198 |
"Modified: / 06-12-2006 / 13:09:43 / cg" |
|
303 | 4199 |
! |
4200 |
||
4201 |
performModuleInitAt:initAddr for:className identifyAs:handle |
|
4202 |
"Initialize a loaded smalltalk module." |
|
4203 |
||
916
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4204 |
^ self |
1010 | 4205 |
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
|
4206 |
|
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4207 |
! |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4208 |
|
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4209 |
performModuleInitAt:initAddr invokeInitializeMethods:invokeInitializeMethods for:className identifyAs:handle |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4210 |
"Initialize a loaded smalltalk module." |
a04d8cad48d8
when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents:
906
diff
changeset
|
4211 |
|
972
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4212 |
|status badClassName infoCollection info classNames classes |
3ae444a1a816
better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents:
966
diff
changeset
|
4213 |
stillTrying| |
303 | 4214 |
|
4215 |
" |
|
4216 |
need 4 passes to init: 0: let module register itself & create its pools/globals |
|
3721 | 4217 |
0b check if modules superclasses are all loaded |
4218 |
1: let it get var-refs to other pools/globals |
|
4219 |
2: let it install install class, methods and literals |
|
4220 |
3: let it send #initialize to its class object |
|
303 | 4221 |
" |
4222 |
||
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4223 |
Verbose ifTrue:[ |
3721 | 4224 |
'start' errorPrintCR |
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4225 |
]. |
3006 | 4226 |
|
2456 | 4227 |
[ |
3721 | 4228 |
stillTrying := false. |
4229 |
||
4230 |
"/ |
|
4231 |
"/ let it register itself |
|
4232 |
"/ and define its globals |
|
4233 |
"/ |
|
4234 |
Verbose ifTrue:[ |
|
4235 |
'phase 0 (module registration) ...' errorPrintCR |
|
4236 |
]. |
|
4237 |
self |
|
4238 |
saveCallInitFunctionAt:initAddr |
|
4239 |
in:nil |
|
4240 |
specialInit:true |
|
4241 |
forceOld:true |
|
4242 |
interruptable:false |
|
4243 |
argument:0 |
|
4244 |
identifyAs:handle |
|
4245 |
returnsObject:false. |
|
4246 |
||
4247 |
"/ |
|
4248 |
"/ check if superclasses are present |
|
4249 |
"/ |
|
4250 |
info := self loadStatusFor:className. |
|
4251 |
status := info at:1. |
|
4252 |
badClassName := info at:2. |
|
4253 |
||
4254 |
Verbose ifTrue:[ |
|
4255 |
'... info is ' errorPrint. info errorPrintCR |
|
4256 |
]. |
|
4257 |
||
4258 |
(status ~~ #ok) ifTrue:[ |
|
4259 |
(status == #missingClass) ifTrue:[ |
|
4260 |
('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR. |
|
4261 |
^ info |
|
4262 |
]. |
|
4263 |
(status == #versionMismatch) ifTrue:[ |
|
4264 |
('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR. |
|
4265 |
^ info |
|
4266 |
]. |
|
4267 |
(status == #unregisteredSuperclass) ifTrue:[ |
|
4268 |
('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR. |
|
4269 |
^ info |
|
4270 |
]. |
|
4271 |
(status == #tryAgain) ifTrue:[ |
|
4272 |
"/ tryAgain: |
|
4273 |
"/ must retry after initialization, to initialize |
|
4274 |
"/ sub-subclasses of autoloaded classes |
|
4275 |
"/ (sigh - class objects are created in phase 3, |
|
4276 |
"/ so we must first complete the initialization cycle, |
|
4277 |
"/ then do all again, for remaining modules) |
|
4278 |
stillTrying := true. |
|
4279 |
'ObjectFileLoader [info]: retry registration of: ' infoPrint. |
|
4280 |
(className ? 'a classLib') infoPrint. ' after init' infoPrintCR. |
|
4281 |
] ifFalse:[ |
|
4282 |
'ObjectFileLoader [error]: load failed: ' infoPrint. className infoPrintCR. |
|
4283 |
^ Array with:#loadFailed with:nil |
|
4284 |
]. |
|
4285 |
]. |
|
4286 |
||
4287 |
Smalltalk flushCachedClasses. |
|
4288 |
Class flushSubclassInfo. |
|
4289 |
"/ |
|
4290 |
"/ remaining initialization |
|
4291 |
"/ |
|
4292 |
||
4293 |
"/ module exports: declare module-globals & symbols ... |
|
4294 |
Verbose ifTrue:[ |
|
4295 |
'phase 1 (resolve globals) ...' errorPrintCR |
|
4296 |
]. |
|
4297 |
self moduleInit:1 forceOld:true interruptable:false. |
|
4298 |
||
4299 |
"/ module-imports: resolve globals ... |
|
4300 |
"/ create methods & install ... |
|
4301 |
Verbose ifTrue:[ |
|
4302 |
'phase 2 (create objects) ...' errorPrintCR |
|
4303 |
]. |
|
4304 |
self moduleInit:2 forceOld:true interruptable:false. |
|
4305 |
||
4306 |
Verbose ifTrue:[ |
|
4307 |
'stillTrying is ' errorPrint. stillTrying errorPrintCR |
|
4308 |
]. |
|
2456 | 4309 |
] doWhile:[stillTrying]. |
4310 |
||
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4311 |
Verbose ifTrue:[ |
3721 | 4312 |
'end' errorPrintCR |
303 | 4313 |
]. |
4314 |
||
4315 |
ObjectMemory flushCaches. |
|
4316 |
||
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4317 |
invokeInitializeMethods ifTrue:[ |
3721 | 4318 |
Verbose ifTrue:[ |
4319 |
'phase 3 (send #initialize) ...' errorPrintCR |
|
4320 |
]. |
|
4321 |
"/ initialize ... |
|
4322 |
self moduleInit:3 forceOld:false interruptable:true. |
|
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4323 |
]. |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4324 |
|
303 | 4325 |
"/ ask objectMemory for the classes we have just loaded |
4326 |
"/ and register them in the handle |
|
4327 |
||
4328 |
infoCollection := ObjectMemory binaryModuleInfo. |
|
4329 |
info := infoCollection at:handle moduleID ifAbsent:nil. |
|
4330 |
info isNil ifTrue:[ |
|
3721 | 4331 |
"/ mhmh registration failed - |
4332 |
'ObjectFileLoader [error]: registration failed: ' infoPrint. |
|
4333 |
(className ? 'some classLib') infoPrintCR. |
|
4334 |
^ Array with:#registrationFailed with:nil |
|
303 | 4335 |
]. |
4336 |
||
405
92cb91b82cf7
changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4337 |
classNames := info classNames. |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
4338 |
classNames notEmptyOrNil ifTrue:[ |
3721 | 4339 |
classes := OrderedCollection new:classNames size. |
4340 |
classNames do:[:eachClassName | |class| |
|
4341 |
class := Smalltalk classNamed:eachClassName. |
|
4342 |
class notNil ifTrue:[ |
|
4343 |
classes add:class. |
|
4344 |
]. |
|
4345 |
]. |
|
303 | 4346 |
]. |
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
4347 |
classes notEmptyOrNil ifTrue:[ |
3721 | 4348 |
classes := classes asArray. |
4349 |
classes := classes , (classes collect:[:aClass | aClass class]). |
|
303 | 4350 |
]. |
4351 |
handle classes:classes. |
|
4352 |
||
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4353 |
"/ invokeinitializemethods iftrue:[ |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4354 |
"/ verbose iftrue:[ |
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4355 |
"/ 'phase 3 (send #initialize) ...' errorPrintCR |
1958
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4356 |
"/ ]. |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4357 |
"/ "/ INITIALIZE ... |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4358 |
"/ self moduleinit:3 forceold:false interruptable:true. |
62e95d1c9501
initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents:
1942
diff
changeset
|
4359 |
"/ ]. |
881
ed4efb1b161e
perform moduleInit3 AFTER registering the module.
Claus Gittinger <cg@exept.de>
parents:
880
diff
changeset
|
4360 |
|
303 | 4361 |
^ Array with:#ok with:nil |
4362 |
||
1540
72bdddf92706
Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
4363 |
"Modified: / 29-07-2004 / 17:12:28 / stefan" |
2459 | 4364 |
"Modified: / 15-11-2010 / 13:20:11 / cg" |
303 | 4365 |
! |
4366 |
||
1959 | 4367 |
primModuleInit:phase forceOld:forceOld interruptable:interruptable |
4368 |
"initialization phases after registration. |
|
4369 |
DANGER: Pure magic; internal only -> don't use in your programs." |
|
4370 |
||
4371 |
%{ |
|
4372 |
int prevSpace, force; |
|
4373 |
int wasBlocked = 1; |
|
4374 |
||
4375 |
if (__isSmallInteger(phase)) { |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4376 |
if (interruptable != true) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4377 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4378 |
} |
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 |
force = (forceOld == true); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4381 |
if (force) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4382 |
prevSpace = __allocForceSpace(OLDSPACE); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4383 |
} |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4384 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4385 |
__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
|
4386 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4387 |
if (force) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4388 |
__allocForceSpace(prevSpace); |
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 |
|
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4391 |
if (! wasBlocked) { |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4392 |
__UNBLOCKINTERRUPTS(); |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4393 |
} |
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4394 |
RETURN (self); |
1959 | 4395 |
} |
4396 |
%}. |
|
4397 |
self primitiveFailed |
|
4398 |
||
4399 |
"Created: / 06-12-2006 / 13:09:24 / cg" |
|
4400 |
! |
|
4401 |
||
303 | 4402 |
revalidateModule:handle |
4403 |
"revalidate all of the classes code objects ..." |
|
4404 |
||
4405 |
|id| |
|
4406 |
||
4407 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4408 |
'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
|
4409 |
' id=' errorPrint. handle moduleID errorPrintCR. |
303 | 4410 |
]. |
4411 |
||
4412 |
id := handle moduleID. |
|
4413 |
%{ |
|
4414 |
__REVALIDATE_BY_ID(__intVal(id)); |
|
4415 |
%} |
|
4416 |
! |
|
4417 |
||
2459 | 4418 |
saveCallInitFunctionAt:address in:aFilenameOrNil specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject |
4419 |
OSSignalInterrupt handle:[:ex | |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4420 |
aFilenameOrNil notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4421 |
('ObjectFileLoader [warning]: SignalInterrupt from initFunction in %1' bindWith:(aFilenameOrNil asFilename pathName)) errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4422 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4423 |
'ObjectFileLoader [warning]: SignalInterrupt from initFunction' errorPrintCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4424 |
]. |
2459 | 4425 |
] do:[ |
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4426 |
^ self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4427 |
callInitFunctionAt:address |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4428 |
specialInit:special |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4429 |
forceOld:forceOld |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4430 |
interruptable:interruptable |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4431 |
argument:argument |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4432 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4433 |
returnsObject:returnsObject |
2459 | 4434 |
]. |
4435 |
||
4436 |
"Created: / 15-11-2010 / 13:21:59 / cg" |
|
4437 |
! |
|
4438 |
||
303 | 4439 |
unregisterModule:handle |
4440 |
"unregister classes in the VM. |
|
4441 |
This invalidates all of the classes code objects ..." |
|
4442 |
||
4443 |
|id| |
|
4444 |
||
4445 |
Verbose ifTrue:[ |
|
1964
f037d5288371
registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents:
1961
diff
changeset
|
4446 |
'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
|
4447 |
' id=' errorPrint. handle moduleID errorPrintCR. |
303 | 4448 |
]. |
4449 |
||
4450 |
id := handle moduleID. |
|
4451 |
%{ |
|
4452 |
__UNREGISTER_BY_ID(__intVal(id)); |
|
4453 |
%} |
|
4454 |
! ! |
|
4455 |
||
2408 | 4456 |
!ObjectFileLoader class methodsFor:'under test - loading dlls'! |
4457 |
||
4458 |
loadObjectFiles:aSeqOfFiles |
|
4459 |
"load a sequence of DLLs... first load all DLLs with #moduleInit:0 |
|
2661 | 4460 |
then call #moduleInit:1, #moduleInit:2 and #moduleInit:3 for all loaded DLLs. |
4461 |
||
4462 |
*** UNDER TEST ... |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4463 |
used by ExpeccoStartup under windows. |
2408 | 4464 |
|
2661 | 4465 |
not supported is C,... |
2408 | 4466 |
" |
2661 | 4467 |
|
2408 | 4468 |
|filename handle initAddr className infoCollection handles info| |
4469 |
||
4470 |
aSeqOfFiles isEmptyOrNil ifTrue:[^ self]. |
|
4471 |
||
4472 |
handles := OrderedCollection new. |
|
4473 |
||
4474 |
Smalltalk flushCachedClasses. |
|
4475 |
Class flushSubclassInfo. |
|
4476 |
||
4477 |
aSeqOfFiles do:[:each| |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4478 |
filename := each asFilename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4479 |
handle := self handleForDynamicObject: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 isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4482 |
Smalltalk showSplashMessage:('loading ', filename baseName). |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4483 |
handle := self loadDynamicObject:filename. |
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 |
handle notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4486 |
className := self initFunctionBasenameForFile:filename. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4487 |
initAddr := self findInitFunction:className in:handle. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4488 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4489 |
initAddr notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4490 |
[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4491 |
self |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4492 |
saveCallInitFunctionAt:initAddr |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4493 |
in:filename |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4494 |
specialInit:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4495 |
forceOld:true |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4496 |
interruptable:false |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4497 |
argument:0 |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4498 |
identifyAs:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4499 |
returnsObject:false. |
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 := self loadStatusFor:nil. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4502 |
(info first == #tryAgain) |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4503 |
] whileTrue. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4504 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4505 |
info first == #ok ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4506 |
handles add:handle |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4507 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4508 |
( '%1: error during init: %2' bindWith:each with:info) printCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4509 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4510 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4511 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4512 |
]. |
2408 | 4513 |
]. |
2661 | 4514 |
Smalltalk showSplashMessage:('initializing modules-1...'). |
2408 | 4515 |
self moduleInit:1 forceOld:true interruptable:false. |
2661 | 4516 |
Smalltalk showSplashMessage:('initializing modules-2...'). |
2408 | 4517 |
self moduleInit:2 forceOld:true interruptable:false. |
4518 |
ObjectMemory flushCaches. |
|
2661 | 4519 |
Smalltalk showSplashMessage:('initializing modules-3...'). |
2408 | 4520 |
self moduleInit:3 forceOld:false interruptable:true. |
4521 |
||
4522 |
infoCollection := ObjectMemory binaryModuleInfo. |
|
4523 |
||
4524 |
handles do:[:each| |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4525 |
|classNames classes| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4526 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4527 |
info := infoCollection at:(handle moduleID) ifAbsent:nil. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4528 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4529 |
info isNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4530 |
('error - nil info: %1' bindWith:handle ) printCR. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4531 |
] ifFalse:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4532 |
classNames := info classNames. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4533 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4534 |
classNames notEmptyOrNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4535 |
classes := OrderedCollection new:classNames size. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4536 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4537 |
classNames do:[:eachClassName | |class| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4538 |
class := Smalltalk classNamed:eachClassName. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4539 |
class notNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4540 |
classes add:class. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4541 |
]. |
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 |
classes notEmptyOrNil ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4544 |
classes := classes asArray. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4545 |
classes := classes , (classes collect:[:aClass | aClass class]). |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4546 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4547 |
handle classes:classes. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4548 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4549 |
]. |
2408 | 4550 |
]. |
2661 | 4551 |
Smalltalk showSplashMessage:('done loading modules.'). |
2408 | 4552 |
|
4553 |
" |
|
4554 |
|directory filename dlls| |
|
4555 |
||
4556 |
directory := 'C:\Dokumente und Einstellungen\Steffen Jung\work\exept\expecco\application' asFilename. |
|
4557 |
filename := directory construct:'modules.stx'. |
|
4558 |
||
4559 |
dlls := OrderedCollection new. |
|
4560 |
||
4561 |
filename readingLinesDo:[:aLine| |
|
2744
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4562 |
|line dllFile| |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4563 |
|
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4564 |
line := aLine withoutSeparators. |
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 |
line size > 3 ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4567 |
line first ~~ $# ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4568 |
dllFile := directory construct:(line, '.dll'). |
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 |
dllFile exists ifTrue:[ |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4571 |
dlls add:dllFile. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4572 |
]. |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4573 |
] |
fb0de2fb6f3b
changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents:
2705
diff
changeset
|
4574 |
] |
2408 | 4575 |
]. |
4576 |
ObjectFileLoader loadObjectFiles:dlls. |
|
4577 |
" |
|
2459 | 4578 |
|
2661 | 4579 |
"Modified: / 11-08-2011 / 17:25:52 / cg" |
2408 | 4580 |
! ! |
4581 |
||
369 | 4582 |
!ObjectFileLoader class methodsFor:'documentation'! |
148 | 4583 |
|
4584 |
version |
|
3721 | 4585 |
^ '$Header$' |
2256
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
4586 |
! |
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
4587 |
|
dba660aa4c26
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
2184
diff
changeset
|
4588 |
version_CVS |
3721 | 4589 |
^ '$Header$' |
148 | 4590 |
! ! |
1358 | 4591 |
|
2992 | 4592 |
|
0 | 4593 |
ObjectFileLoader initialize! |