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