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