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