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