author | Claus Gittinger <cg@exept.de> |
Tue, 22 Jul 1997 18:17:05 +0200 | |
changeset 587 | 5250b6d10925 |
parent 582 | 9a00e2dbdc97 |
child 589 | ee0cc3ae769a |
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 |
||
13 |
Object subclass:#ObjectFileLoader |
|
174 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'MySymbolTable Verbose LastError LinkErrorMessage NextHandleID |
|
149
3dc42a5ab417
default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
LoadedObjects PreviouslyLoadedObjects ActuallyLoadedObjects |
524 | 17 |
SearchedLibraries LibPath LoadLibraryPath ErrorPrinting' |
174 | 18 |
poolDictionaries:'' |
19 |
category:'System-Compiler' |
|
47 | 20 |
! |
21 |
||
53 | 22 |
!ObjectFileLoader primitiveDefinitions! |
0 | 23 |
%{ |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
24 |
|
15 | 25 |
/* |
26 |
* by default, use whatever the system provides |
|
27 |
*/ |
|
95 | 28 |
#ifdef sunos /* sunos (pre 5.4) dlopen interface */ |
15 | 29 |
# define SUN_DL |
20 | 30 |
# define HAS_DL |
15 | 31 |
#endif |
32 |
||
95 | 33 |
#ifdef NeXT /* next rld interface */ |
15 | 34 |
# define NEXT_DL |
20 | 35 |
# define HAS_DL |
15 | 36 |
#endif |
37 |
||
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
38 |
#if defined(SYSV4) || defined(HAS_DLOPEN) /* sys5.4 dlopen interface */ |
15 | 39 |
# define SYSV4_DL |
20 | 40 |
# define HAS_DL |
15 | 41 |
#endif |
42 |
||
523 | 43 |
#if defined(hpux10) |
44 |
# undef SYSV4_DL |
|
45 |
# define HPUX10_DL |
|
46 |
#endif |
|
47 |
||
587 | 48 |
#if defined(alpha) && defined(__osf__) |
49 |
# define SYSV4_DL |
|
50 |
# define HAS_DL |
|
51 |
#endif |
|
52 |
||
95 | 53 |
#ifdef DL1_6 /* dl1.6 COFF loader */ |
54 |
# define HAS_DL |
|
55 |
#endif |
|
56 |
||
98 | 57 |
#ifdef _AIX |
97 | 58 |
# define AIX_DL |
59 |
# define HAS_DL |
|
60 |
#endif |
|
61 |
||
15 | 62 |
/* |
20 | 63 |
* but GNU_DL overwrites this - its better |
15 | 64 |
*/ |
95 | 65 |
#ifdef GNU_DL /* dld2.3.x interface */ |
20 | 66 |
# define HAS_DL |
15 | 67 |
# undef SYSV4_DL |
68 |
# undef NEXT_DL |
|
69 |
# undef SUN_DL |
|
95 | 70 |
# undef DL1_6 |
15 | 71 |
#endif |
72 |
||
20 | 73 |
#include <stdio.h> |
74 |
||
175
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
75 |
#if defined(WIN32) |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
76 |
# undef COFF |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
77 |
# undef ELF |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
78 |
# undef A_DOT_OUT |
180 | 79 |
# define HAS_DL |
80 |
# define WIN_DL |
|
175
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
81 |
#endif |
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
82 |
|
20 | 83 |
/* |
95 | 84 |
* if no dynamic link facilities, try it the hard way ... |
20 | 85 |
*/ |
175
f94969b034c7
make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
86 |
#if !defined(HAS_DL) |
20 | 87 |
|
88 |
# ifdef A_DOT_OUT |
|
89 |
# include <a.out.h> |
|
90 |
# ifndef N_MAGIC |
|
91 |
# if defined(sinix) && defined(BSD) |
|
92 |
# define N_MAGIC(hdr) (hdr.a_magic & 0xFFFF) |
|
93 |
# else |
|
94 |
# define N_MAGIC(hdr) (hdr.a_magic) |
|
95 |
# endif |
|
96 |
# endif |
|
97 |
# endif /* a.out */ |
|
98 |
||
99 |
# ifdef COFF |
|
100 |
# ifdef mips |
|
101 |
# include <sys/exec.h> |
|
102 |
# else |
|
103 |
# include <a.out.h> |
|
104 |
# endif |
|
105 |
# endif /* coff */ |
|
106 |
||
107 |
# ifdef ELF |
|
108 |
# include <elf.h> |
|
109 |
# endif /* elf */ |
|
110 |
||
111 |
#endif /* not HAS_DL */ |
|
112 |
||
95 | 113 |
#ifdef NEXT_DL |
114 |
# ifndef _RLD_H_ |
|
115 |
# define _RLD_H_ |
|
125 | 116 |
# ifdef NEXT3 |
117 |
# include <mach-o/rld.h> |
|
118 |
# else |
|
119 |
# include <rld.h> |
|
120 |
# endif |
|
95 | 121 |
# endif |
122 |
#endif /* NEXT_DL */ |
|
123 |
||
28 | 124 |
#ifdef SYSV4_DL |
125 |
# include <dlfcn.h> |
|
126 |
# define dlcfn_h |
|
127 |
#endif |
|
128 |
||
45 | 129 |
#ifdef GNU_DL |
130 |
# ifndef dld_h |
|
131 |
# include "dld.h" |
|
132 |
# define dld_h |
|
133 |
# endif |
|
134 |
#endif |
|
95 | 135 |
|
136 |
#ifdef DL1_6 |
|
137 |
# ifndef dl_h |
|
138 |
# include "dl.h" |
|
139 |
# define dl_h |
|
140 |
# endif |
|
141 |
#endif |
|
142 |
||
97 | 143 |
#ifdef AIX_DL |
144 |
# include <nlist.h> |
|
100 | 145 |
# include <sys/ldr.h> |
146 |
# include <errno.h> |
|
97 | 147 |
#endif |
180 | 148 |
|
523 | 149 |
#ifdef HPUX10_DL |
150 |
# include <dl.h> |
|
524 | 151 |
# include <errno.h> |
523 | 152 |
#endif |
153 |
||
180 | 154 |
#ifdef WIN_DL |
155 |
||
156 |
# ifdef WIN32 |
|
157 |
# undef INT |
|
158 |
# undef Array |
|
159 |
# undef Number |
|
160 |
# undef Method |
|
468 | 161 |
# undef Block |
180 | 162 |
|
163 |
# ifdef i386 |
|
164 |
# define _X86_ |
|
165 |
# endif |
|
166 |
||
167 |
/* # include <windows.h> /* */ |
|
168 |
# include <windef.h> /* */ |
|
169 |
# include <winbase.h> /* */ |
|
170 |
||
208 | 171 |
# ifdef __DEF_Array |
172 |
# define Array __DEF_Array |
|
180 | 173 |
# endif |
208 | 174 |
# ifdef __DEF_Number |
175 |
# define Number __DEF_Number |
|
180 | 176 |
# endif |
208 | 177 |
# ifdef __DEF_Method |
178 |
# define Method __DEF_Method |
|
468 | 179 |
# endif |
180 |
# ifdef __DEF_Block |
|
181 |
# define Block __DEF_Block |
|
180 | 182 |
# endif |
183 |
# endif |
|
184 |
||
185 |
#endif |
|
0 | 186 |
%} |
20 | 187 |
! ! |
188 |
||
369 | 189 |
!ObjectFileLoader class methodsFor:'documentation'! |
141 | 190 |
|
191 |
copyright |
|
192 |
" |
|
193 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
194 |
All Rights Reserved |
|
195 |
||
196 |
This software is furnished under a license and may be used |
|
197 |
only in accordance with the terms of that license and with the |
|
198 |
inclusion of the above copyright notice. This software may not |
|
199 |
be provided or otherwise made available to, or used by, any |
|
200 |
other person. No title to or ownership of the software is |
|
201 |
hereby transferred. |
|
202 |
" |
|
203 |
! |
|
204 |
||
205 |
documentation |
|
206 |
" |
|
207 |
This class knowns how to dynamically load in external object-modules. |
|
208 |
||
209 |
WARNING: |
|
210 |
As to date, this is completely experimental and WITHOUT ANY WARRANTY. |
|
211 |
It is still being developed and the code below needs cleanup and more |
|
212 |
robustness. |
|
213 |
||
214 |
There are basically two totally different mechanisms to do this: |
|
468 | 215 |
a) if there exists some dynamic-link facility such as: |
216 |
GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT), |
|
217 |
this is used |
|
218 |
b) if no such facility exists, the normal linker is used to |
|
219 |
link the module to text/data address as previously malloced, |
|
220 |
and the object file loaded into that space. |
|
141 | 221 |
|
222 |
Currently, not all mechanisms work fully satisfying. |
|
223 |
For example, the sun dl*-functions do an exit on link-errors (which |
|
224 |
is certainly not what we want here :-(; the NeXT mechanism does not |
|
225 |
allow for selective unloading (only all or last). |
|
226 |
||
227 |
The only really useful packages are the GNU-dl package and the SGI/Unixware |
|
228 |
sys5.4 libdl packages. |
|
229 |
The GNU-dl package is only available for a.out file formats; |
|
230 |
i.e. only (a subset of) linux people can use it at this time. |
|
231 |
For the above reasons, dynamic object loading is currently only |
|
232 |
officially released for SYS5.4 and LINUX systems. |
|
233 |
||
234 |
Once stable, the functionality contained herein will be moved into |
|
235 |
the VM. |
|
236 |
(It is needed there, to allow reloading of objectfiles upon |
|
237 |
image restart; i.e. before any class is reinitialilized). |
|
263 | 238 |
|
239 |
[author:] |
|
468 | 240 |
Claus Gittinger |
141 | 241 |
" |
242 |
! ! |
|
243 |
||
369 | 244 |
!ObjectFileLoader class methodsFor:'initialization'! |
0 | 245 |
|
246 |
initialize |
|
317 | 247 |
|systemType| |
0 | 248 |
|
201 | 249 |
MySymbolTable isNil ifTrue:[ |
504 | 250 |
Verbose := false. |
251 |
NextHandleID := 1. |
|
252 |
ObjectMemory addDependent:self. |
|
253 |
||
521 | 254 |
OperatingSystem isMSDOSlike ifTrue:[ |
255 |
"/ ... we'll see |
|
504 | 256 |
]. |
257 |
||
521 | 258 |
OperatingSystem isUNIXlike ifTrue:[ |
259 |
systemType := OperatingSystem getOSType. |
|
260 |
||
261 |
"/ name of object file, where initial symbol table is found |
|
262 |
"/ not req'd for all architectures. |
|
263 |
||
264 |
MySymbolTable := 'stx'. |
|
265 |
||
266 |
"/ default set of libraries to be considered when |
|
267 |
"/ unresolved symbols are encountered during the load. |
|
268 |
"/ Only req'd for linux and sunos non-ELF systems. |
|
269 |
"/ Can (should) be set in the smalltalk.rc file. |
|
270 |
||
271 |
SearchedLibraries := #(). |
|
272 |
||
273 |
(systemType = 'linux' |
|
274 |
or:[systemType = 'sunos']) ifTrue:[ |
|
275 |
'/usr/lib/libc.a' asFilename isReadable ifTrue:[ |
|
276 |
SearchedLibraries := #('/usr/lib/libc.a') |
|
277 |
] ifFalse:[ |
|
278 |
'/lib/libc.a' asFilename isReadable ifTrue:[ |
|
279 |
SearchedLibraries := #('/lib/libc.a') |
|
280 |
] |
|
281 |
] |
|
282 |
]. |
|
283 |
||
284 |
"/ default libraryPath where shared objects are searched for |
|
285 |
"/ when a dynamic library is loaded without an explicit path. |
|
286 |
||
287 |
LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'. |
|
288 |
LoadLibraryPath isNil ifTrue:[ |
|
289 |
LoadLibraryPath := #('.' |
|
290 |
'lib' |
|
291 |
'/usr/local/smalltalk/lib' |
|
292 |
'/usr/local/lib' |
|
293 |
'/usr/lib' |
|
294 |
'/lib' |
|
295 |
) asOrderedCollection. |
|
296 |
]. |
|
297 |
||
298 |
"/ default libraryPath where shared objects are expected |
|
299 |
"/ when a sharedObject load requires other objects to be loaded. |
|
300 |
"/ Only req'd for aix. |
|
301 |
"/ For more compatibility with ELF systems, look for a shell variable |
|
302 |
"/ named LD_LIBRARY_PATH, and - if present - take that instead if a default. |
|
303 |
"/ Can (should) be set in the smalltalk.rc file. |
|
304 |
||
305 |
systemType = 'aix' ifTrue:[ |
|
306 |
LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'. |
|
307 |
LibPath isNil ifTrue:[ |
|
308 |
LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'. |
|
309 |
] |
|
310 |
]. |
|
311 |
] |
|
201 | 312 |
] |
107 | 313 |
|
314 |
" |
|
315 |
ObjectFileLoader initialize |
|
316 |
" |
|
316
ee3426730cfc
on sunos: link dynamic objects against libc.a for unresolved symbols.
Claus Gittinger <cg@exept.de>
parents:
307
diff
changeset
|
317 |
|
521 | 318 |
"Modified: 2.5.1997 / 11:24:55 / cg" |
0 | 319 |
! |
320 |
||
141 | 321 |
lastError |
322 |
^ LastError |
|
323 |
! |
|
324 |
||
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
325 |
libPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
326 |
"see comment in #libPath:" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
327 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
328 |
^ LibPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
329 |
! |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
330 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
331 |
libPath:aSharedLibraryPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
332 |
"set the pathnames of directories, where other shared objects |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
333 |
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
|
334 |
library object to be loaded. |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
335 |
Currently, this is only required to be set for AIX systems; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
336 |
ELF based linux and solaris systems specify the libPath in the |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
337 |
LD_LIBRARY_PATH environment variable." |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
338 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
339 |
LibPath := aSharedLibraryPath |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
340 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
341 |
" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
342 |
ObjectFileLoader libPath:'.:/usr/lib:/usr/local/lib' |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
343 |
" |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
344 |
! |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
345 |
|
141 | 346 |
linkErrorMessage |
347 |
^ LinkErrorMessage |
|
348 |
! |
|
349 |
||
350 |
searchedLibraries |
|
351 |
"see comment in #searchedLibraries:" |
|
352 |
||
353 |
^ SearchedLibraries |
|
354 |
! |
|
355 |
||
125 | 356 |
searchedLibraries:aCollectionOfArchivePathNames |
357 |
"set the pathnames of archives which are to be searched |
|
358 |
when unresolved references occur while loading in an object |
|
359 |
file. On systems which support shared libraries (all SYS5.4 based |
|
360 |
systems), this is usually not required. Instead, modules which are to |
|
361 |
be filed in (.so files) are to be prelinked with the appropriate |
|
362 |
shared libraries. The dynamic loader then cares about loading those |
|
363 |
modules (keeping track of which modules are already loaded). |
|
364 |
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
|
365 |
(i.e. currently only linux and a.out-sunos) need to set this." |
125 | 366 |
|
367 |
SearchedLibraries := aCollectionOfArchivePathNames |
|
368 |
! |
|
369 |
||
0 | 370 |
verbose:aBoolean |
371 |
"turn on/off debug traces" |
|
372 |
||
10 | 373 |
Verbose := aBoolean |
0 | 374 |
|
375 |
"ObjectFileLoader verbose:true" |
|
376 |
! ! |
|
377 |
||
369 | 378 |
!ObjectFileLoader class methodsFor:'change & update'! |
291 | 379 |
|
380 |
update:something with:aParameter from:changedObject |
|
107 | 381 |
"sent, when image is saved or restarted" |
382 |
||
383 |
(something == #aboutToSnapshot) ifTrue:[ |
|
468 | 384 |
self invalidateAndRememberAllObjectFiles |
125 | 385 |
]. |
386 |
(something == #finishedSnapshot) ifTrue:[ |
|
468 | 387 |
self revalidateAllObjectFiles |
107 | 388 |
]. |
226
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
389 |
"/ (something == #restarted) ifTrue:[ |
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
390 |
"/ self reloadAllRememberedObjectFiles |
f0771f42256d
reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents:
225
diff
changeset
|
391 |
"/ ]. |
125 | 392 |
|
393 |
"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
|
394 |
"Modified: 8.3.1996 / 23:34:29 / cg" |
291 | 395 |
"Created: 21.6.1996 / 19:50:01 / cg" |
107 | 396 |
! ! |
397 |
||
369 | 398 |
!ObjectFileLoader class methodsFor:'defaults'! |
115 | 399 |
|
141 | 400 |
hasValidBinaryExtension:aFilename |
401 |
"return true, if aFilename looks ok for binary loading. |
|
402 |
This checks only the extension - not its contents. |
|
403 |
(So an attempt to load the file may fail due to format errors or unresolved symbols) |
|
404 |
This is very machine specific." |
|
405 |
||
406 |
self validBinaryExtensions do:[:ext | |
|
516 | 407 |
(aFilename endsWith:ext) ifTrue:[^ true]. |
141 | 408 |
]. |
409 |
^ false |
|
410 |
||
411 |
" |
|
412 |
ObjectFileLoader hasValidBinaryExtension:'foo.st' |
|
516 | 413 |
ObjectFileLoader hasValidBinaryExtension:'foo.o' |
141 | 414 |
ObjectFileLoader hasValidBinaryExtension:'foo.so' |
516 | 415 |
ObjectFileLoader hasValidBinaryExtension:'foo.dll' |
416 |
ObjectFileLoader hasValidBinaryExtension:'foo.obj' |
|
141 | 417 |
" |
516 | 418 |
|
419 |
"Modified: 29.4.1997 / 21:55:07 / cg" |
|
141 | 420 |
! |
421 |
||
188 | 422 |
loadableBinaryObjectFormat |
423 |
"return a symbol describing the expected binary format |
|
424 |
for object files to be loadable. |
|
425 |
This is very machine specific." |
|
426 |
||
427 |
%{ /* NOCONTEXT */ |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
428 |
|
188 | 429 |
#ifdef HAS_DL |
430 |
# if defined(SYSV4) || defined(ELF) |
|
431 |
RETURN ( @symbol(elf)); |
|
432 |
# endif |
|
433 |
# if defined(GNU_DL) |
|
434 |
RETURN ( @symbol(aout)); |
|
435 |
# endif |
|
436 |
# if defined(AIX_DL) |
|
437 |
RETURN ( @symbol(xcoff)); |
|
438 |
# endif |
|
523 | 439 |
# if defined(HPUX10_DL) |
440 |
RETURN ( @symbol(hpcoff)); |
|
441 |
# endif |
|
188 | 442 |
# if defined(DL1_6) |
443 |
RETURN ( @symbol(coff)); |
|
444 |
# endif |
|
445 |
# if defined(WIN_DL) |
|
446 |
RETURN ( @symbol(dll)); |
|
447 |
# endif |
|
448 |
#endif |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
449 |
|
188 | 450 |
%}. |
451 |
^ nil |
|
452 |
||
453 |
" |
|
454 |
ObjectFileLoader loadableBinaryObjectFormat |
|
455 |
" |
|
456 |
! |
|
457 |
||
141 | 458 |
nm:file |
403 | 459 |
"this should return a string to list the namelist of file. |
460 |
The output of the command should be one line for each symbol, |
|
461 |
formatted as: |
|
521 | 462 |
addr segment name |
403 | 463 |
This is parsed and read by #namesMatching:segment:in:. |
464 |
||
465 |
If your default nm command cannot produce this, write a little |
|
466 |
shell or awk script, to generate this and return a corresponding command |
|
521 | 467 |
below. |
468 |
This entry is obsolete (no longer req'd) and will vanish." |
|
141 | 469 |
|
470 |
|os| |
|
471 |
||
521 | 472 |
os := OperatingSystem getOSType. |
473 |
(os = 'irix') ifTrue:[ |
|
474 |
^ 'nm -B ' , file |
|
403 | 475 |
]. |
476 |
(os = 'solaris') ifTrue:[ |
|
521 | 477 |
^ 'nm -p ' , file |
141 | 478 |
]. |
479 |
^ 'nm ' , file |
|
403 | 480 |
|
521 | 481 |
"Modified: 2.5.1997 / 11:26:35 / cg" |
141 | 482 |
! |
483 |
||
115 | 484 |
sharedLibraryExtension |
521 | 485 |
"return the fileName extension used for dynamic loadable objects. |
115 | 486 |
This is very machine specific." |
487 |
||
488 |
|os| |
|
489 |
||
521 | 490 |
OperatingSystem isMSDOSlike ifTrue:[ |
491 |
"/ includes all of win32s, win95, winNT & os/2 |
|
492 |
^ '.dll' |
|
493 |
]. |
|
494 |
||
115 | 495 |
os := OperatingSystem getSystemType. |
125 | 496 |
(os = 'sys5_4') ifTrue:[^ '.so']. |
115 | 497 |
(os = 'iris') ifTrue:[^ '.so']. |
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
498 |
(os = 'linux') ifTrue:[ |
504 | 499 |
self loadableBinaryObjectFormat == #aout ifTrue:[ |
500 |
"/ not really shared, but loadable |
|
501 |
^ '.o' |
|
502 |
]. |
|
503 |
^ '.so' |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
504 |
]. |
404 | 505 |
(os = 'solaris') ifTrue:[^ '.so' ]. |
115 | 506 |
(os = 'aix') ifTrue:[^ '.so']. |
507 |
(os = 'hpux') ifTrue:[^ '.sl']. |
|
119 | 508 |
|
509 |
"/ mhmh what is a useful default ? |
|
510 |
||
511 |
^ '.o' |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
512 |
|
521 | 513 |
"Modified: 2.5.1997 / 11:28:16 / cg" |
115 | 514 |
! |
0 | 515 |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
516 |
validBinaryExtensions |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
517 |
"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
|
518 |
This is very machine specific." |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
519 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
520 |
|os| |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
521 |
|
521 | 522 |
OperatingSystem isMSDOSlike ifTrue:[ |
523 |
"/ includes all of win32s, win95, winNT & os/2 |
|
524 |
^ #('.dll') |
|
525 |
]. |
|
526 |
||
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
527 |
os := OperatingSystem getSystemType. |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
528 |
(os = 'sys5_4') ifTrue:[^ #('.so') ]. |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
529 |
(os = 'iris') ifTrue:[^ #('.so') ]. |
403 | 530 |
(os = 'solaris') ifTrue:[^ #('.so') ]. |
504 | 531 |
(os = 'sunos') ifTrue:[^ #('.o' '.obj' '.a') ]. |
514 | 532 |
(os = 'ultrix') ifTrue:[^ #('.o' '.obj' '.ld' '.obj.ld') ]. |
504 | 533 |
(os = 'linux') ifTrue:[ |
534 |
self loadableBinaryObjectFormat == #aout ifTrue:[ |
|
535 |
^ #('.o' '.obj' '.a') |
|
536 |
]. |
|
537 |
^ #('.so' '.o' '.obj' ) |
|
538 |
]. |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
539 |
(os = 'aix') ifTrue:[^ #('.o' '.so') ]. |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
540 |
(os = 'hpux') ifTrue:[^ #('.o' '.sl') ]. |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
541 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
542 |
"/ mhmh what is a useful default ? |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
543 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
544 |
^ #('.o') |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
545 |
|
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
546 |
" |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
547 |
ObjectFileLoader validBinaryExtensions |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
548 |
" |
403 | 549 |
|
521 | 550 |
"Modified: 2.5.1997 / 11:29:00 / cg" |
141 | 551 |
! ! |
552 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
553 |
!ObjectFileLoader class methodsFor:'dynamic object loading'! |
141 | 554 |
|
555 |
loadCPlusPlusObjectFile:aFileName |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
556 |
"load a c++ object file (.o-file) into the image. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
557 |
This method is not maintained (name mangling and static |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
558 |
initialization is so different among systems ...)" |
141 | 559 |
|
560 |
|handle initAddr list| |
|
561 |
||
562 |
handle := self loadDynamicObject:aFileName. |
|
563 |
handle isNil ifTrue:[ |
|
524 | 564 |
Transcript showCR:('failed to load: ' , aFileName). |
565 |
('ObjectFileLoader [warning]: ' |
|
566 |
, aFileName |
|
567 |
, ' failed. (' |
|
568 |
, LinkErrorMessage |
|
569 |
, ')') errorPrintCR. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
570 |
^ nil |
141 | 571 |
]. |
572 |
||
573 |
list := self namesMatching:'__GLOBAL_$I*' segment:'[tT]' in:aFileName. |
|
574 |
list size == 1 ifTrue:[ |
|
575 |
"/ (self isCPlusPlusObject:handle) ifTrue:[ |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
576 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
577 |
'a c++ object file' infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
578 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
579 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
580 |
what I would like to get is the CTOR_LIST, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
581 |
and call each function. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
582 |
But dld cannot (currently) handle SET-type symbols, therefore |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
583 |
we search (using nm) for all __GLOBAL_$I* syms, get their values |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
584 |
and call them each |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
585 |
" |
141 | 586 |
"/ list := self namesMatching:'__GLOBAL_$I*' segment:'[tT]' in:aFileName. |
587 |
||
588 |
"/ initAddr := self getFunction:'__CTOR_LIST__' from:handle. |
|
589 |
"/ Verbose ifTrue:[ |
|
478 | 590 |
"/ ('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintCR |
141 | 591 |
"/ ]. |
592 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
593 |
initAddr := self getFunction:list first from:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
594 |
initAddr isNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
595 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
596 |
try with added underscore |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
597 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
598 |
initAddr := self getFunction:('_' , list first) from:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
599 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
600 |
(initAddr isNil and:[list first startsWith:'_']) ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
601 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
602 |
try with removed underscore |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
603 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
604 |
initAddr := self getFunction:(list first copyFrom:2) from:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
605 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
606 |
initAddr isNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
607 |
Verbose ifTrue:[ |
478 | 608 |
('no CTOR-func found (' , list first , ')') infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
609 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
610 |
self unloadDynamicObject:aFileName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
611 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
612 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
613 |
Verbose ifTrue:[ |
478 | 614 |
('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
615 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
616 |
self callInitFunctionAt:initAddr |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
617 |
specialInit:false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
618 |
forceOld:false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
619 |
interruptable:false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
620 |
argument:0 |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
621 |
identifyAs:nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
622 |
returnsObject:false. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
623 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
624 |
Verbose ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
625 |
'done with CTORs.' infoPrintNL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
626 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
627 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
628 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
629 |
cannot create a CPlusPlus class automatically (there could be more than |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
630 |
one classes in it too ...) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
631 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
632 |
^ handle |
141 | 633 |
]. |
634 |
||
635 |
||
636 |
Verbose ifTrue:[ |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
637 |
'unknown object file' infoPrintNL |
141 | 638 |
]. |
639 |
self unloadDynamicObject:aFileName. |
|
640 |
^ nil |
|
272 | 641 |
|
478 | 642 |
"Modified: 10.1.1997 / 19:11:57 / cg" |
141 | 643 |
! |
644 |
||
645 |
loadClass:aClassName fromObjectFile:aFileName |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
646 |
"load a compiled class (.o-file) into the image. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
647 |
Returns the class or nil." |
141 | 648 |
|
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
649 |
|handle initAddr symName newClass moreHandles info status |
141 | 650 |
otherClass knownToBeOk| |
651 |
||
652 |
handle := self loadDynamicObject:aFileName. |
|
653 |
handle isNil ifTrue:[ |
|
580 | 654 |
Transcript showCR:('failed to load: ' , aFileName). |
655 |
('ObjectFileLoader [warning]: ' |
|
656 |
, aFileName |
|
657 |
, ' failed. (' |
|
658 |
, LinkErrorMessage |
|
659 |
, ')') errorPrintCR. |
|
660 |
^ nil |
|
141 | 661 |
]. |
662 |
||
663 |
" |
|
664 |
get the Init-function; let the class install itself |
|
665 |
" |
|
666 |
symName := '_' , aClassName , '_Init'. |
|
667 |
initAddr := self getFunction:symName from:handle. |
|
668 |
initAddr isNil ifTrue:[ |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
669 |
"try with added underscore" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
670 |
symName := '__' , aClassName , '_Init'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
671 |
initAddr := self getFunction:symName from:handle. |
141 | 672 |
]. |
673 |
||
674 |
knownToBeOk := true. |
|
675 |
||
676 |
"/ knownToBeOk ifFalse:[ |
|
468 | 677 |
"/ |list| |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
678 |
"/ |
141 | 679 |
"/ Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
680 |
"/ 'looking for undefs ...' infoPrintCR. |
141 | 681 |
"/ ]. |
682 |
"/ |
|
683 |
"/ " |
|
684 |
"/ if there are any undefined symbols, we may have to load more |
|
685 |
"/ files (libs, other modules) |
|
686 |
"/ " |
|
687 |
"/ list := self getListOfUndefinedSymbolsFrom:handle. |
|
688 |
"/ list notNil ifTrue:[ |
|
689 |
"/ moreHandles := self loadModulesFromListOfUndefined:list. |
|
690 |
"/ |
|
691 |
"/ " |
|
692 |
"/ now, try again |
|
693 |
"/ " |
|
694 |
"/ symName := '_' , aClassName , '_Init'. |
|
695 |
"/ initAddr := self getFunction:symName from:handle. |
|
696 |
"/ initAddr isNil ifTrue:[ |
|
697 |
"/ "try with added underscore" |
|
698 |
"/ symName := '__' , aClassName , '_Init'. |
|
699 |
"/ initAddr := self getFunction:symName from:handle. |
|
700 |
"/ ]. |
|
701 |
"/ ] |
|
702 |
"/ ]. |
|
703 |
||
704 |
initAddr notNil ifTrue:[ |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
705 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
706 |
('calling init at: ' , (initAddr printStringRadix:16)) infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
707 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
708 |
info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
709 |
status := info at:1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
710 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
711 |
if any classes are missing ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
712 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
713 |
(status == #missingClass) ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
714 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
715 |
... and we are loading a module ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
716 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
717 |
Transcript showCR:'try for missing class in same object ...'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
718 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
719 |
'try for missing class:' infoPrint. (info at:2) infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
720 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
721 |
otherClass := self loadClass:(info at:2) fromObjectFile:aFileName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
722 |
otherClass notNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
723 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
724 |
try again ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
725 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
726 |
Transcript showCR:'missing class is here; try again ...'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
727 |
info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
728 |
status := info at:1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
729 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
730 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
731 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
732 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
733 |
'done init status=' infoPrint. info infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
734 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
735 |
(status == #unregisteredSuperclass) ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
736 |
Transcript showCR:'superclass is not registered'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
737 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
738 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
739 |
(Symbol hasInterned:aClassName) ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
740 |
newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
741 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
742 |
'newClass is: ' infoPrint. newClass infoPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
743 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
744 |
newClass notNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
745 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
746 |
'initialize newClass ...' infoPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
747 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
748 |
newClass initialize. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
749 |
"force cache flush" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
750 |
Smalltalk at:aClassName asSymbol put:newClass. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
751 |
Smalltalk isInitialized ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
752 |
Smalltalk changed. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
753 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
754 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
755 |
] ifFalse:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
756 |
'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint. |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
757 |
' did not define itself' errorPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
758 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
759 |
do not unload - could have installed other classes/methods ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
760 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
761 |
]. |
582
9a00e2dbdc97
must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents:
580
diff
changeset
|
762 |
Smalltalk flushCachedClasses. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
763 |
^ newClass |
141 | 764 |
]. |
765 |
||
766 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
767 |
('no symbol: ', symName,' in ',aFileName) infoPrintCR. |
141 | 768 |
]. |
769 |
||
770 |
" |
|
771 |
unload |
|
772 |
" |
|
773 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
774 |
'unloading due to init failure:' infoPrint. handle pathName infoPrintCR. |
141 | 775 |
]. |
776 |
||
777 |
moreHandles notNil ifTrue:[ |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
778 |
moreHandles do:[:aHandle | |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
779 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
780 |
('unloading: ', aHandle printString) infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
781 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
782 |
self unloadDynamicObject:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
783 |
] |
141 | 784 |
]. |
785 |
||
786 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
787 |
('unloading: ', handle printString) infoPrintCR. |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
788 |
]. |
141 | 789 |
self unloadDynamicObject:handle. |
790 |
^ nil |
|
791 |
||
792 |
" |
|
793 |
ObjectFileLoader loadClass:'Tetris' fromObjectFile:'../clients/Tetris/Tetris.o' |
|
794 |
ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o' |
|
795 |
ObjectFileLoader loadClass:'Foo' fromObjectFile:'classList.o' |
|
796 |
" |
|
272 | 797 |
|
582
9a00e2dbdc97
must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents:
580
diff
changeset
|
798 |
"Modified: 6.7.1997 / 12:34:48 / cg" |
141 | 799 |
! |
800 |
||
504 | 801 |
loadLibrary:aLibraryFileName |
802 |
"load a library; search in some standard places and using |
|
803 |
standard suffixes (i.e. no suffix should be given in the arg). |
|
804 |
Returns a handle or nil. |
|
805 |
Use this to attach C-libraries." |
|
806 |
||
807 |
|s suffixes handle| |
|
808 |
||
809 |
(s := aLibraryFileName asFilename suffix) isEmpty ifTrue:[ |
|
810 |
suffixes := self validBinaryExtensions |
|
811 |
] ifFalse:[ |
|
812 |
suffixes := Array with:'' |
|
813 |
]. |
|
814 |
||
815 |
"/ try each suffix ... |
|
816 |
suffixes do:[:aSuffix | |
|
817 |
|fn f| |
|
818 |
||
819 |
fn := aLibraryFileName , aSuffix. |
|
820 |
||
821 |
(aLibraryFileName asFilename isAbsolute |
|
822 |
or:[(aLibraryFileName startsWith:'./') |
|
823 |
or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[ |
|
824 |
f := fn asFilename. |
|
825 |
f exists ifTrue:[ |
|
826 |
handle := self loadObjectFile:fn. |
|
827 |
handle notNil ifTrue:[^ handle]. |
|
828 |
] |
|
829 |
] ifFalse:[ |
|
830 |
"/ try each directory |
|
831 |
||
832 |
LoadLibraryPath do:[:aDir | |
|
833 |
f := (aDir , '/' , fn) asFilename. |
|
834 |
f exists ifTrue:[ |
|
835 |
handle := self loadObjectFile:(aDir , '/' , fn). |
|
836 |
handle notNil ifTrue:[^ handle]. |
|
837 |
] |
|
838 |
] |
|
839 |
] |
|
840 |
]. |
|
841 |
||
842 |
^ nil |
|
843 |
||
844 |
" |
|
845 |
ObjectFileLoader loadLibrary:'libjpeg' |
|
846 |
" |
|
847 |
||
848 |
"Modified: 11.4.1997 / 15:44:48 / cg" |
|
849 |
! |
|
850 |
||
174 | 851 |
loadMethodObjectFile:aFileName |
852 |
"load an object file (.o-file) for a single method into the image; |
|
853 |
This does a slightly different initialization. |
|
854 |
Return an object handle; nil on error" |
|
855 |
||
346 | 856 |
|handle initAddr initName m| |
174 | 857 |
|
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
858 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
859 |
"/ load the objectfile |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
860 |
"/ |
174 | 861 |
handle := self loadDynamicObject:aFileName. |
862 |
handle isNil ifTrue:[ |
|
474 | 863 |
^ nil |
174 | 864 |
]. |
865 |
||
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
866 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
867 |
"/ find the entry function |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
868 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
869 |
initName := aFileName asFilename withoutSuffix baseName. |
174 | 870 |
|
871 |
initAddr := self getFunction:'__' , initName , '_Init' from:handle. |
|
872 |
initAddr isNil ifTrue:[ |
|
474 | 873 |
initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle. |
874 |
initAddr isNil ifTrue:[ |
|
875 |
(self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[ |
|
876 |
self listUndefinedSymbolsIn:handle. |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
877 |
'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR. |
474 | 878 |
] ifFalse:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
879 |
('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR |
474 | 880 |
]. |
881 |
||
882 |
"/ |
|
883 |
"/ not found - unload |
|
884 |
"/ |
|
885 |
self unloadDynamicObject:handle. |
|
886 |
^ nil |
|
887 |
] |
|
174 | 888 |
]. |
889 |
||
300
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
890 |
"/ |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
891 |
"/ call it - it returns the new method object |
e351220115f5
added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
892 |
"/ |
174 | 893 |
m := self |
474 | 894 |
callInitFunctionAt:initAddr |
895 |
specialInit:true |
|
896 |
forceOld:true |
|
897 |
interruptable:false |
|
898 |
argument:2 |
|
899 |
identifyAs:handle |
|
900 |
returnsObject:true. |
|
174 | 901 |
|
902 |
handle method:m. |
|
903 |
^ handle |
|
904 |
||
905 |
"Created: 5.12.1995 / 20:59:46 / cg" |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
906 |
"Modified: 10.1.1997 / 17:58:15 / cg" |
174 | 907 |
! |
908 |
||
141 | 909 |
loadObjectFile:aFileName |
910 |
"load an object file (.o-file) into the image; |
|
911 |
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
|
912 |
This may be either a smalltalk object or a C-object file. |
472 | 913 |
The object files init function (if any) is called, and the module |
914 |
is unloaded if it returns failure (use lowLevel load, to load a file |
|
915 |
without automatic initialization). |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
916 |
Return nil on error, an objectFile handle if ok." |
141 | 917 |
|
346 | 918 |
|handle initAddr className initNames didInit info status |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
919 |
dummyHandle msg isCModule| |
141 | 920 |
|
921 |
handle := self loadDynamicObject:aFileName. |
|
922 |
handle isNil ifTrue:[ |
|
524 | 923 |
Transcript showCR:('failed to load: ' , aFileName). |
924 |
('ObjectFileLoader [warning]: ' |
|
925 |
, aFileName |
|
926 |
, ' failed. (' |
|
927 |
, LinkErrorMessage |
|
928 |
, ')') errorPrintCR. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
929 |
^ nil |
141 | 930 |
]. |
931 |
||
932 |
didInit := false. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
933 |
isCModule := false. |
141 | 934 |
|
935 |
"/ with dld, load may have worked, even if undefined symbols |
|
936 |
"/ are to be resolved. If thats the case, load all libraries ... |
|
937 |
||
938 |
SearchedLibraries notNil ifTrue:[ |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
939 |
(self hasUndefinedSymbolsIn:handle) ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
940 |
SearchedLibraries do:[:libName | |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
941 |
(self hasUndefinedSymbolsIn:handle) ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
942 |
Transcript showCR:' ... trying ' , libName , ' to resolve undefined symbols ...'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
943 |
dummyHandle := Array new:4. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
944 |
dummyHandle := self primLoadDynamicObject:libName into:dummyHandle. |
228
be9939d96cfe
removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents:
227
diff
changeset
|
945 |
"/ dummyHandle isNil ifTrue:[ |
272 | 946 |
"/ Transcript showCR:' ... load of library ' , libName , ' failed.'. |
228
be9939d96cfe
removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents:
227
diff
changeset
|
947 |
"/ ] |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
948 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
949 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
950 |
(self hasUndefinedSymbolsIn:handle) isNil ifTrue:[ |
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
951 |
Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.'). |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
952 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
953 |
] |
141 | 954 |
]. |
955 |
||
956 |
" |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
957 |
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
|
958 |
(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
|
959 |
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
|
960 |
scheme as well) |
141 | 961 |
" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
962 |
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
|
963 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
964 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
965 |
"/ 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
|
966 |
"/ 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
|
967 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
968 |
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
|
969 |
|
141 | 970 |
initAddr notNil ifTrue:[ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
971 |
Verbose ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
972 |
('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
973 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
974 |
info := self performModuleInitAt:initAddr for:nil identifyAs:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
975 |
status := info at:1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
976 |
status == #ok ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
977 |
didInit := true. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
978 |
] |
141 | 979 |
] ifFalse:[ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
980 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
981 |
"/ look for explicit C-init (xxx__Init) function |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
982 |
"/ This is used in C object files |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
983 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
984 |
initAddr := self findFunction:className suffix:'__Init' in:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
985 |
initAddr notNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
986 |
isCModule := true. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
987 |
(self callInitFunctionAt:initAddr |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
988 |
specialInit:false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
989 |
forceOld:true |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
990 |
interruptable:false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
991 |
argument:0 |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
992 |
identifyAs:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
993 |
returnsObject:false) < 0 ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
994 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
995 |
Verbose ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
996 |
'init function return failure ... unload' infoPrintCR. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
997 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
998 |
status := #initFailed. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
999 |
] ifFalse:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1000 |
didInit := true. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1001 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1002 |
] ifFalse:[ |
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1003 |
status := #noInitFunction. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1004 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1005 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1006 |
look for any init-function(s); call them all |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1007 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1008 |
Verbose ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1009 |
'no good init functions found; looking for candidates ...' infoPrintCR. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1010 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1011 |
initNames := self namesMatching:'*_Init' segment:'[tT]' in:aFileName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1012 |
initNames notNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1013 |
initNames do:[:aName | |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1014 |
initAddr := self getFunction:aName from:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1015 |
initAddr isNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1016 |
(aName startsWith:'_') ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1017 |
initAddr := self getFunction:(aName copyFrom:2) from:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1018 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1019 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1020 |
initAddr isNil ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1021 |
Transcript showCR:('no symbol: ',aName,' in ',aFileName). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1022 |
] ifFalse:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1023 |
Verbose ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1024 |
('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1025 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1026 |
self performModuleInitAt:initAddr for:nil identifyAs:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1027 |
didInit := true. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1028 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1029 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1030 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1031 |
] |
141 | 1032 |
]. |
1033 |
||
1034 |
didInit ifFalse:[ |
|
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1035 |
status == #noInitFunction ifTrue:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1036 |
msg := 'LOADER: no init function; assume load ok' |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1037 |
] ifFalse:[ |
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1038 |
|
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1039 |
status == #registrationFailed ifTrue:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1040 |
Transcript showCR:'LOADER:incompatible object (recompile without commonSymbols ?)' |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1041 |
]. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1042 |
status ~~ #initFailed ifTrue:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1043 |
self listUndefinedSymbolsIn:handle. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1044 |
]. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1045 |
|
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1046 |
Verbose ifTrue:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1047 |
'unloading, since init failed ...' infoPrintCR. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1048 |
]. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1049 |
self unloadDynamicObject:handle. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1050 |
handle := nil. |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1051 |
|
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1052 |
status == #initFailed ifTrue:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1053 |
msg := 'LOADER: module not loaded (init function signalled failure).' |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1054 |
] ifFalse:[ |
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1055 |
(self namesMatching:'*__sepInitCode__*' segment:'[tT]' in:aFileName) notNil ifTrue:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1056 |
msg := 'LOADER: module not loaded (no _Init entry - looks like an incomplete sepInitCode object).' |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1057 |
] ifFalse:[ |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1058 |
msg := 'LOADER: module not loaded (no _Init entry in object file ?).' |
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1059 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1060 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1061 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1062 |
Transcript showCR:msg |
141 | 1063 |
]. |
1064 |
||
471
508fa84cb122
no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents:
470
diff
changeset
|
1065 |
isCModule ifFalse:[ |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1066 |
Smalltalk isInitialized ifTrue:[ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1067 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1068 |
really dont know, if it has changed ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1069 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1070 |
Smalltalk changed. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1071 |
] |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
1072 |
]. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1073 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1074 |
|
472 | 1075 |
"Modified: 8.1.1997 / 18:28:12 / cg" |
141 | 1076 |
! |
1077 |
||
1078 |
unloadAllObsoleteObjectFiles |
|
1079 |
"unload all dynamically loaded object files for which the classes/method |
|
1080 |
has been already garbage collected." |
|
1081 |
||
1082 |
LoadedObjects notNil ifTrue:[ |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1083 |
LoadedObjects keys copy do:[:name | |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1084 |
|handle| |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1085 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1086 |
handle := LoadedObjects at:name ifAbsent:nil. |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1087 |
(handle notNil and:[handle isObsolete]) ifTrue:[ |
141 | 1088 |
self unloadObjectFile:name |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1089 |
] |
141 | 1090 |
] |
1091 |
]. |
|
1092 |
||
1093 |
" |
|
1094 |
ObjectFileLoader unloadAllObsoleteObjectFiles |
|
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1095 |
" |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1096 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
149
diff
changeset
|
1097 |
"Modified: 5.12.1995 / 18:16:52 / cg" |
134
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1098 |
! |
d93682ca90a1
more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents:
130
diff
changeset
|
1099 |
|
141 | 1100 |
unloadObjectFile:aFileName |
1101 |
"unload an object file (.o-file) from the image. |
|
1102 |
DANGER ALERT: currently, you have to make sure that no references to |
|
1103 |
objects of this module exist - in future versions, the system will keep |
|
1104 |
track of these. For now, use at your own risk. |
|
1105 |
(especially critical are blocks-functions)." |
|
1106 |
||
1107 |
|handle| |
|
1108 |
||
1109 |
LoadedObjects notNil ifTrue:[ |
|
153 | 1110 |
handle := LoadedObjects at:aFileName ifAbsent:nil |
141 | 1111 |
]. |
1112 |
handle isNil ifTrue:[ |
|
153 | 1113 |
'OBJFLOADER: oops file to be unloaded was not loaded dynamically (', aFileName , ')'. |
141 | 1114 |
^ self |
1115 |
]. |
|
1116 |
||
1117 |
"/ call the modules deInit-function ... |
|
1118 |
||
1119 |
"/ unload ... |
|
1120 |
||
1121 |
self unloadDynamicObject:handle |
|
1122 |
! ! |
|
1123 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
1124 |
!ObjectFileLoader class methodsFor:'dynamic object queries'! |
141 | 1125 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1126 |
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
|
1127 |
"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
|
1128 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1129 |
|initAddr className| |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1130 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1131 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1132 |
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
|
1133 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1134 |
initAddr := self getFunction:(functionName , suffix) from:handle. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1135 |
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
|
1136 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1137 |
initAddr := self getFunction:('_' , functionName , suffix) from:handle. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1138 |
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
|
1139 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1140 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1141 |
"/ special for broken ultrix nlist |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1142 |
"/ (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
|
1143 |
"/ 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
|
1144 |
"/ |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1145 |
initAddr := self getFunction:('__' , functionName , suffix) from:handle. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1146 |
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
|
1147 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1148 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1149 |
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
|
1150 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1151 |
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
|
1152 |
className notNil ifTrue:[ |
514 | 1153 |
initAddr := self getFunction:(className , suffix) from:handle. |
1154 |
initAddr notNil ifTrue:[^ initAddr]. |
|
1155 |
||
1156 |
initAddr := self getFunction:('_' , className , suffix) from:handle. |
|
1157 |
initAddr isNil ifTrue:[ |
|
1158 |
"/ |
|
1159 |
"/ special for broken ultrix nlist |
|
1160 |
"/ (will not find symbol with single underscore) |
|
1161 |
"/ workaround: add another underscore and retry |
|
1162 |
"/ |
|
1163 |
initAddr := self getFunction:('__' , className , suffix) from:handle. |
|
1164 |
]. |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1165 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1166 |
^ initAddr |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1167 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1168 |
"Created: 13.7.1996 / 00:38:01 / cg" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1169 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1170 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1171 |
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
|
1172 |
"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
|
1173 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1174 |
^ 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
|
1175 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1176 |
"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
|
1177 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1178 |
|
141 | 1179 |
getFunction:aString from:handle |
1180 |
"return the address of a function from a dynamically loaded object file. |
|
1181 |
Handle must be the one returned previously from loadDynamicObject. |
|
1182 |
Return the address of the function, or nil on any error." |
|
1183 |
||
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1184 |
^ self getSymbol:aString function:true from:handle |
141 | 1185 |
! |
1186 |
||
1187 |
getListOfUndefinedSymbolsFrom:aHandle |
|
1188 |
"return a collection of undefined symbols in a dynamically loaded object file. |
|
1189 |
Handle must be the one returned previously from loadDynamicObject. |
|
1190 |
Not all systems allow an object with undefined symbols to be |
|
1191 |
loaded (actually, only dld does)." |
|
1192 |
||
1193 |
|list| |
|
1194 |
||
1195 |
%{ /* STACK: 20000 */ |
|
1196 |
#ifdef GNU_DL |
|
1197 |
void (*func)(); |
|
1198 |
unsigned long addr; |
|
1199 |
char *name; |
|
1200 |
int nMax; |
|
1201 |
char **undefNames; |
|
1202 |
||
1203 |
undefNames = dld_list_undefined_sym(); |
|
1204 |
if (dld_undefined_sym_count > 0) { |
|
1205 |
char **nm; |
|
1206 |
int index; |
|
1207 |
int count = dld_undefined_sym_count; |
|
1208 |
||
1209 |
if (count > 100) count = 100; |
|
1210 |
list = __ARRAY_NEW_INT(count); |
|
1211 |
if (list) { |
|
1212 |
nm = undefNames; |
|
1213 |
for (index = 0; index < count; index++) { |
|
1214 |
OBJ s; |
|
1215 |
||
238 | 1216 |
s = __MKSTRING(*nm); |
1217 |
__ArrayInstPtr(list)->a_element[index] = s; |
|
141 | 1218 |
__STORE(list, s); |
1219 |
nm++; |
|
1220 |
} |
|
1221 |
free(undefNames); |
|
1222 |
} |
|
1223 |
} |
|
1224 |
#endif |
|
1225 |
||
1226 |
#ifdef DL1_6 |
|
1227 |
/* |
|
1228 |
* dont know how to do it |
|
1229 |
*/ |
|
1230 |
#endif |
|
1231 |
||
1232 |
#ifdef SYSV4_DL |
|
1233 |
/* |
|
1234 |
* dont know how to do it |
|
1235 |
*/ |
|
1236 |
#endif |
|
1237 |
||
1238 |
#ifdef SUN_DL |
|
1239 |
/* |
|
1240 |
* dont know how to do it |
|
1241 |
*/ |
|
1242 |
#endif |
|
1243 |
||
1244 |
#ifdef NEXT_DL |
|
1245 |
/* |
|
1246 |
* dont know how to do it |
|
1247 |
*/ |
|
1248 |
#endif |
|
180 | 1249 |
|
1250 |
#ifdef WIN_DL |
|
1251 |
/* |
|
1252 |
* dont know how to do it |
|
1253 |
*/ |
|
1254 |
#endif |
|
1255 |
||
141 | 1256 |
%}. |
1257 |
^ list |
|
1258 |
! |
|
1259 |
||
1260 |
getSymbol:aString function:isFunction from:aHandle |
|
1261 |
"return the address of a symbol/function from a dynamically loaded object file. |
|
1262 |
Handle must be the one returned previously from loadDynamicObject. |
|
1263 |
Return the address of the symbol, or nil on any error." |
|
1264 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1265 |
|sysHandle1 sysHandle2 pathName address| |
141 | 1266 |
|
1267 |
sysHandle1 := aHandle sysHandle1. |
|
1268 |
sysHandle2 := aHandle sysHandle2. |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1269 |
pathName := aHandle pathName. |
141 | 1270 |
|
1271 |
%{ /* STACK: 20000 */ |
|
1272 |
||
1273 |
#ifdef GNU_DL |
|
1274 |
{ |
|
1275 |
void (*func)(); |
|
1276 |
unsigned long addr; |
|
1277 |
char *name; |
|
1278 |
||
1279 |
if (__isString(aString)) { |
|
1280 |
name = (char *) __stringVal(aString); |
|
1281 |
if (isFunction == false) { |
|
1282 |
addr = dld_get_symbol(name); |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1283 |
if (addr) { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1284 |
if (ObjectFileLoader_Verbose == true) { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1285 |
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
|
1286 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1287 |
address = __MKUINT( addr ); |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1288 |
} |
141 | 1289 |
} else { |
1290 |
func = (void (*) ()) dld_get_func(name); |
|
1291 |
if (func) { |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1292 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1293 |
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
|
1294 |
} |
141 | 1295 |
if (dld_function_executable_p(name)) { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1296 |
address = __MKUINT( (INT)func ); |
141 | 1297 |
} else { |
1298 |
char **undefNames; |
|
1299 |
char **nm; |
|
1300 |
int i; |
|
1301 |
||
1302 |
if (ObjectFileLoader_Verbose == true) { |
|
1303 |
printf ("function %s not executable\n", name); |
|
1304 |
dld_perror("not executable"); |
|
1305 |
||
1306 |
printf("undefined:\n"); |
|
1307 |
nm = undefNames = dld_list_undefined_sym(); |
|
1308 |
for (i=dld_undefined_sym_count; i; i--) { |
|
1309 |
printf(" %s\n", *nm++); |
|
1310 |
} |
|
1311 |
free(undefNames); |
|
1312 |
} |
|
1313 |
} |
|
1314 |
} else { |
|
1315 |
if (ObjectFileLoader_Verbose == true) { |
|
1316 |
printf ("function %s not found\n", name); |
|
1317 |
dld_perror("get_func"); |
|
1318 |
} |
|
1319 |
} |
|
1320 |
} |
|
1321 |
} |
|
1322 |
} |
|
1323 |
#endif /* GNU_DL */ |
|
1324 |
||
180 | 1325 |
#ifdef WIN_DL |
1326 |
{ |
|
1327 |
void *h; |
|
1328 |
void *addr; |
|
1329 |
int val; |
|
1330 |
FARPROC entry; |
|
1331 |
HMODULE handle; |
|
1332 |
||
1333 |
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
|
1334 |
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
|
1335 |
handle = (HMODULE)(val); |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1336 |
if (__isString(aString)) { |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1337 |
if (ObjectFileLoader_Verbose == true) |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1338 |
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
|
1339 |
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
|
1340 |
if (entry != NULL) { |
180 | 1341 |
addr = (void *)entry; |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1342 |
if (ObjectFileLoader_Verbose == true) { |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1343 |
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
|
1344 |
} |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1345 |
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
|
1346 |
} else { |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1347 |
if (ObjectFileLoader_Verbose == true) { |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1348 |
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
|
1349 |
} |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1350 |
} |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
1351 |
} |
180 | 1352 |
} |
1353 |
} |
|
1354 |
#endif |
|
1355 |
||
141 | 1356 |
#ifdef DL1_6 |
1357 |
{ |
|
1358 |
void *h; |
|
1359 |
void *addr; |
|
1360 |
int val; |
|
1361 |
||
1362 |
if (__isString(aString)) { |
|
1363 |
if (__isString(sysHandle1)) { |
|
1364 |
if (ObjectFileLoader_Verbose == true) |
|
1365 |
printf("get sym <%s> handle = %x\n", |
|
1366 |
__stringVal(aString), __stringVal(sysHandle1)); |
|
1367 |
addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString)); |
|
1368 |
if (addr) { |
|
1369 |
if (ObjectFileLoader_Verbose == true) |
|
1370 |
printf("addr = %x\n", addr); |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1371 |
address = __MKUINT( (int)addr ); |
141 | 1372 |
} else { |
1373 |
if (ObjectFileLoader_Verbose == true) |
|
1374 |
printf("dl_getsymbol %s failed\n", __stringVal(aString)); |
|
1375 |
} |
|
1376 |
} |
|
1377 |
} |
|
1378 |
} |
|
1379 |
#endif |
|
1380 |
||
1381 |
#ifdef SYSV4_DL |
|
1382 |
{ |
|
1383 |
void *h; |
|
1384 |
void *addr; |
|
1385 |
int val; |
|
1386 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
1387 |
||
1388 |
if (__bothSmallInteger(low, hi)) { |
|
1389 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
1390 |
h = (void *)(val); |
|
1391 |
if (__isString(aString)) { |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1392 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1393 |
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
|
1394 |
} |
141 | 1395 |
addr = dlsym(h, (char *) __stringVal(aString)); |
1396 |
if (addr) { |
|
1397 |
if (ObjectFileLoader_Verbose == true) { |
|
1398 |
printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr); |
|
1399 |
} |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1400 |
address = __MKUINT( (int)addr ); |
141 | 1401 |
} else { |
1402 |
if (ObjectFileLoader_Verbose == true) { |
|
1403 |
printf("dlsym %s error: %s\n", __stringVal(aString), dlerror()); |
|
1404 |
} |
|
1405 |
} |
|
1406 |
} |
|
1407 |
} |
|
1408 |
} |
|
1409 |
#endif |
|
1410 |
||
523 | 1411 |
#ifdef HPUX10_DL |
1412 |
{ |
|
1413 |
void *h; |
|
1414 |
void *addr; |
|
1415 |
int val, ret; |
|
1416 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
1417 |
||
1418 |
if (__bothSmallInteger(low, hi)) { |
|
1419 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
1420 |
h = (void *)(val); |
|
1421 |
if (__isString(aString)) { |
|
1422 |
if (ObjectFileLoader_Verbose == true) { |
|
1423 |
printf("get sym <%s> handle = %x\n", __stringVal(aString), h); |
|
1424 |
} |
|
1425 |
ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr); |
|
1426 |
if (ret != 0) { |
|
1427 |
if (ObjectFileLoader_Verbose == true) { |
|
1428 |
printf("dlsym %s error\n", __stringVal(aString)); |
|
1429 |
} |
|
1430 |
} else { |
|
1431 |
if (ObjectFileLoader_Verbose == true) { |
|
1432 |
printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr); |
|
1433 |
} |
|
1434 |
address = __MKUINT( (int)addr ); |
|
1435 |
} |
|
1436 |
} |
|
1437 |
} |
|
1438 |
} |
|
1439 |
#endif |
|
1440 |
||
1441 |
||
141 | 1442 |
#ifdef AIX_DL |
1443 |
{ |
|
1444 |
void *h; |
|
1445 |
void *addr; |
|
1446 |
int val; |
|
1447 |
struct nlist nl[2]; |
|
1448 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1449 |
char nameBuffer[256]; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1450 |
static struct funcDescriptor { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1451 |
unsigned vaddr; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1452 |
unsigned long2; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1453 |
unsigned long3; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1454 |
} descriptor; |
141 | 1455 |
|
1456 |
if (__bothSmallInteger(low, hi) |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1457 |
&& __isString(aString) && __isString(pathName)) { |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1458 |
val = (__intVal(hi) << 16) + __intVal(low); |
141 | 1459 |
h = (void *)(val); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1460 |
|
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1461 |
if (ObjectFileLoader_Verbose == true) { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1462 |
printf("get sym <%s> handle = %x path= %s\n", |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1463 |
__stringVal(aString), h, __stringVal(pathName)); |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1464 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1465 |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1466 |
#define USE_ENTRY |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1467 |
#ifdef USE_ENTRY |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1468 |
/* |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1469 |
* 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
|
1470 |
* (i.e. linked with -e _xxx_Init) |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1471 |
*/ |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1472 |
if (ObjectFileLoader_Verbose == true) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1473 |
printf("return handle as addr = %x\n", h); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1474 |
} |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1475 |
address = __MKUINT( (int)(h) ); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1476 |
#else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1477 |
|
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1478 |
# ifdef USE_DESCRIPTOR |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1479 |
if (isFunction == true) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1480 |
# else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1481 |
if (0) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1482 |
# endif |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1483 |
nameBuffer[0] = '.'; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1484 |
strcpy(nameBuffer+1, aString); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1485 |
nl[0].n_name = nameBuffer; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1486 |
} else { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1487 |
nl[0].n_name = __stringVal(aString); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1488 |
} |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1489 |
nl[1].n_name = ""; |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1490 |
|
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1491 |
if (nlist(__stringVal(pathName), &nl) == -1) { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1492 |
if (ObjectFileLoader_Verbose == true) { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1493 |
printf("nlist error\n"); |
141 | 1494 |
} |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1495 |
} else { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1496 |
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
|
1497 |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1498 |
if (isFunction == true) { |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1499 |
# ifdef USE_DESCRIPTOR |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1500 |
printf("daddr = %x\n", addr); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1501 |
printf("daddr[0] = %x\n", ((long *)addr)[0]); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1502 |
printf("daddr[1] = %x\n", ((long *)addr)[1]); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1503 |
printf("daddr[2] = %x\n", ((long *)addr)[2]); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1504 |
# endif |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1505 |
} |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1506 |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1507 |
if (ObjectFileLoader_Verbose == true) { |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1508 |
printf("value=%x section=%d type=%x sclass=%d\n", |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1509 |
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
|
1510 |
printf("vaddr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1511 |
} |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1512 |
# ifdef DOES_NOT_WORK |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1513 |
address = __MKUINT( (int)addr ); |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1514 |
# else |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1515 |
descriptor.vaddr = (unsigned) addr; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1516 |
descriptor.long2 = 0; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1517 |
descriptor.long3 = 0; |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1518 |
address = __MKUINT( (int)(&descriptor) ); |
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1519 |
# endif |
141 | 1520 |
} |
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1521 |
#endif /* dont USE_ENTRY */ |
141 | 1522 |
} |
1523 |
} |
|
321
9428bae4c62e
dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
1524 |
#endif /* AIX_DL */ |
141 | 1525 |
|
523 | 1526 |
|
141 | 1527 |
#ifdef SUN_DL |
1528 |
{ |
|
1529 |
void *h; |
|
1530 |
void *addr; |
|
1531 |
int val; |
|
1532 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
1533 |
||
1534 |
if (__bothSmallInteger(low, hi)) { |
|
1535 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
1536 |
h = (void *)(val); |
|
1537 |
if (__isString(aString)) { |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1538 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1539 |
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
|
1540 |
} |
141 | 1541 |
addr = dlsym(h, __stringVal(aString)); |
1542 |
if (addr) { |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1543 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1544 |
printf("addr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1545 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1546 |
address = __MKUINT( (int)addr ); |
141 | 1547 |
} else { |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1548 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1549 |
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
|
1550 |
} |
141 | 1551 |
} |
1552 |
} |
|
1553 |
} |
|
1554 |
} |
|
1555 |
#endif |
|
1556 |
||
523 | 1557 |
|
141 | 1558 |
#ifdef NEXT_DL |
1559 |
{ |
|
1560 |
unsigned long addr; |
|
1561 |
long result; |
|
1562 |
NXStream *errOut; |
|
1563 |
||
1564 |
if (__isString(aString)) { |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1565 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1566 |
printf("get sym <%s>\n", __stringVal(aString)); |
468 | 1567 |
} |
141 | 1568 |
errOut = NXOpenFile(2, 2); |
1569 |
result = rld_lookup(errOut, |
|
1570 |
(char *) __stringVal(aString), |
|
1571 |
&addr); |
|
1572 |
NXClose(errOut); |
|
1573 |
if (result) { |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1574 |
if (ObjectFileLoader_Verbose == true) { |
141 | 1575 |
printf("addr = %x\n", addr); |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1576 |
} |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1577 |
address = __MKUINT( (int)addr ); |
141 | 1578 |
} |
1579 |
} |
|
1580 |
} |
|
1581 |
#endif |
|
180 | 1582 |
|
141 | 1583 |
%}. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
1584 |
^ address |
141 | 1585 |
! |
1586 |
||
1587 |
hasUndefinedSymbolsIn:handle |
|
259 | 1588 |
"return true, if a module has undefined symbols in it. |
1589 |
This is only possible if the system supports loading |
|
1590 |
modules with undefined things in it - most do not" |
|
1591 |
||
141 | 1592 |
^ (self getListOfUndefinedSymbolsFrom:handle) size > 0 |
259 | 1593 |
|
1594 |
"Modified: 25.4.1996 / 09:47:27 / cg" |
|
141 | 1595 |
! |
1596 |
||
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1597 |
initFunctionBasenameForFile:aFileName |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1598 |
"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
|
1599 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1600 |
|name suffixLen| |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1601 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1602 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1603 |
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
|
1604 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1605 |
name := OperatingSystem baseNameOf:aFileName. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1606 |
suffixLen := 0. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1607 |
self validBinaryExtensions do:[:suffix | |
514 | 1608 |
suffixLen == 0 ifTrue:[ |
1609 |
(name endsWith:suffix) ifTrue:[ |
|
1610 |
suffixLen := suffix size |
|
1611 |
] |
|
1612 |
] |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1613 |
]. |
403 | 1614 |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1615 |
suffixLen ~~ 0 ifTrue:[ |
514 | 1616 |
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
|
1617 |
]. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1618 |
^ name. |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1619 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1620 |
" |
514 | 1621 |
ObjectFileLoader initFunctionBasenameForFile:'libbasic.so' |
1622 |
ObjectFileLoader initFunctionBasenameForFile:'demo.so' |
|
1623 |
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
|
1624 |
" |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1625 |
|
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1626 |
"Created: 13.7.1996 / 00:01:54 / cg" |
403 | 1627 |
"Modified: 30.10.1996 / 13:28:22 / cg" |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1628 |
! |
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
1629 |
|
141 | 1630 |
isCPlusPlusObject:handle |
259 | 1631 |
"return true, if the loaded object is a c++ object module. |
1632 |
This is not yet fully implemented/supported." |
|
141 | 1633 |
|
1634 |
(self getSymbol:'__gnu_compiled_cplusplus' function:true from:handle) notNil ifTrue:[^ true]. |
|
1635 |
(self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true]. |
|
1636 |
(self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true]. |
|
1637 |
(self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true]. |
|
6 | 1638 |
^ false |
259 | 1639 |
|
1640 |
"Modified: 25.4.1996 / 09:48:19 / cg" |
|
0 | 1641 |
! |
1642 |
||
141 | 1643 |
isObjectiveCObject:handle |
259 | 1644 |
"return true, if the loaded object is an objective-C object module. |
1645 |
This is not yet implemented/supported" |
|
141 | 1646 |
|
1647 |
^ false |
|
259 | 1648 |
|
1649 |
"Modified: 25.4.1996 / 09:47:59 / cg" |
|
141 | 1650 |
! |
1651 |
||
1652 |
isSmalltalkObject:handle |
|
1653 |
"return true, if the loaded object is a smalltalk object module" |
|
1654 |
||
1655 |
"not yet implemented - stc_compiled_smalltalk is a static symbol, |
|
1656 |
not found in list - need nm-interface, or nlist-walker |
|
1657 |
" |
|
1658 |
^ true. |
|
1659 |
||
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
1660 |
"/ (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
|
1661 |
"/ (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
|
1662 |
"/ ^ false |
141 | 1663 |
! |
1664 |
||
1665 |
listUndefinedSymbolsIn:handle |
|
259 | 1666 |
"list undefined objects in a module on the transcript" |
1667 |
||
141 | 1668 |
|undefinedNames| |
1669 |
||
1670 |
undefinedNames := self getListOfUndefinedSymbolsFrom:handle. |
|
1671 |
undefinedNames size > 0 ifTrue:[ |
|
468 | 1672 |
Transcript showCR:'undefined:'. |
1673 |
undefinedNames do:[:aName | |
|
1674 |
Transcript showCR:' ' , aName |
|
1675 |
] |
|
141 | 1676 |
]. |
259 | 1677 |
|
272 | 1678 |
"Modified: 18.5.1996 / 15:43:45 / cg" |
141 | 1679 |
! |
1680 |
||
1681 |
namesMatching:aPattern segment:segmentPattern in:aFileName |
|
521 | 1682 |
"search for entries which match a pattern. |
1683 |
This is obsolete & rubbish - it will vanish soon" |
|
141 | 1684 |
|
1685 |
|p l s addr segment name entry| |
|
1686 |
||
521 | 1687 |
OperatingSystem getOSType = 'aix' ifTrue:[ |
474 | 1688 |
^ nil |
141 | 1689 |
]. |
1690 |
||
1691 |
l := OrderedCollection new. |
|
1692 |
p := PipeStream readingFrom:(self nm:aFileName). |
|
1693 |
p isNil ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1694 |
('ObjectFileLoader [info]: cannot read names from ' , aFileName) infoPrintCR. |
474 | 1695 |
^ nil |
141 | 1696 |
]. |
1697 |
[p atEnd] whileFalse:[ |
|
474 | 1698 |
entry := p nextLine. |
1699 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1700 |
entry infoPrintCR. |
474 | 1701 |
]. |
1702 |
entry notNil ifTrue:[ |
|
1703 |
s := ReadStream on:entry. |
|
1704 |
addr := s nextAlphaNumericWord. |
|
1705 |
segment := s nextAlphaNumericWord. |
|
1706 |
name := s upToEnd withoutSeparators. |
|
1707 |
(addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[ |
|
1708 |
(aPattern match:name) ifTrue:[ |
|
1709 |
(segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[ |
|
1710 |
l add:name. |
|
1711 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1712 |
('found name: ' , name) infoPrintCR. |
474 | 1713 |
] |
1714 |
] ifFalse:[ |
|
1715 |
Verbose ifTrue:[ |
|
1716 |
name infoPrint. ' segment mismatch ' infoPrint. |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1717 |
segmentPattern infoPrint. ' ' infoPrint. segment infoPrintCR. |
474 | 1718 |
] |
1719 |
] |
|
1720 |
] |
|
1721 |
] |
|
1722 |
] |
|
0 | 1723 |
]. |
141 | 1724 |
p close. |
1725 |
^ l |
|
225 | 1726 |
|
521 | 1727 |
"Modified: 2.5.1997 / 12:32:09 / cg" |
141 | 1728 |
! |
1729 |
||
1730 |
releaseSymbolTable |
|
1731 |
"this is needed on NeXT to forget loaded names. If this wasnt done, |
|
1732 |
the same class could not be loaded in again due to multiple defines. |
|
1733 |
On other architectures, this is not needed and therefore a noop." |
|
1734 |
||
1735 |
%{ |
|
1736 |
#ifdef NEXT_DL |
|
1737 |
NXStream *errOut; |
|
1738 |
||
1739 |
errOut = NXOpenFile(2, 2); |
|
1740 |
rld_unload_all(errOut, (long)0); |
|
1741 |
rld_load_basefile(errOut, "smalltalk"); |
|
1742 |
NXClose(errOut); |
|
1743 |
#endif |
|
1744 |
%} |
|
303 | 1745 |
! ! |
1746 |
||
369 | 1747 |
!ObjectFileLoader class methodsFor:'image save/restart'! |
303 | 1748 |
|
1749 |
invalidateAndRememberAllObjectFiles |
|
1750 |
"invalidate code refs into all dynamically loaded object files. |
|
1751 |
Required before writing a snapshot image." |
|
1752 |
||
1753 |
LoadedObjects notNil ifTrue:[ |
|
468 | 1754 |
ActuallyLoadedObjects := LoadedObjects. |
1755 |
self rememberAllObjectFiles. |
|
1756 |
ActuallyLoadedObjects keys do:[:aFileName | |
|
1757 |
|handle| |
|
1758 |
||
1759 |
handle := ActuallyLoadedObjects at:aFileName. |
|
1760 |
handle isNil ifTrue:[ |
|
1761 |
self error:'oops, no handle'. |
|
1762 |
] ifFalse:[ |
|
1763 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
1764 |
self invalidateModule:handle |
|
1765 |
] |
|
1766 |
] |
|
1767 |
]. |
|
1768 |
LoadedObjects := nil. |
|
303 | 1769 |
]. |
1770 |
||
1771 |
"Created: 5.10.1995 / 15:48:56 / claus" |
|
1772 |
"Modified: 5.10.1995 / 16:48:51 / claus" |
|
1773 |
"Modified: 12.7.1996 / 17:13:45 / cg" |
|
28 | 1774 |
! |
6 | 1775 |
|
303 | 1776 |
reloadAllRememberedObjectFiles |
1777 |
"reload all object modules as were loaded when the image was saved. |
|
1778 |
Some care has to be taken, if files are missing or otherwise corrupted." |
|
1779 |
||
406
6a4f1e3800af
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
405
diff
changeset
|
1780 |
|oldDummyMethod who m newHandle |
303 | 1781 |
savedOldClasses savedByteCodeMethods savedMethods |
1782 |
functions newFunction| |
|
1783 |
||
1784 |
PreviouslyLoadedObjects notNil ifTrue:[ |
|
474 | 1785 |
PreviouslyLoadedObjects do:[:entry | |
1786 |
|fileName handle cls sel| |
|
1787 |
||
1788 |
fileName := entry key. |
|
1789 |
handle := entry value. |
|
1790 |
handle moduleID:nil. |
|
1791 |
||
1792 |
handle isClassLibHandle ifTrue:[ |
|
1793 |
('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR. |
|
1794 |
||
1795 |
"/ |
|
1796 |
"/ remember all byteCode methods (as added in the session) |
|
1797 |
"/ |
|
1798 |
savedByteCodeMethods := IdentityDictionary new. |
|
1799 |
savedOldClasses := IdentitySet new. |
|
1800 |
||
1801 |
handle classes do:[:aClass | |
|
1802 |
savedMethods := IdentityDictionary new. |
|
1803 |
savedOldClasses add:aClass. |
|
1804 |
aClass methodDictionary keysAndValuesDo:[:sel :m | |
|
1805 |
m byteCode notNil ifTrue:[ |
|
1806 |
"/ an interpreted method - must be preserved |
|
1807 |
savedMethods at:sel put:m |
|
1808 |
] |
|
1809 |
]. |
|
1810 |
savedMethods notEmpty ifTrue:[ |
|
1811 |
savedByteCodeMethods at:(aClass name) put:savedMethods |
|
1812 |
]. |
|
1813 |
]. |
|
1814 |
"/ |
|
1815 |
"/ load the class binary |
|
1816 |
"/ |
|
1817 |
self loadObjectFile:fileName. |
|
1818 |
||
1819 |
"/ |
|
1820 |
"/ reinstall the byteCode methods |
|
1821 |
"/ |
|
1822 |
savedByteCodeMethods keysAndValuesDo:[:nm :savedMethods | |
|
1823 |
|cls| |
|
1824 |
||
1825 |
cls := Smalltalk classNamed:nm. |
|
1826 |
savedMethods keysAndValuesDo:[:sel :m | |
|
1827 |
cls primAddSelector:sel withMethod:m. |
|
1828 |
"/ ('preserved ' , cls name , '>>' , sel) printCR. |
|
1829 |
] |
|
1830 |
]. |
|
1831 |
||
1832 |
"/ |
|
1833 |
"/ validate old-classes vs. new classes. |
|
1834 |
"/ and if things look ok, get rid of old stuff |
|
1835 |
"/ and make instances become instances of the new class |
|
1836 |
"/ |
|
1837 |
savedOldClasses do:[:oldClass | |
|
1838 |
|newClass| |
|
1839 |
||
1840 |
newClass := Smalltalk classNamed:(oldClass name). |
|
1841 |
newClass == oldClass ifTrue:[ |
|
1842 |
"/ ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR. |
|
1843 |
] ifFalse:[ |
|
1844 |
(newClass isNil or:[newClass == oldClass]) ifTrue:[ |
|
1845 |
('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR. |
|
1846 |
] ifFalse:[ |
|
303 | 1847 |
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print. |
1848 |
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR. |
|
1849 |
||
474 | 1850 |
oldClass instSize ~~ newClass instSize ifTrue:[ |
1851 |
('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR. |
|
1852 |
] ifFalse:[ |
|
1853 |
oldClass class instSize ~~ newClass class instSize ifTrue:[ |
|
1854 |
('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR. |
|
1855 |
] ifFalse:[ |
|
1856 |
('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR. |
|
1857 |
oldClass becomeSameAs:newClass |
|
1858 |
] |
|
1859 |
] |
|
1860 |
] |
|
1861 |
] |
|
1862 |
] |
|
1863 |
||
1864 |
] ifFalse:[ |
|
1865 |
handle isMethodHandle ifTrue:[ |
|
1866 |
oldDummyMethod := handle method. |
|
1867 |
(oldDummyMethod isKindOf:Method) ifFalse:[ |
|
1868 |
('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR |
|
1869 |
] ifTrue:[ |
|
1870 |
('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR. |
|
1871 |
who := oldDummyMethod who. |
|
1872 |
newHandle := self loadMethodObjectFile:fileName. |
|
1873 |
newHandle isNil ifTrue:[ |
|
1874 |
('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR. |
|
1875 |
handle moduleID:nil. |
|
1876 |
] ifFalse:[ |
|
1877 |
m := newHandle method. |
|
1878 |
m source:(oldDummyMethod source). |
|
1879 |
m package:(oldDummyMethod package). |
|
1880 |
who notNil ifTrue:[ |
|
1881 |
cls := who methodClass. |
|
1882 |
sel := who methodSelector. |
|
1883 |
m == (cls compiledMethodAt:sel) ifFalse:[ |
|
1884 |
'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR. |
|
1885 |
] ifTrue:[ |
|
303 | 1886 |
"/ cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod). |
474 | 1887 |
] |
1888 |
]. |
|
1889 |
] |
|
1890 |
] |
|
1891 |
] ifFalse:[ |
|
1892 |
handle isFunctionObjectHandle ifTrue:[ |
|
1893 |
functions := handle functions. |
|
1894 |
functions isEmpty ifTrue:[ |
|
1895 |
('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR |
|
1896 |
] ifFalse:[ |
|
1897 |
newHandle := self loadDynamicObject:fileName. |
|
1898 |
newHandle isNil ifTrue:[ |
|
1899 |
('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR. |
|
1900 |
handle moduleID:nil. |
|
1901 |
] ifFalse:[ |
|
1902 |
('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR. |
|
1903 |
functions do:[:oldFunction | |
|
1904 |
newFunction := newHandle getFunction:(oldFunction name). |
|
1905 |
newFunction isNil ifTrue:[ |
|
1906 |
('ObjectFileLoader [info]: function: ''' , oldFunction name , ''' no longer present.') errorPrintCR. |
|
1907 |
oldFunction code:nil. |
|
1908 |
oldFunction setName:oldFunction name moduleHandle:nil. |
|
1909 |
] ifFalse:[ |
|
1910 |
oldFunction code:(newFunction code). |
|
1911 |
oldFunction setName:oldFunction name moduleHandle:newHandle. |
|
1912 |
('ObjectFileLoader [info]: rebound function: ''' , oldFunction name , '''.') infoPrintCR. |
|
1913 |
] |
|
1914 |
]. |
|
1915 |
handle becomeSameAs:newHandle. "/ the old handle is now void |
|
1916 |
] |
|
1917 |
] |
|
1918 |
] ifFalse:[ |
|
1919 |
('ObjectFileLoader [info]: ignored invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR. |
|
1920 |
] |
|
1921 |
] |
|
1922 |
] |
|
1923 |
]. |
|
1924 |
PreviouslyLoadedObjects := nil |
|
303 | 1925 |
] |
1926 |
||
474 | 1927 |
"Modified: 10.1.1997 / 15:06:07 / cg" |
303 | 1928 |
! |
1929 |
||
1930 |
rememberAllObjectFiles |
|
1931 |
"remember all loaded objectModules in the |
|
1932 |
PreviouslyLoadedObjects classVariable. |
|
1933 |
Called when an image is restarted to reload all modules which |
|
1934 |
were loaded in the previous life" |
|
1935 |
||
1936 |
LoadedObjects notNil ifTrue:[ |
|
474 | 1937 |
PreviouslyLoadedObjects := OrderedCollection new. |
1938 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
1939 |
handle isForCollectedObject ifTrue:[ |
|
1940 |
('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR |
|
1941 |
] ifFalse:[ |
|
1942 |
PreviouslyLoadedObjects add:(name -> handle) |
|
1943 |
] |
|
1944 |
]. |
|
1945 |
PreviouslyLoadedObjects sort:[:a :b | a value moduleID < b value moduleID]. |
|
303 | 1946 |
] |
1947 |
||
1948 |
"Created: 5.12.1995 / 20:51:07 / cg" |
|
474 | 1949 |
"Modified: 10.1.1997 / 15:06:25 / cg" |
303 | 1950 |
! |
1951 |
||
1952 |
revalidateAllObjectFiles |
|
1953 |
"revalidate code refs into all dynamically loaded object files. |
|
1954 |
Required after writing a snapshot image." |
|
1955 |
||
1956 |
ActuallyLoadedObjects notNil ifTrue:[ |
|
468 | 1957 |
ActuallyLoadedObjects keys do:[:aFileName | |
1958 |
|handle| |
|
1959 |
||
1960 |
handle := ActuallyLoadedObjects at:aFileName. |
|
1961 |
handle isNil ifTrue:[ |
|
1962 |
self error:'oops, no handle'. |
|
1963 |
] ifFalse:[ |
|
1964 |
(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[ |
|
1965 |
self revalidateModule:handle |
|
1966 |
] |
|
1967 |
] |
|
1968 |
]. |
|
1969 |
LoadedObjects := ActuallyLoadedObjects. |
|
1970 |
ActuallyLoadedObjects := PreviouslyLoadedObjects := nil. |
|
28 | 1971 |
]. |
141 | 1972 |
|
303 | 1973 |
"Created: 5.10.1995 / 15:49:08 / claus" |
1974 |
"Modified: 5.10.1995 / 16:49:18 / claus" |
|
1975 |
"Modified: 12.7.1996 / 17:14:48 / cg" |
|
1976 |
! |
|
1977 |
||
1978 |
unloadAllObjectFiles |
|
1979 |
"unload all dynamically loaded object files from the image. |
|
1980 |
see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:" |
|
1981 |
||
1982 |
LoadedObjects notNil ifTrue:[ |
|
1983 |
LoadedObjects keys copy do:[:aFileName | |
|
1984 |
self unloadObjectFile:aFileName |
|
1985 |
] |
|
1986 |
]. |
|
1987 |
||
1988 |
" |
|
1989 |
ObjectFileLoader unloadAllObjectFiles |
|
1990 |
" |
|
1991 |
! |
|
1992 |
||
1993 |
unloadAndRememberAllObjectFiles |
|
1994 |
"remember all modules and unload them" |
|
1995 |
||
1996 |
LoadedObjects notNil ifTrue:[ |
|
468 | 1997 |
self rememberAllObjectFiles. |
1998 |
self unloadAllObjectFiles |
|
303 | 1999 |
] |
2000 |
||
2001 |
"Modified: 25.4.1996 / 09:46:27 / cg" |
|
0 | 2002 |
! ! |
2003 |
||
369 | 2004 |
!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
|
2005 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2006 |
createLoadableObjectFor:baseFileName |
259 | 2007 |
"given an oFile, arrange for it to be loadable. |
2008 |
On ELF systems, this means that it has to be linked with the |
|
2009 |
-shared option into a .so file; |
|
2010 |
DLD based loaders (linux a.out) can directly load a .o file; |
|
2011 |
Other systems may require more ..." |
|
2012 |
||
513 | 2013 |
|osType oFileName soFileName expFileName librunExpFileName |
322
a844e84b16fd
on aix: create an exports file when loading modules
Claus Gittinger <cg@exept.de>
parents:
321
diff
changeset
|
2014 |
needSharedObject ld ldArg expFile| |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2015 |
|
324 | 2016 |
ld := 'ld'. |
188 | 2017 |
needSharedObject := false. |
513 | 2018 |
osType := OperatingSystem getOSType. |
2019 |
osType = 'irix' ifTrue:[ |
|
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2020 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2021 |
link it to a shared object with 'ld -shared' |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2022 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2023 |
needSharedObject := true. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2024 |
ldArg := '-shared'. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2025 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2026 |
|
513 | 2027 |
osType = 'sys5_4' ifTrue:[ |
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2028 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2029 |
link it to a shared object with 'ld -G' |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2030 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2031 |
needSharedObject := true. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2032 |
ldArg := '-G'. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2033 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2034 |
|
513 | 2035 |
osType = 'linux' ifTrue:[ |
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2036 |
ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[ |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2037 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2038 |
link it to a shared object with 'ld -shared' |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2039 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2040 |
needSharedObject := true. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2041 |
ldArg := '-shared'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2042 |
] |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2043 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2044 |
|
513 | 2045 |
osType = 'aix' ifTrue:[ |
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2046 |
"/ create an exports file. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2047 |
expFileName := './' , baseFileName , '.exp'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2048 |
|
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2049 |
expFile := expFileName asFilename writeStream. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2050 |
expFile notNil ifTrue:[ |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2051 |
expFile nextPutAll:'#!! ./' , baseFileName , '.so'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2052 |
expFile cr. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2053 |
expFile nextPutAll:'_' , baseFileName , '_Init'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2054 |
expFile close. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2055 |
]. |
322
a844e84b16fd
on aix: create an exports file when loading modules
Claus Gittinger <cg@exept.de>
parents:
321
diff
changeset
|
2056 |
|
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2057 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2058 |
link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE' |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2059 |
" |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2060 |
needSharedObject := true. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2061 |
ld := 'cc'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2062 |
librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2063 |
librunExpFileName isNil ifTrue:[ |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2064 |
LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2065 |
^ nil |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2066 |
]. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2067 |
|
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2068 |
ldArg := '-bI:' , librunExpFileName , |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2069 |
' -bE:' , baseFileName , '.exp' , |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2070 |
' -bM:SRE -e _' , baseFileName , '_Init'. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2071 |
]. |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2072 |
|
188 | 2073 |
oFileName := './' , baseFileName , '.o'. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2074 |
needSharedObject ifTrue:[ |
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2075 |
soFileName := './' , baseFileName , '.so'. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2076 |
OperatingSystem removeFile:soFileName. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2077 |
Verbose ifTrue:[ |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2078 |
'linking with:' infoPrintCR. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2079 |
' ' infoPrint. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2080 |
(ld , ' ' , ldArg , ' -o ' , soFileName , ' ' , oFileName) infoPrintCR. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2081 |
]. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2082 |
OperatingSystem executeCommand:ld , ' ' , ldArg , ' -o ' , soFileName , ' ' , oFileName. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2083 |
OperatingSystem removeFile:oFileName. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2084 |
expFileName notNil ifTrue:[ |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2085 |
OperatingSystem removeFile:expFileName |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2086 |
]. |
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2087 |
^ soFileName. |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2088 |
]. |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2089 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2090 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2091 |
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
|
2092 |
" |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2093 |
^ oFileName |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2094 |
|
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2095 |
"Created: 3.1.1996 / 16:04:45 / cg" |
322
a844e84b16fd
on aix: create an exports file when loading modules
Claus Gittinger <cg@exept.de>
parents:
321
diff
changeset
|
2096 |
"Modified: 29.7.1996 / 13:20:30 / cg" |
469
419b1cdea858
Use #removeFile: instead of executeCommand:'rm'.
Stefan Vogel <sv@exept.de>
parents:
468
diff
changeset
|
2097 |
"Modified: 7.1.1997 / 20:16:28 / stefan" |
182
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2098 |
! ! |
b8316f207380
added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents:
180
diff
changeset
|
2099 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2100 |
!ObjectFileLoader class methodsFor:'lowlevel object loading'! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2101 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2102 |
loadDynamicObject:pathName |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2103 |
"load an object-file (load/map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2104 |
Return a non-nil handle if ok, nil otherwise. |
472 | 2105 |
No bindings or automatic initializations are done |
2106 |
- only a pure (low-level) load is performed. |
|
2107 |
For class-files or C-objects to be loaded with this method, |
|
2108 |
it is your responsibility to fetch any init-functions and |
|
2109 |
call them as appropriate. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2110 |
This function is not supported on all architectures. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2111 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2112 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2113 |
|handle buffer| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2114 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2115 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2116 |
('loadDynamic: ' , pathName , ' ...') infoPrintCR |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2117 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2118 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2119 |
"/ already loaded ? |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2120 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2121 |
LoadedObjects notNil ifTrue:[ |
472 | 2122 |
handle := LoadedObjects at:pathName ifAbsent:nil. |
2123 |
handle notNil ifTrue:[ |
|
2124 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2125 |
('... ' , pathName , ' already loaded.') infoPrintCR. |
472 | 2126 |
]. |
2127 |
^ handle |
|
2128 |
]. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2129 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2130 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2131 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2132 |
"/ the 1st two entries are system dependent; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2133 |
"/ entry 3 is the pathName |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2134 |
"/ entry 4 is a unique ID |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2135 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2136 |
buffer := Array new:4. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2137 |
buffer at:3 put:pathName. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2138 |
buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2139 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2140 |
buffer := self primLoadDynamicObject:pathName into:buffer. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2141 |
buffer isNil ifTrue:[ |
472 | 2142 |
LastError == #notImplemented ifTrue:[ |
525 | 2143 |
'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR. |
2144 |
] ifFalse:[ |
|
472 | 2145 |
LastError == #linkError ifTrue:[ |
2146 |
LinkErrorMessage notNil ifTrue:[ |
|
525 | 2147 |
('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR. |
2148 |
] ifFalse:[ |
|
2149 |
('ObjectFileLoader [warning]: load error') infoPrintCR. |
|
2150 |
]. |
|
472 | 2151 |
]. |
2152 |
^ nil |
|
2153 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2154 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2155 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2156 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2157 |
remember loaded object for later unloading |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2158 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2159 |
handle := ObjectFileHandle new. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2160 |
handle sysHandle1:(buffer at:1). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2161 |
handle sysHandle2:(buffer at:2). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2162 |
handle pathName:(buffer at:3). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2163 |
handle moduleID:(buffer at:4). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2164 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2165 |
LoadedObjects isNil ifTrue:[ |
472 | 2166 |
LoadedObjects := Dictionary new. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2167 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2168 |
LoadedObjects at:pathName put:handle. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2169 |
Smalltalk flushCachedClasses. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2170 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2171 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2172 |
('loadDynamic ok; handle is: ' , handle printString) infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2173 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2174 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2175 |
^ handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2176 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2177 |
"sys5.4: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2178 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2179 |
handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2180 |
ObjectFileLoader getFunction:'module1' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2181 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2182 |
"next: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2183 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2184 |
handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2185 |
ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2186 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2187 |
"GLD: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2188 |
|handle| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2189 |
handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2190 |
ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2191 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2192 |
|
525 | 2193 |
"Modified: 16.5.1997 / 12:56:33 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2194 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2195 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2196 |
loadModulesFromListOfUndefined:list |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2197 |
"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
|
2198 |
return a list of handles of loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2199 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2200 |
|inits classNames| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2201 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2202 |
inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2203 |
inits notNil ifTrue:[ |
474 | 2204 |
classNames := inits collect:[:symbol | |
2205 |
(symbol startsWith:'___') ifTrue:[ |
|
2206 |
symbol copyFrom:4 to:(symbol size - 5) |
|
2207 |
] ifFalse:[ |
|
2208 |
(symbol startsWith:'__') ifTrue:[ |
|
2209 |
symbol copyFrom:3 to:(symbol size - 5) |
|
2210 |
] ifFalse:[ |
|
2211 |
(symbol startsWith:'_') ifTrue:[ |
|
2212 |
symbol copyFrom:2 to:(symbol size - 5) |
|
2213 |
] ifFalse:[ |
|
2214 |
symbol |
|
2215 |
] |
|
2216 |
] |
|
2217 |
] |
|
2218 |
]. |
|
2219 |
" |
|
2220 |
autoload those classes |
|
2221 |
" |
|
2222 |
classNames do:[:aClassName | |
|
2223 |
|cls| |
|
2224 |
||
2225 |
(cls := Smalltalk classNamed:aClassName) notNil ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2226 |
'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR. |
474 | 2227 |
cls autoload |
2228 |
] |
|
2229 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2230 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2231 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2232 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2233 |
"Modified: 10.1.1997 / 17:58:23 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2234 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2235 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2236 |
primLoadDynamicObject:pathName into:anInfoBuffer |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2237 |
"load an object-file (map into my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2238 |
Return an OS-handle (whatever that is) - where some space |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2239 |
(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
|
2240 |
The first two entries are used in a machine dependent way, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2241 |
and callers may not depend on what is found there |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2242 |
(instead, only pass around handles transparently). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2243 |
This function is not supported on all architectures." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2244 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2245 |
%{ /* CALLSUNLIMITEDSTACK */ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2246 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2247 |
if (! __isArray(anInfoBuffer) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2248 |
|| (_arraySize(anInfoBuffer) < 3)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2249 |
return nil; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2250 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2251 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2252 |
#ifdef GNU_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2253 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2254 |
static firstCall = 1; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2255 |
extern char *__myName__; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2256 |
extern dld_ignore_redefinitions; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2257 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2258 |
if (firstCall) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2259 |
firstCall = 0; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2260 |
(void) dld_init (__myName__); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2261 |
dld_ignore_redefinitions = 1; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2262 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2263 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2264 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2265 |
if (dld_link(__stringVal(pathName))) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2266 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2267 |
printf ("link file %s failed\n", __stringVal(pathName)); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2268 |
} |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2269 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2270 |
dld_perror("ObjectFileLoader - DLD error cant link"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2271 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2272 |
ObjectFileLoader_LastError = @symbol(linkError); |
524 | 2273 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING("DLD error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2274 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2275 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2276 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2277 |
__STORE(anInfoBuffer, pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2278 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2279 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2280 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2281 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2282 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2283 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2284 |
#ifdef WIN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2285 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2286 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2287 |
int err; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2288 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2289 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2290 |
if ((handle = LoadLibrary(__stringVal(pathName))) == NULL) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2291 |
err = GetLastError(); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2292 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2293 |
fprintf (stderr, "ObjectFileLoader: LoadLibrary %s failed; error: %x\n", |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2294 |
__stringVal(pathName), err); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2295 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2296 |
ObjectFileLoader_LastError = __MKINT(err); |
524 | 2297 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING("LoadLibrary error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2298 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2299 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2300 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2301 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2302 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2303 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2304 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2305 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2306 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2307 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2308 |
#ifdef DL1_6 |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2309 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2310 |
extern char *__myName__; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2311 |
char *ldname; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2312 |
OBJ tmpName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2313 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2314 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2315 |
if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2316 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2317 |
printf ("link file %s failed\n", __stringVal(pathName)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2318 |
} |
524 | 2319 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING("dl_load error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2320 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2321 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2322 |
/* |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2323 |
* returns the name of the temporary ld-file |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2324 |
* use that as handle ... |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2325 |
*/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2326 |
tmpName = __MKSTRING(ldname); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2327 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2328 |
__STORE(anInfoBuffer, tmpName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2329 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2330 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2331 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2332 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2333 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2334 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2335 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2336 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2337 |
extern char *__myName__; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2338 |
char *objName, *libPath; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2339 |
int *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2340 |
extern errno; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2341 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2342 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2343 |
objName = __stringVal(pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2344 |
|
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2345 |
if (__isString(ObjectFileLoader_LibPath)) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2346 |
libPath = __stringVal(ObjectFileLoader_LibPath); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2347 |
} else { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2348 |
libPath = (char *)0; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2349 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2350 |
if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2351 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2352 |
char *messages[64]; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2353 |
int i; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2354 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2355 |
printf ("load file %s failed errno=%d\n", |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2356 |
objName, errno); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2357 |
switch (errno) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2358 |
case ENOEXEC: |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2359 |
printf(" load messages:\n"); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2360 |
loadquery(L_GETMESSAGES, messages, sizeof(messages)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2361 |
for (i=0; messages[i]; i++) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2362 |
printf(" %s\n", messages[i]); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2363 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2364 |
break; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2365 |
} |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2366 |
} else { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2367 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2368 |
fprintf (stderr, "load file %s failed errno=%d\n", |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2369 |
objName, errno); |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2370 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2371 |
} |
524 | 2372 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING("load error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2373 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2374 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2375 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2376 |
printf("load %s handle = %x\n", objName, handle); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2377 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2378 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2379 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2380 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2381 |
RETURN (anInfoBuffer); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2382 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2383 |
RETURN ( nil ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2384 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2385 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2386 |
|
523 | 2387 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2388 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2389 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2390 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2391 |
char *nm; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2392 |
char *errMsg; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2393 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2394 |
if ((pathName == nil) || __isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2395 |
handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2396 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2397 |
if (! handle) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2398 |
errMsg = (char *) dlerror(); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2399 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2400 |
fprintf(stderr, "dlopen %s error:\n", __stringVal(pathName)); |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2401 |
fprintf(stderr, " <%s>\n", errMsg); |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2402 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2403 |
ObjectFileLoader_LastError = @symbol(linkError); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2404 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING(errMsg); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2405 |
RETURN (nil); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2406 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2407 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2408 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2409 |
printf("open %s handle = %x\n", __stringVal(pathName), handle); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2410 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2411 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2412 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2413 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2414 |
RETURN (anInfoBuffer); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2415 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2416 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2417 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2418 |
|
523 | 2419 |
|
2420 |
#ifdef HPUX10_DL |
|
2421 |
{ |
|
2422 |
void *handle; |
|
2423 |
char *nm; |
|
2424 |
char *errMsg; |
|
2425 |
||
2426 |
if (__isString(pathName)) { |
|
2427 |
handle = (void *)shl_load(__stringVal(pathName), |
|
2428 |
BIND_IMMEDIATE, 0L /* address */); |
|
2429 |
||
2430 |
if (! handle) { |
|
2431 |
if (@global(ErrorPrinting) == true) { |
|
2432 |
fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName)); |
|
2433 |
} |
|
524 | 2434 |
ObjectFileLoader_LastError = @symbol(linkError); |
2435 |
switch (errno) { |
|
2436 |
case ENOEXEC: |
|
2437 |
errMsg = "not a shared library"; |
|
2438 |
break; |
|
2439 |
case ENOSYM: |
|
2440 |
errMsg = "undefined symbols"; |
|
2441 |
break; |
|
2442 |
case ENOMEM: |
|
2443 |
errMsg = "out of memory"; |
|
2444 |
break; |
|
2445 |
case ENOENT: |
|
2446 |
errMsg = "non existing library"; |
|
2447 |
break; |
|
2448 |
case EACCES: |
|
2449 |
errMsg = "permission denied"; |
|
2450 |
break; |
|
2451 |
default: |
|
2452 |
errMsg = "unspecified error"; |
|
2453 |
break; |
|
2454 |
} |
|
2455 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING(errMsg); |
|
523 | 2456 |
RETURN (nil); |
2457 |
} |
|
2458 |
||
2459 |
if (ObjectFileLoader_Verbose == true) { |
|
2460 |
printf("open %s handle = %x\n", __stringVal(pathName), handle); |
|
2461 |
} |
|
2462 |
||
2463 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF); |
|
2464 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
|
2465 |
RETURN (anInfoBuffer); |
|
2466 |
} |
|
2467 |
} |
|
2468 |
#endif |
|
2469 |
||
2470 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2471 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2472 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2473 |
void *handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2474 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2475 |
if ((pathName == nil) || __isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2476 |
if (pathName == nil) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2477 |
handle = dlopen((char *)0, 1); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2478 |
else |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2479 |
handle = dlopen(__stringVal(pathName), 1); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2480 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2481 |
if (! handle) { |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2482 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2483 |
fprintf(stderr, "dlopen %s error: <%s>\n", |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2484 |
__stringVal(pathName), dlerror()); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2485 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2486 |
ObjectFileLoader_LastError = @symbol(linkError); |
524 | 2487 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING("dlopen error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2488 |
RETURN (nil); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2489 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2490 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2491 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2492 |
printf("open %s handle = %x\n", __stringVal(pathName), handle); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2493 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2494 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2495 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2496 |
__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2497 |
RETURN (anInfoBuffer); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2498 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2499 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2500 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2501 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2502 |
#ifdef NEXT_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2503 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2504 |
long result; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2505 |
char *files[2]; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2506 |
NXStream *errOut; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2507 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2508 |
if (__isString(pathName)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2509 |
files[0] = (char *) __stringVal(pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2510 |
files[1] = (char *) 0; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2511 |
errOut = NXOpenFile(2, 2); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2512 |
result = rld_load(errOut, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2513 |
(struct mach_header **)0, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2514 |
files, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2515 |
(char *)0); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2516 |
NXClose(errOut); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2517 |
if (! result) { |
524 | 2518 |
ObjectFileLoader_LinkErrorMessage = __MKSTRING("rld_load error"); |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2519 |
ObjectFileLoader_LastError = @symbol(linkError); |
515
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2520 |
if (@global(ErrorPrinting) == true) { |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2521 |
fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName)); |
cbc67d75d9ce
make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents:
514
diff
changeset
|
2522 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2523 |
RETURN (nil); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2524 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2525 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2526 |
if (ObjectFileLoader_Verbose == true) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2527 |
printf("rld_load %s ok\n", __stringVal(pathName)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2528 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2529 |
__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2530 |
__STORE(anInfoBuffer, pathName); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2531 |
RETURN ( anInfoBuffer ); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2532 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2533 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2534 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2535 |
%}. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2536 |
LastError := #notImplemented. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2537 |
^ nil |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2538 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2539 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2540 |
primUnloadDynamicObject:aHandle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2541 |
"unload an object-file (unmap from my address space). |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2542 |
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
|
2543 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2544 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2545 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2546 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2547 |
|sysHandle1 sysHandle2| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2548 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2549 |
sysHandle1 := aHandle sysHandle1. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2550 |
sysHandle2 := aHandle sysHandle2. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2551 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2552 |
%{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2553 |
#ifdef GNU_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2554 |
if (__isString(sysHandle1)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2555 |
if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2556 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2557 |
printf ("unlink file %s failed\n", __stringVal(sysHandle1)); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2558 |
dld_perror("cant unlink"); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2559 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2560 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2561 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2562 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2563 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2564 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2565 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2566 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2567 |
#ifdef WIN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2568 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2569 |
HINSTANCE handle; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2570 |
int err; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2571 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2572 |
if (__bothSmallInteger(sysHandle1, sysHandle2)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2573 |
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2574 |
handle = (HINSTANCE)(val); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2575 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2576 |
if (FreeLibrary(handle) != TRUE) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2577 |
err = GetLastError(); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2578 |
if (ObjectFileLoader_Verbose == true) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2579 |
printf ("unlink file %s failed; error: %x\n", |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2580 |
__stringVal(sysHandle1), err); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2581 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2582 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2583 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2584 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2585 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2586 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2587 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2588 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2589 |
#ifdef SYSV4_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2590 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2591 |
void *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2592 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2593 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2594 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2595 |
if (__bothSmallInteger(low, hi)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2596 |
val = (_intVal(hi) << 16) + _intVal(low); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2597 |
h = (void *)(val); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2598 |
if (ObjectFileLoader_Verbose == true) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2599 |
printf("close handle = %x\n", h); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2600 |
if (dlclose(h) != 0) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2601 |
fprintf(stderr, "dlclose failed with:<%s>\n", dlerror()); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2602 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2603 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2604 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2605 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2606 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2607 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2608 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2609 |
#ifdef SUN_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2610 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2611 |
void *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2612 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2613 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2614 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2615 |
if (__bothSmallInteger(low, hi)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2616 |
val = (_intVal(hi) << 16) + _intVal(low); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2617 |
h = (void *)(val); |
523 | 2618 |
if (ObjectFileLoader_Verbose == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2619 |
printf("close handle = %x\n", h); |
523 | 2620 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2621 |
dlclose(h); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2622 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2623 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2624 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2625 |
#endif |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2626 |
|
523 | 2627 |
#ifdef HPUX10_DL |
2628 |
{ |
|
2629 |
int *h; |
|
2630 |
int val; |
|
2631 |
OBJ low = sysHandle1, hi = sysHandle2; |
|
2632 |
||
2633 |
if (__bothSmallInteger(low, hi)) { |
|
2634 |
val = (_intVal(hi) << 16) + _intVal(low); |
|
2635 |
h = (void *)(val); |
|
2636 |
if (ObjectFileLoader_Verbose == true) { |
|
2637 |
printf("unload handle = %x\n", h); |
|
2638 |
} |
|
2639 |
shl_unload(h); |
|
2640 |
RETURN (true); |
|
2641 |
} |
|
2642 |
} |
|
2643 |
#endif |
|
2644 |
||
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2645 |
#ifdef AIX_DL |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2646 |
{ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2647 |
int *h; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2648 |
int val; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2649 |
OBJ low = sysHandle1, hi = sysHandle2; |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2650 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2651 |
if (__bothSmallInteger(low, hi)) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2652 |
val = (_intVal(hi) << 16) + _intVal(low); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2653 |
h = (int *)(val); |
523 | 2654 |
if (ObjectFileLoader_Verbose == true) { |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2655 |
printf("unload handle = %x\n", h); |
523 | 2656 |
} |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2657 |
if ( unload(h) != 0) { |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2658 |
fprintf(stderr, "unload failed\n"); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2659 |
RETURN (false); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2660 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2661 |
RETURN (true); |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2662 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2663 |
} |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2664 |
#endif |
529
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
2665 |
|
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
2666 |
#ifdef NEXT_DL |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
2667 |
{ |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
2668 |
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
|
2669 |
} |
039322479f26
NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents:
525
diff
changeset
|
2670 |
#endif |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2671 |
%}. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2672 |
^ false |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2673 |
! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2674 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2675 |
unloadDynamicObject:handle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2676 |
"close an object-file (unmap from my address space) |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2677 |
and remove the entry from the remembered object file set. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2678 |
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
|
2679 |
still any code references (from blocks or methods) to this |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2680 |
module. Calling it for still living classes will definitely |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2681 |
lead to some fatal conditions to occur later." |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2682 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2683 |
|key fileName functionName deInitAddr m| |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2684 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2685 |
Verbose ifTrue:[ |
474 | 2686 |
'unload module name=' infoPrint. handle pathName infoPrintCR. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2687 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2688 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2689 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2690 |
"/ fixup |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2691 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2692 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2693 |
handle isFunctionObjectHandle ifTrue:[ |
474 | 2694 |
handle functions do:[:f | |
2695 |
f notNil ifTrue:[ |
|
2696 |
f code:0 |
|
2697 |
] |
|
2698 |
]. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2699 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2700 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2701 |
(handle isClassLibHandle |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2702 |
or:[handle isMethodHandle]) ifTrue:[ |
474 | 2703 |
self deinitializeClassesFromModule:handle. |
2704 |
self unregisterModule:handle. |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2705 |
] ifFalse:[ |
474 | 2706 |
fileName := handle pathName asFilename baseName. |
2707 |
functionName := self initFunctionBasenameForFile:fileName. |
|
2708 |
||
2709 |
deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle. |
|
2710 |
deInitAddr notNil ifTrue:[ |
|
2711 |
self callInitFunctionAt:deInitAddr |
|
2712 |
specialInit:false |
|
2713 |
forceOld:true |
|
2714 |
interruptable:false |
|
2715 |
argument:0 |
|
2716 |
identifyAs:handle |
|
2717 |
returnsObject:false. |
|
2718 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2719 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2720 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2721 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2722 |
"/ now, really unload |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2723 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2724 |
(self primUnloadDynamicObject:handle) ifFalse:[ |
474 | 2725 |
^ self error:'unloadDynamic failed' |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2726 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2727 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2728 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2729 |
"/ remove from loaded objects |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2730 |
"/ |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2731 |
LoadedObjects notNil ifTrue:[ |
474 | 2732 |
key := LoadedObjects keyAtEqualValue:handle. |
2733 |
key notNil ifTrue:[ |
|
2734 |
LoadedObjects removeKey:key |
|
2735 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2736 |
]. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2737 |
Smalltalk flushCachedClasses. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2738 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2739 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2740 |
for individual methods, we keep the methodObject, |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2741 |
but make it unexecutable. Its still visible in the browser. |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2742 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2743 |
handle isMethodHandle ifTrue:[ |
474 | 2744 |
((m := handle method) notNil |
2745 |
and:[m ~~ 0]) ifTrue:[ |
|
2746 |
m makeUnloaded. |
|
2747 |
ObjectMemory flushCaches. |
|
2748 |
] |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2749 |
] |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2750 |
|
474 | 2751 |
"Modified: 10.1.1997 / 15:08:26 / cg" |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2752 |
! ! |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2753 |
|
369 | 2754 |
!ObjectFileLoader class methodsFor:'queries'! |
141 | 2755 |
|
2756 |
canLoadObjectFiles |
|
259 | 2757 |
"return true, if dynamic loading is possible. |
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2758 |
Currently, only ELF based systems, AIX and linux a.out can do this." |
141 | 2759 |
|
2760 |
self primCanLoadObjectFiles ifTrue:[^true]. |
|
2761 |
||
2762 |
"/ can add a return true here, if I ever get manual loading to work |
|
2763 |
"/ for some specific machine |
|
2764 |
^ false |
|
259 | 2765 |
|
470
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2766 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2767 |
ObjectFileLoader canLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2768 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2769 |
|
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2770 |
"Modified: 8.1.1997 / 18:13:01 / cg" |
141 | 2771 |
! |
2772 |
||
2773 |
loadedObjectFiles |
|
2774 |
"return a collection containing the names of all |
|
2775 |
dynamically loaded objects." |
|
2776 |
||
2777 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
2778 |
^ LoadedObjects keys copy |
|
2779 |
||
2780 |
" |
|
2781 |
ObjectFileLoader loadedObjectFiles |
|
2782 |
" |
|
2783 |
! |
|
2784 |
||
2785 |
loadedObjectHandles |
|
2786 |
"return a collection of all handles" |
|
2787 |
||
2788 |
LoadedObjects isNil ifTrue:[^ #()]. |
|
2789 |
^ LoadedObjects |
|
2790 |
||
2791 |
" |
|
2792 |
ObjectFileLoader loadedObjectHandles |
|
2793 |
" |
|
2794 |
||
2795 |
"Created: 17.9.1995 / 14:28:55 / claus" |
|
2796 |
"Modified: 17.9.1995 / 16:13:48 / claus" |
|
2797 |
! |
|
2798 |
||
2799 |
loadedObjectHandlesDo:aBlock |
|
2800 |
"enumerate all handles" |
|
2801 |
||
2802 |
LoadedObjects notNil ifTrue:[ |
|
2803 |
LoadedObjects copy do:aBlock. |
|
2804 |
]. |
|
2805 |
||
2806 |
" |
|
2807 |
ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL] |
|
2808 |
" |
|
2809 |
||
2810 |
"Created: 14.9.1995 / 22:03:13 / claus" |
|
2811 |
"Modified: 14.9.1995 / 22:32:48 / claus" |
|
2812 |
! |
|
2813 |
||
2814 |
pathNameFromID:id |
|
2815 |
"given an id, return the pathName, or nil for static modules" |
|
2816 |
||
2817 |
LoadedObjects notNil ifTrue:[ |
|
2818 |
LoadedObjects keysAndValuesDo:[:name :handle | |
|
2819 |
handle moduleID == id ifTrue:[ |
|
2820 |
^ handle pathName |
|
2821 |
] |
|
2822 |
]. |
|
2823 |
]. |
|
2824 |
^ nil |
|
2825 |
||
2826 |
" |
|
2827 |
ObjectFileLoader pathNameFromID:1 |
|
2828 |
" |
|
2829 |
||
2830 |
"Modified: 28.8.1995 / 18:08:28 / claus" |
|
2831 |
! |
|
2832 |
||
2833 |
primCanLoadObjectFiles |
|
2834 |
"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
|
2835 |
|
141 | 2836 |
%{ /* NOCONTEXT */ |
2837 |
#ifdef HAS_DL |
|
2838 |
# if !defined(OS_DEFINE) || defined(unknownOS) |
|
2839 |
fprintf(stderr, "*** OS_DEFINE not correct\n"); |
|
2840 |
# else |
|
2841 |
# if !defined(CPU_DEFINE) || defined(unknownCPU) |
|
2842 |
fprintf(stderr, "*** CPU_DEFINE not correct\n"); |
|
2843 |
# else |
|
2844 |
RETURN (true); |
|
2845 |
# endif |
|
2846 |
# endif |
|
2847 |
#endif |
|
2848 |
%}. |
|
2849 |
^ false |
|
470
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 |
" |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2852 |
ObjectFileLoader primCanLoadObjectFiles |
2994a91156e0
category changes; added comments.
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
2853 |
" |
20 | 2854 |
! ! |
2855 |
||
369 | 2856 |
!ObjectFileLoader class methodsFor:'st object file handling'! |
303 | 2857 |
|
2858 |
callInitFunctionAt:address specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject |
|
2859 |
"call a function at address - a very dangerous operation. |
|
2860 |
This is needed to call the classes init-function after loading in a |
|
2861 |
class-object file or to call the CTORS when c++ modules are loaded. |
|
2862 |
ForceOld (if true) will have the memory manager |
|
2863 |
allocate things in oldSpace instead of newSpace. |
|
2864 |
If special is true, this is a smalltalk moduleInit (i.e. pass the vm-entries table); |
|
2865 |
otherwise, its called without arguments. |
|
2866 |
If its a smalltalk-moduleInit, it may be either for a classPackage (which should |
|
2867 |
install all of its classes) or for a single incrementally compiled methdod |
|
2868 |
(it should then NOT install it, but return the method object instead). |
|
2869 |
||
2870 |
DANGER: Internal & highly specialized. Dont use in your programs. |
|
468 | 2871 |
This interface may change without notice." |
303 | 2872 |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2873 |
|moduleID retVal| |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2874 |
|
303 | 2875 |
handle notNil ifTrue:[ |
468 | 2876 |
moduleID := handle moduleID |
303 | 2877 |
]. |
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2878 |
|
303 | 2879 |
%{ /* CALLSSTACK: 32000 */ |
2880 |
OBJ (*addr)(); |
|
2881 |
unsigned val; |
|
2882 |
int savInt; |
|
2883 |
int prevSpace, force; |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2884 |
int arg = 0, ret = 0; |
303 | 2885 |
int wasBlocked = 1; |
2886 |
extern int __oldSpaceSize(), __oldSpaceUsed(); |
|
2887 |
||
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
2888 |
if (__isInteger(address)) { |
468 | 2889 |
if (_isSmallInteger(argument)) { |
2890 |
arg = __intVal(argument); |
|
2891 |
||
2892 |
val = (unsigned)(__longIntVal(address)); |
|
2893 |
addr = (OBJFUNC) val; |
|
2894 |
||
2895 |
/* |
|
2896 |
* allow function to be interrupted |
|
2897 |
*/ |
|
2898 |
if (interruptable != true) { |
|
2899 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
|
2900 |
} |
|
2901 |
||
2902 |
force = (forceOld == true); |
|
2903 |
if (force) { |
|
2904 |
if ((__oldSpaceSize() - __oldSpaceUsed()) < (256*1024)) { |
|
2905 |
__moreOldSpace(__thisContext, 256*1024); |
|
2906 |
} |
|
2907 |
prevSpace = __allocForceSpace(OLDSPACE); |
|
2908 |
} |
|
2909 |
||
2910 |
if (special == true) { |
|
2911 |
if (__isSmallInteger(moduleID)) { |
|
2912 |
__SET_MODULE_ID(__intVal(moduleID)); |
|
2913 |
} |
|
2914 |
retVal = (*addr)(arg, __pRT__); |
|
2915 |
__SET_MODULE_ID(0); |
|
2916 |
if (returnsObject != true) { |
|
2917 |
retVal = nil; |
|
2918 |
} |
|
2919 |
} else { |
|
2920 |
if (returnsObject == true) { |
|
2921 |
retVal = (*addr)(arg); |
|
2922 |
} else { |
|
2923 |
ret = (int) ((*addr)(arg)); |
|
2924 |
retVal = __MKSMALLINT(ret); |
|
2925 |
} |
|
2926 |
} |
|
2927 |
||
2928 |
if (force) { |
|
2929 |
__allocForceSpace(prevSpace); |
|
2930 |
} |
|
2931 |
||
2932 |
if (! wasBlocked) { |
|
2933 |
__UNBLOCKINTERRUPTS(); |
|
2934 |
} |
|
2935 |
RETURN (retVal); |
|
2936 |
} |
|
303 | 2937 |
} |
2938 |
%}. |
|
2939 |
self primitiveFailed |
|
2940 |
! |
|
2941 |
||
2942 |
deinitializeClassesFromModule:handle |
|
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2943 |
"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
|
2944 |
to all classes of a module." |
303 | 2945 |
|
2946 |
|classes| |
|
2947 |
||
2948 |
classes := handle classes. |
|
2949 |
classes notNil ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2950 |
classes do:[:aClass | |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2951 |
aClass notNil ifTrue:[ |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2952 |
aClass isMeta ifFalse:[ |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2953 |
Verbose ifTrue:[ |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2954 |
'send #deinitialize to:' infoPrint. aClass name infoPrintCR. |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2955 |
]. |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2956 |
aClass deinitialize. |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2957 |
aClass update:#aboutToUnload with:nil from:self |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2958 |
] |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2959 |
] |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2960 |
] |
303 | 2961 |
] |
307
2552fd5e8592
give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents:
306
diff
changeset
|
2962 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2963 |
"Modified: 10.1.1997 / 17:56:50 / cg" |
303 | 2964 |
! |
2965 |
||
2966 |
invalidateModule:handle |
|
2967 |
"invalidate all of the classes code objects ..." |
|
2968 |
||
2969 |
|id| |
|
2970 |
||
2971 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2972 |
'invalidate module; name=' infoPrint. handle pathName infoPrint. |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2973 |
' id=' infoPrint. handle moduleID infoPrintCR. |
303 | 2974 |
]. |
2975 |
||
2976 |
id := handle moduleID. |
|
2977 |
%{ |
|
2978 |
__INVALIDATE_BY_ID(__intVal(id)); |
|
2979 |
%} |
|
2980 |
! |
|
2981 |
||
2982 |
loadStatusFor:className |
|
2983 |
"ask VM if class-hierarchy has been completely loaded, and return the status." |
|
2984 |
||
2985 |
|checker checkSymbol statusCode status badClassName| |
|
2986 |
||
2987 |
checker := self. |
|
2988 |
checkSymbol := #'superClassCheck:'. |
|
2989 |
||
2990 |
%{ /* NOREGISTER */ |
|
2991 |
char *badName; |
|
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
2992 |
char *interestingClassName; |
303 | 2993 |
|
2994 |
if (__isString(className) || __isSymbol(className)) { |
|
587 | 2995 |
interestingClassName = (char *)__stringVal(className); |
303 | 2996 |
} else { |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
2997 |
interestingClassName = (char *)0; |
303 | 2998 |
} |
365
22c85186e799
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
346
diff
changeset
|
2999 |
statusCode = __MKSMALLINT(__check_registration__(interestingClassName, |
303 | 3000 |
&checker, &checkSymbol, &badName)); |
3001 |
if (badName) { |
|
3002 |
badClassName = __MKSTRING(badName); |
|
3003 |
} |
|
3004 |
%}. |
|
3005 |
statusCode == 0 ifTrue:[ |
|
3006 |
status := #ok |
|
3007 |
] ifFalse:[ |
|
3008 |
statusCode == -1 ifTrue:[ |
|
3009 |
status := #missingClass |
|
3010 |
] ifFalse:[ |
|
3011 |
statusCode == -2 ifTrue:[ |
|
3012 |
status := #versionMismatch |
|
3013 |
] ifFalse:[ |
|
3014 |
statusCode == -3 ifTrue:[ |
|
3015 |
status := #unregisteredSuperclass |
|
3016 |
] ifFalse:[ |
|
3017 |
status := #loadFailed |
|
3018 |
] |
|
3019 |
] |
|
3020 |
] |
|
3021 |
]. |
|
3022 |
^ Array with:status with:badClassName. |
|
3023 |
! |
|
3024 |
||
3025 |
moduleInit:phase forceOld:forceOld interruptable:interruptable |
|
3026 |
"initialization phases after registration. |
|
3027 |
DANGER: Pure magic; internal only -> dont use in your programs." |
|
3028 |
||
3029 |
%{ |
|
3030 |
int savInt; |
|
3031 |
int prevSpace, force; |
|
3032 |
int arg = 0; |
|
3033 |
int wasBlocked = 1; |
|
3034 |
||
3035 |
if (_isSmallInteger(phase)) { |
|
3036 |
if (interruptable != true) { |
|
3037 |
wasBlocked = (__BLOCKINTERRUPTS() == true); |
|
3038 |
} |
|
3039 |
||
3040 |
force = (forceOld == true); |
|
3041 |
if (force) { |
|
3042 |
prevSpace = __allocForceSpace(OLDSPACE); |
|
3043 |
} |
|
3044 |
||
345
3727b0b6f62f
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
339
diff
changeset
|
3045 |
__init_registered_modules__(__intVal(phase)); |
303 | 3046 |
|
3047 |
if (force) { |
|
3048 |
__allocForceSpace(prevSpace); |
|
3049 |
} |
|
3050 |
||
3051 |
if (! wasBlocked) { |
|
3052 |
__UNBLOCKINTERRUPTS(); |
|
3053 |
} |
|
3054 |
RETURN (self); |
|
3055 |
} |
|
3056 |
%}. |
|
3057 |
self primitiveFailed |
|
3058 |
! |
|
3059 |
||
3060 |
performModuleInitAt:initAddr for:className identifyAs:handle |
|
3061 |
"Initialize a loaded smalltalk module." |
|
3062 |
||
3063 |
|status badClassName infoCollection info classNames classes| |
|
3064 |
||
3065 |
" |
|
3066 |
need 4 passes to init: 0: let module register itself & create its pools/globals |
|
474 | 3067 |
0b check if modules superclasses are all loaded |
3068 |
1: let it get var-refs to other pools/globals |
|
3069 |
2: let it install install class, methods and literals |
|
3070 |
3: let it send #initialize to its class object |
|
303 | 3071 |
" |
3072 |
||
3073 |
"/ |
|
3074 |
"/ let it register itself |
|
3075 |
"/ and define its globals |
|
3076 |
"/ |
|
3077 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3078 |
'phase 0 ...' infoPrintCR |
303 | 3079 |
]. |
3080 |
self callInitFunctionAt:initAddr |
|
474 | 3081 |
specialInit:true |
3082 |
forceOld:true |
|
3083 |
interruptable:false |
|
3084 |
argument:0 |
|
3085 |
identifyAs:handle |
|
3086 |
returnsObject:false. |
|
303 | 3087 |
|
3088 |
"/ |
|
3089 |
"/ check if superclasses are present |
|
3090 |
"/ |
|
3091 |
info := self loadStatusFor:className. |
|
3092 |
status := info at:1. |
|
3093 |
badClassName := info at:2. |
|
3094 |
||
3095 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3096 |
'... status is ' infoPrint. info infoPrintCR |
303 | 3097 |
]. |
3098 |
||
3099 |
(status ~~ #ok) ifTrue:[ |
|
474 | 3100 |
(status == #missingClass) ifTrue:[ |
3101 |
('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR. |
|
3102 |
^ info |
|
3103 |
]. |
|
3104 |
(status == #versionMismatch) ifTrue:[ |
|
3105 |
('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR. |
|
3106 |
^ info |
|
3107 |
]. |
|
3108 |
(status == #unregisteredSuperclass) ifTrue:[ |
|
3109 |
('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR. |
|
3110 |
^ info |
|
3111 |
]. |
|
3112 |
('ObjectFileLoader [error]: load failed') infoPrintCR. |
|
3113 |
^ Array with:#loadFailed with:nil |
|
303 | 3114 |
]. |
3115 |
||
3116 |
"/ |
|
3117 |
"/ remaining initialization |
|
3118 |
"/ |
|
3119 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3120 |
'phase 1 ...' infoPrintCR |
303 | 3121 |
]. |
3122 |
self moduleInit:1 forceOld:true interruptable:false. |
|
3123 |
||
3124 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3125 |
'phase 2 ...' infoPrintCR |
303 | 3126 |
]. |
3127 |
self moduleInit:2 forceOld:true interruptable:false. |
|
3128 |
||
3129 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3130 |
'phase 3 ...' infoPrintCR |
303 | 3131 |
]. |
3132 |
ObjectMemory flushCaches. |
|
3133 |
self moduleInit:3 forceOld:false interruptable:true. |
|
3134 |
||
3135 |
"/ ask objectMemory for the classes we have just loaded |
|
3136 |
"/ and register them in the handle |
|
3137 |
||
3138 |
infoCollection := ObjectMemory binaryModuleInfo. |
|
3139 |
info := infoCollection at:handle moduleID ifAbsent:nil. |
|
3140 |
info isNil ifTrue:[ |
|
474 | 3141 |
"/ mhmh registration failed - |
3142 |
('ObjectFileLoader [error]: registration failed') infoPrintCR. |
|
3143 |
^ Array with:#registrationFailed with:nil |
|
303 | 3144 |
]. |
3145 |
||
405
92cb91b82cf7
changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3146 |
classNames := info classNames. |
303 | 3147 |
classNames size > 0 ifTrue:[ |
474 | 3148 |
classes := classNames collect:[:nm | Smalltalk classNamed:nm]. |
303 | 3149 |
]. |
3150 |
classes size > 0 ifTrue:[ |
|
474 | 3151 |
classes := classes asArray. |
3152 |
classes := classes , (classes collect:[:aClass | aClass class]). |
|
303 | 3153 |
]. |
3154 |
handle classes:classes. |
|
3155 |
||
3156 |
^ Array with:#ok with:nil |
|
3157 |
||
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3158 |
"Modified: 10.1.1997 / 17:58:41 / cg" |
303 | 3159 |
! |
3160 |
||
3161 |
revalidateModule:handle |
|
3162 |
"revalidate all of the classes code objects ..." |
|
3163 |
||
3164 |
|id| |
|
3165 |
||
3166 |
Verbose ifTrue:[ |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3167 |
'revalidate module; name=' infoPrint. handle pathName infoPrint. |
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3168 |
' id=' infoPrint. handle moduleID infoPrintCR. |
303 | 3169 |
]. |
3170 |
||
3171 |
id := handle moduleID. |
|
3172 |
%{ |
|
3173 |
__REVALIDATE_BY_ID(__intVal(id)); |
|
3174 |
%} |
|
3175 |
! |
|
3176 |
||
3177 |
superClassCheck:aClass |
|
320
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3178 |
"callBack from class registration code in VM: |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3179 |
make certain, that aClass is loaded too ... |
54bfd6fd28b9
removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents:
317
diff
changeset
|
3180 |
(req'd if a subclass of an autoloaded class has been loaded)" |
303 | 3181 |
|
3182 |
Verbose ifTrue:[ |
|
474 | 3183 |
'checkCall for:' infoPrint. aClass name infoPrint. ' -> ' infoPrint. |
303 | 3184 |
]. |
3185 |
aClass isBehavior ifFalse:[ |
|
474 | 3186 |
Verbose ifTrue:[ |
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3187 |
'false' infoPrintCR. |
474 | 3188 |
]. |
3189 |
'ObjectFileLoader [warning]: check failed - no behavior' errorPrintCR. |
|
3190 |
^ false |
|
303 | 3191 |
]. |
3192 |
Verbose ifTrue:[ |
|
474 | 3193 |
'true' infoPrintCR. |
303 | 3194 |
]. |
474 | 3195 |
('ObjectFileLoader [info]: check for ' , aClass name , ' being loaded') infoPrintCR. |
303 | 3196 |
aClass autoload. |
3197 |
(aClass isBehavior and:[aClass isLoaded]) ifTrue:[ |
|
474 | 3198 |
('ObjectFileLoader [info]: ok, loaded. continue registration of actual class') infoPrintCR. |
3199 |
aClass signature. "/ req'd in VM for validation |
|
3200 |
^ true |
|
303 | 3201 |
]. |
474 | 3202 |
('ObjectFileLoader [warning]: superclass not loaded; registration of ' , aClass name , ' fails') errorPrintCR. |
303 | 3203 |
^ false |
474 | 3204 |
|
477
5208c65a2b3d
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3205 |
"Modified: 10.1.1997 / 17:58:48 / cg" |
303 | 3206 |
! |
3207 |
||
3208 |
unregisterModule:handle |
|
3209 |
"unregister classes in the VM. |
|
3210 |
This invalidates all of the classes code objects ..." |
|
3211 |
||
3212 |
|id| |
|
3213 |
||
3214 |
Verbose ifTrue:[ |
|
474 | 3215 |
'unregister module; name=' infoPrint. handle pathName infoPrint. |
3216 |
' id=' infoPrint. handle moduleID infoPrintCR. |
|
303 | 3217 |
]. |
3218 |
||
3219 |
id := handle moduleID. |
|
3220 |
%{ |
|
3221 |
__UNREGISTER_BY_ID(__intVal(id)); |
|
3222 |
%} |
|
3223 |
! ! |
|
3224 |
||
369 | 3225 |
!ObjectFileLoader class methodsFor:'documentation'! |
148 | 3226 |
|
3227 |
version |
|
587 | 3228 |
^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.143 1997-07-22 16:17:05 cg Exp $' |
148 | 3229 |
! ! |
0 | 3230 |
ObjectFileLoader initialize! |