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