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