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