ObjectFileLoader.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Feb 2020 13:40:53 +0100
changeset 4644 117a8f63f3f8
parent 4635 d8c0804e23e3
child 4723 524785227024
permissions -rw-r--r--
#BUGFIX by cg class: Parser changed: #stringWithEmbeddedExpressions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
     1
"{ Encoding: utf8 }"
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
     2
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     3
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1993 by Claus Gittinger
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
     5
	      All Rights Reserved
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     6
7ad01559b262 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
7ad01559b262 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
7ad01559b262 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
7ad01559b262 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
7ad01559b262 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    13
"
1116
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
    14
"{ Package: 'stx:libcomp' }"
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
    15
3556
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
    16
"{ NameSpace: Smalltalk }"
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
    17
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    18
Object subclass:#ObjectFileLoader
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    19
	instanceVariableNames:''
3904
cbd7407d4f48 #OTHER by sr
sr
parents: 3900
diff changeset
    20
	classVariableNames:'ActuallyLoadedObjects CopyLibrariesWhenLoading ErrorPrinting
cbd7407d4f48 #OTHER by sr
sr
parents: 3900
diff changeset
    21
		LastError LastErrorNumber LinkErrorMessage LoadedObjects
cbd7407d4f48 #OTHER by sr
sr
parents: 3900
diff changeset
    22
		MySymbolTable NextHandleID OldSpaceReserve
cbd7407d4f48 #OTHER by sr
sr
parents: 3900
diff changeset
    23
		PreviouslyLoadedObjects Verbose'
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    24
	poolDictionaries:''
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    25
	category:'System-Compiler'
47
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    26
!
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    27
2627
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    28
Error subclass:#ObjectFileLoadError
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    29
	instanceVariableNames:''
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    30
	classVariableNames:''
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    31
	poolDictionaries:''
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    32
	privateIn:ObjectFileLoader
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    33
!
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    34
2284
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    35
Notification subclass:#ObjectFileLoadErrorNotification
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    36
	instanceVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    37
	classVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    38
	poolDictionaries:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    39
	privateIn:ObjectFileLoader
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
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    42
ObjectFileLoader::ObjectFileLoadErrorNotification subclass:#RegistrationFailedErrorNotification
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    43
	instanceVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    44
	classVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    45
	poolDictionaries:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    46
	privateIn:ObjectFileLoader
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
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    49
ObjectFileLoader::ObjectFileLoadErrorNotification subclass:#SuperClassMissingErrorNotification
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    50
	instanceVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    51
	classVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    52
	poolDictionaries:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    53
	privateIn:ObjectFileLoader
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    54
!
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    55
53
c5dd7abf8431 *** empty log message ***
claus
parents: 51
diff changeset
    56
!ObjectFileLoader primitiveDefinitions!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    57
%{
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    58
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
    59
#undef true
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
    60
#undef false
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
    61
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    62
/*
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    63
 * by default, use whatever the system provides
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    64
 */
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
    65
#if defined(SYSV4) || defined(HAS_DLOPEN)   /* sys5.4 dlopen interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    66
# define SYSV4_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    67
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    68
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    69
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    70
#ifdef __VMS__
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    71
# undef __new
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    72
#endif
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    73
95
claus
parents: 94
diff changeset
    74
#ifdef DL1_6    /* dl1.6 COFF loader */
claus
parents: 94
diff changeset
    75
# define HAS_DL
claus
parents: 94
diff changeset
    76
#endif
claus
parents: 94
diff changeset
    77
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    78
#include <stdio.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    79
95
claus
parents: 94
diff changeset
    80
#ifdef NEXT_DL
claus
parents: 94
diff changeset
    81
# ifndef _RLD_H_
claus
parents: 94
diff changeset
    82
#  define _RLD_H_
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
    83
#  ifdef __NEXT3__
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    84
#   include <mach-o/rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    85
#  else
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    86
#   include <rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    87
#  endif
95
claus
parents: 94
diff changeset
    88
# endif
claus
parents: 94
diff changeset
    89
#endif /* NEXT_DL */
claus
parents: 94
diff changeset
    90
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
    91
#ifdef SYSV4_DL
1903
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    92
# ifndef dlfcn_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    93
#  include <dlfcn.h>
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    94
#  define dlfcn_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    95
# endif
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
    96
#endif
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
    97
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    98
#ifdef GNU_DL
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    99
#  ifndef dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   100
#   include "dld.h"
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   101
#   define dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   102
#  endif
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   103
#endif
95
claus
parents: 94
diff changeset
   104
claus
parents: 94
diff changeset
   105
#ifdef DL1_6
claus
parents: 94
diff changeset
   106
#  ifndef dl_h
claus
parents: 94
diff changeset
   107
#   include "dl.h"
claus
parents: 94
diff changeset
   108
#   define dl_h
claus
parents: 94
diff changeset
   109
#  endif
claus
parents: 94
diff changeset
   110
#endif
claus
parents: 94
diff changeset
   111
97
claus
parents: 96
diff changeset
   112
#ifdef AIX_DL
claus
parents: 96
diff changeset
   113
# include <nlist.h>
100
claus
parents: 98
diff changeset
   114
# include <sys/ldr.h>
claus
parents: 98
diff changeset
   115
# include <errno.h>
97
claus
parents: 96
diff changeset
   116
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   117
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   118
#ifdef HPUX10_DL
1903
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   119
# ifndef dl_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   120
#  include <dl.h>
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   121
#  define dl_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   122
# endif
524
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
   123
# include <errno.h>
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   124
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   125
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   126
#ifdef WIN_DL
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   127
# undef INT
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   128
# undef UINT
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   129
# undef Array
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   130
# undef Number
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   131
# undef Method
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   132
# undef Block
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   133
# undef Time
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   134
# undef Date
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   135
# undef Set
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   136
# undef Delay
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   137
# undef Signal
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   138
# undef Context
2114
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   139
# undef Message
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   140
# undef Process
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   141
# undef Processor
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   142
# undef Rectangle
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   143
# undef String
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   144
# undef Character
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   145
# undef Point
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   146
# undef Object
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   147
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   148
# ifdef __i386__
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   149
#  ifndef _X86_
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   150
#   define _X86_
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   151
#  endif
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   152
# endif
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   153
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   154
# ifdef __BORLANDC__
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   155
#  define NOATOM
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   156
#  define NOUSER
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   157
#  define NOGDI
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   158
#  define NOGDICAPMASKS
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   159
#  define NOMETAFILE
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   160
#  define NOMINMAX
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   161
#  define NOMSG
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   162
#  define NOOPENFILE
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   163
#  define NORASTEROPS
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   164
#  define NOSCROLL
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   165
#  define NOSOUND
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   166
#  define NOSYSMETRICS
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   167
#  define NOTEXTMETRIC
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   168
#  define NOWH
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   169
#  define NOCOMM
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   170
#  define NOKANJI
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   171
#  define NOCRYPT
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   172
#  define NOMCX
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   173
#  define WIN32_LEAN_AND_MEAN
2920
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   174
#  include <windows.h>
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   175
// #  include <windef.h>
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   176
// #  include <winbase.h>
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   177
# else
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   178
#  ifdef __VISUALC__
2920
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   179
// #  include <windows.h>
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   180
#   include <windef.h>
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   181
#   include <winbase.h>
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   182
#  else
2920
951b877c3c44 compilability
Claus Gittinger <cg@exept.de>
parents: 2919
diff changeset
   183
#   include <windows.h>
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   184
#  endif
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   185
# endif /* BORLANDC */
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   186
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   187
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   188
# ifdef __DEF_Array
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   189
#  define Array __DEF_Array
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   190
# endif
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   191
# ifdef __DEF_Number
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   192
#  define Number __DEF_Number
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   193
# endif
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   194
# ifdef __DEF_Method
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   195
#  define Method __DEF_Method
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   196
# endif
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   197
# ifdef __DEF_Block
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   198
#  define Block __DEF_Block
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   199
# endif
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   200
# ifdef __DEF_Time
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   201
#  define Time __DEF_Time
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   202
# endif
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   203
# ifdef __DEF_Date
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   204
#  define Date __DEF_Date
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   205
# endif
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   206
# ifdef __DEF_Set
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   207
#  define Set __DEF_Set
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   208
# endif
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   209
# ifdef __DEF_Signal
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   210
#  define Signal __DEF_Signal
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   211
# endif
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   212
# ifdef __DEF_Delay
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   213
#  define Delay __DEF_Delay
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   214
# endif
1175
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   215
# ifdef __DEF_Context
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   216
#  define Context __DEF_Context
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   217
# endif
2114
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   218
# ifdef __DEF_Message
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   219
#  define Message __DEF_Message
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   220
# endif
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   221
# ifdef __DEF_Process
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   222
#  define Process __DEF_Process
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   223
# endif
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   224
# ifdef __DEF_Processor
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   225
#  define Processor __DEF_Processor
1b2f1452321d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   226
# endif
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   227
# ifdef __DEF_Rectangle
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   228
#  define Rectangle __DEF_Rectangle
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
   229
# endif
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   230
# ifdef __DEF_String
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   231
#  define String __DEF_String
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   232
# endif
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   233
# ifdef __DEF_Character
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   234
#  define Character __DEF_Character
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   235
# endif
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   236
# ifdef __DEF_Point
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   237
#  define Point __DEF_Point
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   238
# endif
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   239
# ifdef __DEF_Object
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   240
#  define Object __DEF_Object
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   241
# endif
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   242
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   243
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   244
# define INT STX_INT
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   245
# define UINT STX_UINT
1974
b56c1d85dea2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1965
diff changeset
   246
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   247
#endif /* WIN_DL */
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   248
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   249
#undef true
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   250
#define true __STX_true
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   251
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   252
#undef false
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   253
#define false __STX_false
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   254
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   255
%}
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   256
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   257
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   258
!ObjectFileLoader class methodsFor:'documentation'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   259
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   260
copyright
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   261
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   262
 COPYRIGHT (c) 1993 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   263
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   264
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   265
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   266
 only in accordance with the terms of that license and with the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   267
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   268
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   269
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   270
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   271
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   272
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   273
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   274
documentation
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   275
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   276
    This class knowns how to dynamically load in external object-modules.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   277
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   278
    WARNING:
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   279
      As to date, this is still experimental and WITHOUT ANY WARRANTY.
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   280
      It is still being developed and the code may need some cleanup and more
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   281
      robustness.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   282
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   283
    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
   284
	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
   285
	   GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
   286
	   or LoadLibrary (Win32), this is used
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
   287
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
   288
	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
   289
	   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
   290
	   and the object file is loaded into that space.
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   291
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   292
    Not all mechanisms work fully satisfying.
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
   293
    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
   294
    (which is certainly not what we want here :-(;
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
   295
    the NeXT mechanism does not allow for selective unloading
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   296
    (only all or the last loaded module).
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   297
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   298
    The only really useful packages are the GNU-dl package,
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   299
    the SGI/Unixware/sys5.4/linux/osx libdl packages and the win32 dll's.
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   300
    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
   301
    (which is more or less obsolete);
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   302
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   303
    For the above reasons, dynamic object loading is only
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   304
    officially released for SYS5.4-based, linux, osx and win32 systems.
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   305
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   306
    When stable, the functionality contained herein will be moved into the VM.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   307
    (It is needed there, to allow reloading of objectfiles upon
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   308
     image restart; i.e. before any class is reinitialilized).
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   309
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   310
    Right now, reloading of object files is done by Smalltalk code,
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   311
    which fails, if code is to be loaded which is required before the
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   312
    load takes place, or which is used by the loader itself.
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   313
    (i.e. for now, many primitives from libbasic cannot be dynamically
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   314
    loaded at image restart time).
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
   315
    This will fix itself, once we do object file loading in the VM.
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   316
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   317
    [author:]
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
   318
	Claus Gittinger
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   319
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   320
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   321
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   322
!ObjectFileLoader class methodsFor:'initialization'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   323
7ad01559b262 Initial revision
claus
parents:
diff changeset
   324
initialize
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   325
    |systemType libDir linkCommand linkArgs libPath searchedLibraries|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   326
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
   327
    Verbose := false.
2745
d3c89036c184 changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
   328
    "/ Verbose := true.
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
   329
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   330
    OperatingSystem isMSDOSlike ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   331
	ParserFlags useBorlandC ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   332
	    "/ default setup for bcc
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   333
	    libDir := '..\lib\bc'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   334
	    libDir asFilename exists ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   335
		libDir := '..\lib\lib\bc'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   336
		libDir asFilename exists ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   337
		    libDir := '..\lib'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   338
		]
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
	    linkCommand isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   342
		"/ linkCommand := 'tlink32'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   343
		linkCommand := 'ilink32'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   344
	    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   345
	    linkArgs isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   346
		"/ 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
   347
		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
   348
	    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   349
	    searchedLibraries := #(
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   350
				    'import32.lib'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   351
				  ).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   352
	] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   353
	    linkCommand isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   354
		linkCommand := 'link'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   355
	    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   356
	    linkArgs isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   357
		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
   358
	    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   359
	].
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   360
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   361
201
66bd5f9c781c only init once
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
   362
    MySymbolTable isNil ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   363
	NextHandleID := 1.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   364
	ObjectMemory addDependent:self.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   365
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   366
	OperatingSystem isMSDOSlike ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   367
	    searchedLibraries := #(
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   368
				    'import32.lib'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   369
				  ).
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
	OperatingSystem isUNIXlike ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   373
	    |ldLibraryPath|
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   374
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   375
	    systemType := OperatingSystem getOSType.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   376
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   377
	    "/ 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
   378
	    "/ not req'd for all architectures.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   379
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   380
	    MySymbolTable := 'stx'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   381
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   382
	    searchedLibraries := #().
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   383
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   384
	    "/ default libraryPath where shared objects are expected
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   385
	    "/ 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
   386
	    "/ 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
   387
	    "/ 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
   388
	    "/ 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
   389
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   390
	    ldLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   391
	    ldLibraryPath isEmptyOrNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   392
		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
   393
	    ] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   394
		"/ 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
   395
		systemType = #aix ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   396
		    libPath := ldLibraryPath.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   397
		].
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
	]
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   400
    ].
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   401
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   402
    ParserFlags linkCommand:linkCommand.
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   403
    ParserFlags linkArgs:linkArgs.
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
   404
    ParserFlags libPath:libPath ? ''.
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   405
    ParserFlags searchedLibraries:searchedLibraries.
107
claus
parents: 106
diff changeset
   406
claus
parents: 106
diff changeset
   407
    "
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   408
     LinkArgs := LinkCommand := nil.
107
claus
parents: 106
diff changeset
   409
     ObjectFileLoader initialize
claus
parents: 106
diff changeset
   410
    "
316
ee3426730cfc on sunos: link dynamic objects against libc.a for unresolved symbols.
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   411
2933
8d05290d3b98 changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 2932
diff changeset
   412
    "Modified: / 28-09-2012 / 18:19:28 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   413
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   414
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   415
lastError
780
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   416
    ^ LastError ? 'unknown error'
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   417
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   418
    "Modified: / 30.9.1998 / 17:21:23 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   419
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   420
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   421
libPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   422
    "see comment in #libPath:"
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   423
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   424
    ^ ParserFlags libPath
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   425
!
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
libPath:aSharedLibraryPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   428
    "set the pathnames of directories, where other shared objects
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   429
     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
   430
     library object to be loaded.
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   431
     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
   432
     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
   433
     LD_LIBRARY_PATH environment variable."
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   434
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   435
    ParserFlags libPath:aSharedLibraryPath
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   436
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
     ObjectFileLoader libPath:'.:/usr/lib:/usr/local/lib'
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   439
    "
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
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   442
linkErrorMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   443
    ^ LinkErrorMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   444
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   445
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   446
searchedLibraries
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   447
    "see comment in #searchedLibraries:"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   448
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   449
    ^ ParserFlags searchedLibraries
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   450
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   451
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   452
searchedLibraries:aCollectionOfArchivePathNames
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   453
    "set the pathnames of archives which are to be searched
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   454
     when unresolved references occur while loading in an object
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   455
     file. On systems which support shared libraries (all SYS5.4 based
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   456
     systems), this is usually not required. Instead, modules which are to
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   457
     be filed in (.so files) are to be prelinked with the appropriate
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   458
     shared libraries. The dynamic loader then cares about loading those
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   459
     modules (keeping track of which modules are already loaded).
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   460
     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
   461
     (i.e. currently only linux and a.out-sunos) need to set this."
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   462
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   463
    ParserFlags searchedLibraries:aCollectionOfArchivePathNames
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   464
!
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   465
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   466
verbose
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   467
    "return true, if debug traces are turned on"
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   468
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   469
    ^ Verbose
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   470
!
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   471
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   472
verbose:aBoolean
7ad01559b262 Initial revision
claus
parents:
diff changeset
   473
    "turn on/off debug traces"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   474
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
   475
    Verbose := aBoolean
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   476
7ad01559b262 Initial revision
claus
parents:
diff changeset
   477
    "ObjectFileLoader verbose:true"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   478
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   479
2982
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   480
!ObjectFileLoader class methodsFor:'accessing'!
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   481
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   482
copyLibrariesWhenLoading
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   483
    "under windows, a library file (dll) which has been loaded cannot be overwritten.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   484
     This makes it troublesome, to recompile a new lib while a smalltalk is being executed.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   485
     When CopyLibrariesWhenLoading is true, ddl files are copied to a tempdir before loading,
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   486
     so that the original can still be recompiled.
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   487
     Makes loading a bit slower (due to the copying),
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   488
     so it is off by default and must be turned on explicitly during development."
2982
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   489
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   490
    ^ CopyLibrariesWhenLoading ? false
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   491
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   492
    "
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   493
     self copyLibrariesWhenLoading
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   494
     self copyLibrariesWhenLoading:true
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   495
    "
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   496
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   497
    "Modified (comment): / 22-07-2018 / 18:10:15 / Stefan Vogel"
2982
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   498
!
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   499
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   500
copyLibrariesWhenLoading:aBoolean
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   501
    "under windows, a library file (dll) which has been loaded cannot be overwritten.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   502
     This makes it troublesome, to recompile a new lib while a smalltalk is being executed.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   503
     When CopyLibrariesWhenLoading is true, ddl files are copied to a tempdir before loading,
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   504
     so that the original can still be recompiled.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   505
     Makes loading a bit slower (due to copying and less sharing/caching of already loaded dlls),
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   506
     so it is of by default and must be turned on explicitly during development."
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   507
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   508
    CopyLibrariesWhenLoading := aBoolean.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   509
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   510
    "
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   511
     self copyLibrariesWhenLoading:true
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   512
    "
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   513
! !
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   514
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   515
!ObjectFileLoader class methodsFor:'change & update'!
291
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   516
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   517
update:something with:aParameter from:changedObject
107
claus
parents: 106
diff changeset
   518
    "sent, when image is saved or restarted"
claus
parents: 106
diff changeset
   519
claus
parents: 106
diff changeset
   520
    (something == #aboutToSnapshot) ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   521
	self invalidateAndRememberAllObjectFiles
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   522
    ].
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   523
    (something == #finishedSnapshot) ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   524
	self revalidateAllObjectFiles
107
claus
parents: 106
diff changeset
   525
    ].
226
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   526
"/    (something == #restarted) ifTrue:[
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   527
"/        self reloadAllRememberedObjectFiles
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   528
"/    ].
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   529
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   530
    "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
   531
    "Modified: 8.3.1996 / 23:34:29 / cg"
291
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   532
    "Created: 21.6.1996 / 19:50:01 / cg"
107
claus
parents: 106
diff changeset
   533
! !
claus
parents: 106
diff changeset
   534
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   535
!ObjectFileLoader class methodsFor:'defaults'!
115
claus
parents: 114
diff changeset
   536
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   537
hasValidBinaryExtension:aFilename
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   538
    "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
   539
     This checks only the extension - not its contents.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   540
     (So an attempt to load the file may fail due to format errors or unresolved symbols)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   541
     This is very machine specific."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   542
1697
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   543
    |suffix|
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   544
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   545
    suffix := aFilename asFilename suffix.
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   546
    ^ self validBinaryExtensions includes:suffix.
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   547
"/    |fn|
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   548
"/
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   549
"/    fn := aFilename asFilename.
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   550
"/    self validBinaryExtensions do:[:ext |
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   551
"/        (fn hasSuffix:ext) ifTrue:[^ true].
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   552
"/    ].
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   553
"/    ^ false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   554
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   555
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   556
     ObjectFileLoader hasValidBinaryExtension:'foo.st'
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   557
     ObjectFileLoader hasValidBinaryExtension:'foo.o'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   558
     ObjectFileLoader hasValidBinaryExtension:'foo.so'
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   559
     ObjectFileLoader hasValidBinaryExtension:'foo.dll'
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   560
     ObjectFileLoader hasValidBinaryExtension:'foo.DLL'
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   561
     ObjectFileLoader hasValidBinaryExtension:'foo.obj'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   562
     ObjectFileLoader hasValidBinaryExtension:'foo.sl'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   563
    "
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   564
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   565
    "Modified: / 1.10.1998 / 12:47:01 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   566
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   567
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   568
linkArgs
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   569
    ^ ParserFlags linkArgs
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   570
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   571
    "Created: / 12.8.1998 / 21:41:16 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   572
    "Modified: / 12.8.1998 / 21:42:50 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   573
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   574
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   575
linkArgs:anArgString
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   576
    ParserFlags linkArgs:anArgString
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   577
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   578
    "
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   579
     MSC:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   580
	ParserFlags linkCommand:'link32'.
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   581
	ParserFlags linkArgs:' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   582
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   583
     Borland:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   584
	ParserFlags linkCommand:'ilink32'.
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   585
	ParserFlags linkArgs:'-ap -E0 -Tpd -s -c -L\Programme\Borland\CBuilder3\lib -L..\libbc librun.lib import32.lib'
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   586
'
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   587
'/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   588
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   589
     Unix:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   590
	ParserFlags linkCommand:'ld'
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   591
	ParserFlags linkArgs:'-shared'
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   592
    "
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   593
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   594
    "Created: / 12.8.1998 / 21:43:16 / cg"
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   595
    "Modified: / 4.9.1998 / 00:33:46 / cg"
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   596
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   597
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   598
linkCommand
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   599
    ^ ParserFlags linkCommand
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   600
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   601
    "Created: / 12.8.1998 / 21:41:16 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   602
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   603
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   604
linkCommand:aCommand
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   605
    ParserFlags linkCommand:aCommand
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   606
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   607
    "Created: / 12.8.1998 / 21:40:44 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   608
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   609
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   610
linkSharedArgs
2651
ee993b9ebefb changed:
Stefan Vogel <sv@exept.de>
parents: 2650
diff changeset
   611
    ^ ParserFlags linkSharedArgs
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   612
!
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   613
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   614
linkSharedArgs:anArgString
1897
49bb87ddc41b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1896
diff changeset
   615
    ParserFlags linkSharedArgs:anArgString
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   616
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   617
    "
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   618
     Linux on AMD64 in 32bit mode:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   619
	LinkSharedArgs := '-shared -m elf_i386'
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   620
    "
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
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   623
loadableBinaryObjectFormat
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   624
    "return a symbol describing the expected binary format
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   625
     for object files to be loadable.
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   626
     This is very machine specific."
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   627
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   628
%{  /* NOCONTEXT */
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   629
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   630
#ifdef HAS_DL
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   631
# if defined(SYSV4) || defined(ELF)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   632
    RETURN ( @symbol(elf));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   633
# endif
1607
074a99bb9a50 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 1602
diff changeset
   634
# if defined(__alpha__) && defined(__osf__)
590
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   635
    RETURN ( @symbol(coff));
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   636
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   637
# if defined(GNU_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   638
    RETURN ( @symbol(aout));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   639
# endif
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   640
# if defined(AIX_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   641
    RETURN ( @symbol(xcoff));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   642
# endif
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   643
# if defined(HPUX10_DL)
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   644
    RETURN ( @symbol(hpcoff));
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   645
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   646
# if defined(DL1_6)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   647
    RETURN ( @symbol(coff));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   648
# endif
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   649
# if defined(WIN_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   650
    RETURN ( @symbol(dll));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   651
# endif
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   652
# if defined(__VMS__)
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   653
    RETURN ( @symbol(exe));
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   654
# endif
3107
142a0751c8ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3054
diff changeset
   655
# if defined(__osx__)
3054
269b9da32620 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3052
diff changeset
   656
    RETURN ( @symbol(macho));
269b9da32620 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3052
diff changeset
   657
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   658
#endif
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   659
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   660
%}.
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   661
    ^ nil
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   662
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   663
    "
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   664
     ObjectFileLoader loadableBinaryObjectFormat
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   665
    "
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   666
!
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   667
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   668
nm:file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   669
   "this should return a string to list the namelist of file.
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   670
    The output of the command should be one line for each symbol,
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   671
    formatted as:
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   672
	addr  segment  name
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   673
    This is parsed and read by #namesMatching:segment:in:.
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   674
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   675
    If your default nm command cannot produce this, write a little
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   676
    shell or awk script, to generate this and return a corresponding command
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   677
    below.
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   678
    This entry is obsolete (no longer req'd) and will vanish."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   679
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   680
    |os|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   681
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   682
    os := OperatingSystem getOSType.
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
   683
    (os = #irix or:[os = #osf]) ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   684
	^ 'nm -B ' , file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   685
    ].
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
   686
    (os = #solaris) ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   687
	^ 'nm -p ' , file
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   688
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   689
    ^ 'nm ' , file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   690
702
80f90a274837 more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   691
    "Modified: / 4.5.1998 / 12:18:47 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   692
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   693
4267
692f8ce72b36 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4253
diff changeset
   694
objectFileSuffix
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   695
    "return the fileName extension used for objects,
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   696
     as generated by myself (output of cc).
115
claus
parents: 114
diff changeset
   697
     This is very machine specific."
claus
parents: 114
diff changeset
   698
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   699
    OperatingSystem isMSDOSlike ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   700
	"/ includes all of win32s, win95, winNT & os/2
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   701
	^ 'obj'
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   702
    ].
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   703
    OperatingSystem isVMSlike ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   704
	^ 'obj'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   705
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   706
4267
692f8ce72b36 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4253
diff changeset
   707
    ^ 'o'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   708
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   709
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   710
     ObjectFileLoader objectFileExtension
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   711
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   712
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   713
    "Modified: / 4.5.1998 / 12:17:34 / cg"
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   714
!
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   715
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   716
sharedLibrarySuffix
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   717
    "return the fileName suffix used for dynamic loadable objects,
4118
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   718
     (as generated by myself - output of linker/makefiles).
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   719
     This is very os/machine specific."
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   720
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   721
    |suffixes|
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   722
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   723
    suffixes := self sharedLibrarySuffixes.
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   724
    suffixes notEmptyOrNil ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   725
	^ suffixes first
4118
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   726
    ].
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   727
    ^ 'so'
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   728
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   729
    "
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   730
     ObjectFileLoader sharedLibrarySuffix
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   731
    "
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   732
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   733
    "Modified (comment): / 12-02-2017 / 21:44:13 / cg"
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   734
!
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   735
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   736
sharedLibrarySuffixes
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   737
    "return a collection of possible fileName suffixes used for dynamic loadable objects.
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   738
     If multiple suffixes are possible, the first one should be the suffix generated by myself,
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   739
     when I create loadable modules (methods with primitive code).
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   740
     This is very os/machine specific."
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   741
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   742
    |os|
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   743
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   744
    OperatingSystem isMSDOSlike ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   745
	"/ includes all Windows systems & os/2
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   746
	^ #( 'dll' )
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   747
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   748
    OperatingSystem isVMSlike ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   749
	^ #( 'exe' )
4118
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   750
    ].
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   751
    OperatingSystem isOSXlike ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   752
	^ #( 'so' 'dylib' )
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   753
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   754
115
claus
parents: 114
diff changeset
   755
    os := OperatingSystem getSystemType.
3054
269b9da32620 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3052
diff changeset
   756
    "/ are we really still supporting that old stuff?
269b9da32620 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3052
diff changeset
   757
    (self loadableBinaryObjectFormat == #aout) ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   758
	"/ not really shared, but loadable
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   759
	^ #( 'o' )
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   760
    ].
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
   761
    (os = #hpux) ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
   762
	^ #( 'sl' )
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
   763
    ].
119
claus
parents: 118
diff changeset
   764
4122
b5458dbb1426 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4118
diff changeset
   765
    ^ #( 'so' )
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   766
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   767
    "
4118
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   768
     ObjectFileLoader sharedLibrarySuffixes
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   769
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   770
4118
2234ac51545b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4034
diff changeset
   771
    "Created: / 12-02-2017 / 21:41:18 / cg"
4122
b5458dbb1426 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4118
diff changeset
   772
    "Modified: / 13-02-2017 / 20:17:31 / cg"
115
claus
parents: 114
diff changeset
   773
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   774
2012
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   775
useBorlandC
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   776
    ^ ParserFlags useBorlandC
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   777
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   778
    "Created: / 15-03-2007 / 13:32:29 / cg"
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   779
!
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   780
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   781
validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   782
    "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
   783
     This is very machine specific."
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   784
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   785
    |os|
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   786
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   787
    OperatingSystem isMSDOSlike ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   788
	"/ includes all of win32s, win95, winNT & os/2
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   789
	^ #('dll')
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   790
    ].
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   791
    OperatingSystem isVMSlike ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   792
	^ #('exe')
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   793
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   794
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   795
    os := OperatingSystem getSystemType.
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   796
    (os == #linux) ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   797
	"/ are we really still supporting that old stuff?
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   798
	self loadableBinaryObjectFormat == #aout ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   799
	    ^ #('o' 'obj' 'a')
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   800
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
   801
	^ #('so')
2156
2cb69ec50829 #validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents: 2154
diff changeset
   802
    ].
2cb69ec50829 #validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents: 2154
diff changeset
   803
    (os = 'hpux') ifTrue:[^ #('sl') ].
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   804
    (os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   805
    (os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ].
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   806
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   807
    "/ a useful default
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   808
1287
d1199118e73d sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   809
    ^ #('so')
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   810
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
     ObjectFileLoader validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   813
    "
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   814
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   815
    "Modified: / 01-10-1998 / 12:46:03 / cg"
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
   816
    "Modified: / 22-07-2018 / 16:14:54 / Stefan Vogel"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   817
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   818
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   819
!ObjectFileLoader class methodsFor:'dynamic object loading'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   820
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   821
loadCPlusPlusObjectFile:aFileName
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   822
    "load a c++ object file (.o-file) into the image.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   823
     This method is not maintained (name mangling and static
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   824
     initialization is so different among systems ...)"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   825
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   826
    |handle initAddr list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   827
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   828
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   829
    handle isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   830
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   831
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   832
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   833
    list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   834
list size == 1 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   835
"/    (self isCPlusPlusObject:handle) ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   836
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   837
	    'a c++ object file' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   838
	].
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
	 what I would like to get is the CTOR_LIST,
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   841
	 and call each function.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   842
	 But dld cannot (currently) handle SET-type symbols, therefore
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   843
	 we search (using nm) for all __GLOBAL_$I* syms, get their values
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   844
	 and call them each
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   845
	"
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   846
"/        list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   847
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   848
"/        initAddr := self getFunction:'__CTOR_LIST__' from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   849
"/        Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
   850
"/            ('calling CTORs at:' , (initAddr printStringRadix:16)) errorPrintCR
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   851
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   852
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   853
	initAddr := self getFunction:list first from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   854
	initAddr isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   855
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   856
	     try with added underscore
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   857
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   858
	    initAddr := self getFunction:('_' , list first) from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   859
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   860
	(initAddr isNil and:[list first startsWith:'_']) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   861
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   862
	     try with removed underscore
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   863
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   864
	    initAddr := self getFunction:(list first copyFrom:2) from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   865
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   866
	initAddr isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   867
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   868
		('no CTOR-func found (' , list first , ')') errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   869
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   870
	    self unloadDynamicObject:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   871
	    ^ nil
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   872
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   873
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   874
	    ('calling CTORs at:' , (initAddr printStringRadix:16)) errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   875
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   876
	self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   877
	    saveCallInitFunctionAt:initAddr
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   878
	    in:aFileName
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   879
	    specialInit:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   880
	    forceOld:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   881
	    interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   882
	    argument:0
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   883
	    identifyAs:nil
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   884
	    returnsObject:false.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   885
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   886
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   887
	    'done with CTORs.' errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   888
	].
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
	 cannot create a CPlusPlus class automatically (there could be more than
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   892
	 one classes in it too ...)
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   893
	"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   894
	^ handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   895
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   896
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   897
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   898
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   899
	'unknown object file' errorPrintCR
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   900
    ].
2348
b2a3bb714bf6 comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents: 2346
diff changeset
   901
    self unloadDynamicObject:handle.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   902
    ^ nil
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
   903
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
   904
    "Modified: / 15-11-2010 / 13:19:06 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   905
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   906
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   907
loadClass:aClassName fromObjectFile:aFileName
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   908
    "load a compiled class (.o-file) into the image.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   909
     Returns the class or nil."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   910
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   911
    |handle initAddr symName newClass moreHandles info status
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   912
     otherClass knownToBeOk|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   913
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   914
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   915
    handle isNil ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   916
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   917
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   918
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   919
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   920
     get the Init-function; let the class install itself
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   921
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   922
    symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   923
    initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   924
    initAddr isNil ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   925
	"try with added underscore"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   926
	symName := '__' , aClassName , '_Init'.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   927
	initAddr := self getFunction:symName from:handle.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   928
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   929
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   930
    knownToBeOk := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   931
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   932
"/    knownToBeOk ifFalse:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   933
"/        |list|
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
   934
"/
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   935
"/        Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
   936
"/            'looking for undefs ...' errorPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   937
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   938
"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   939
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   940
"/         if there are any undefined symbols, we may have to load more
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   941
"/         files (libs, other modules)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   942
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   943
"/        list := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   944
"/        list notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   945
"/            moreHandles := self loadModulesFromListOfUndefined:list.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   946
"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   947
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   948
"/             now, try again
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   949
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   950
"/            symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   951
"/            initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   952
"/            initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   953
"/                "try with added underscore"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   954
"/                symName := '__' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   955
"/                initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   956
"/            ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   957
"/        ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   958
"/    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   959
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   960
    initAddr notNil ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   961
	Verbose ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   962
	    ('calling init at: ' , (initAddr printStringRadix:16)) errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   963
	].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   964
	info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   965
	status := info at:1.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   966
	"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   967
	 if any classes are missing ...
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   968
	"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   969
	(status == #missingClass) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   970
	    "
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   971
	     ... and we are loading a module ...
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   972
	    "
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   973
	    Transcript showCR:'ObjectFileLoader [info]: try for missing class in same object ...'.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   974
	    Verbose ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   975
		'try for missing class:' errorPrint. (info at:2) errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   976
	    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   977
	    otherClass := self loadClass:(info at:2) fromObjectFile:aFileName.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   978
	    otherClass notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   979
		"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   980
		 try again ...
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   981
		"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   982
		Transcript showCR:'ObjectFileLoader [info]: missing class is here; try again ...'.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   983
		info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   984
		status := info at:1.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   985
	    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   986
	].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   987
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   988
	Verbose ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   989
	    'done init status=' errorPrint. info errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   990
	].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   991
	(status == #unregisteredSuperclass) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   992
	    Transcript showCR:'ObjectFileLoader [info]: superclass is not registered'.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   993
	].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   994
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   995
	(Symbol hasInterned:aClassName) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   996
	    newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   997
	    Verbose ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   998
		'newClass is: ' errorPrint. newClass errorPrintCR
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
   999
	    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1000
	    newClass notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1001
		Smalltalk at:aClassName asSymbol put:newClass.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1002
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1003
		(newClass includesSelector:#initialize) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1004
		    Verbose ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1005
			'initialize newClass ...' errorPrintCR
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1006
		    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1007
		    newClass initialize.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1008
		].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1009
		"force cache flush"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1010
		Smalltalk isInitialized ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1011
		    Smalltalk changed.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1012
		]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1013
	    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1014
	] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1015
	    'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1016
	    ' did not define itself' errorPrintCR
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1017
	    "
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1018
	     do not unload - could have installed other classes/methods ...
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1019
	    "
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1020
	].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1021
	^ newClass
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1022
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1023
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1024
    Verbose ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1025
	('no symbol: ', symName,' in ',aFileName) errorPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1026
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1027
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1028
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1029
     unload
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1030
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1031
    Verbose ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1032
	'unloading due to init failure:' errorPrint. handle pathName errorPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1033
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1034
3038
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1035
"/    moreHandles notNil ifTrue:[
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1036
"/        moreHandles do:[:eachHandle |
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1037
"/            Verbose ifTrue:[
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1038
"/                ('unloading: ', eachHandle printString) errorPrintCR.
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1039
"/            ].
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1040
"/            self unloadDynamicObject:eachHandle.
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1041
"/        ]
3ab6b8d3f3a8 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
  1042
"/    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1043
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1044
    Verbose ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1045
	('unloading: ', handle printString) errorPrintCR.
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1046
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1047
    self unloadDynamicObject:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1048
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1049
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1050
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1051
     ObjectFileLoader loadClass:'Tetris'      fromObjectFile:'../clients/Tetris/Tetris.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1052
     ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1053
     ObjectFileLoader loadClass:'Foo'         fromObjectFile:'classList.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1054
    "
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  1055
582
9a00e2dbdc97 must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
  1056
    "Modified: 6.7.1997 / 12:34:48 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1057
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1058
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1059
loadLibrary:aLibraryFileName
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1060
    "load a library; search in some standard places and using
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1061
     standard suffixes (i.e. suffix may be omitted from LibraryFileName).
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1062
     Returns a handle or raise an error.
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1063
     Use this to attach C-libraries."
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1064
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1065
    |suffix suffixes handle libFilename libPath|
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1066
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1067
    Verbose ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1068
	('loadLibrary:' , aLibraryFileName) errorPrintCR.
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1069
    ].
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1070
    libFilename := aLibraryFileName asFilename.
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1071
    (suffix := libFilename suffix) isEmpty ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1072
	suffixes := self validBinaryExtensions
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1073
    ] ifFalse:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1074
	suffixes := Array with:suffix
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1075
    ].
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1076
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1077
    "/ try each suffix ...
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1078
    suffixes do:[:aSuffix |
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1079
	|fn f|
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1080
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1081
	aSuffix isEmptyOrNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1082
	    fn := libFilename.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1083
	] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1084
	    fn := libFilename withSuffix:aSuffix.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1085
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1086
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1087
	Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1088
	    ('loadLibrary try:' , fn asString) errorPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1089
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1090
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1091
	handle := self loadObjectFile:fn.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1092
	handle notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1093
	    ^ handle
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1094
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1095
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1096
	(libFilename isAbsolute
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1097
	 or:[(aLibraryFileName startsWith:'./')
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1098
	 or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1099
	    "/ already tried...
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1100
	] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1101
	    "/ try to load it by name - maybe someone else knows
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1102
	    "/ how to find it (the system itself)
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1103
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1104
	    "/ try each directory in libPath
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1105
	    libPath := self libPath.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1106
	    libPath notEmptyOrNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1107
		libPath asCollectionOfSubCollectionsSeparatedBy:$: do:[:eachSinglePath |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1108
		    f := eachSinglePath asFilename construct:fn.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1109
		    f exists ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1110
			handle := self loadObjectFile:f.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1111
			handle notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1112
			    ^ handle
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1113
			].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1114
		    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1115
		]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1116
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1117
	]
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1118
    ].
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1119
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1120
   ObjectFileLoadError
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1121
	raiseErrorString:('Cannot find or load dll/library: "%1"' bindWith:aLibraryFileName asString).
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1122
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1123
    "
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1124
     ObjectFileLoader loadLibrary:'libc.so.6'
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1125
     ObjectFileLoader loadLibrary:'libjpeg'
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
  1126
     ObjectFileLoader loadLibrary:'odbc32'
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1127
    "
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1128
4194
ac7b50f1d2fa #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4176
diff changeset
  1129
    "Modified: / 04-05-1999 / 17:01:47 / cg"
ac7b50f1d2fa #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4176
diff changeset
  1130
    "Modified: / 20-09-2017 / 20:10:15 / stefan"
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  1131
    "Modified: / 22-07-2018 / 16:40:34 / Stefan Vogel"
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1132
!
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1133
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1134
loadMethodObjectFile:aFileName
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1135
    "load an object file (.o-file) for a single method into the image;
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1136
     This does a slightly different initialization.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1137
     Return an object handle; nil on error"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1138
346
29fe74c22e1e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1139
    |handle initAddr initName m|
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1140
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1141
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1142
    "/ load the objectfile
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1143
    "/
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1144
    handle := self loadDynamicObject:aFileName.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1145
    handle isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1146
	^ nil
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1147
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1148
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1149
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1150
    "/ find the entry function
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1151
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1152
    initName := aFileName asFilename withoutSuffix baseName.
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1153
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1154
    initAddr := self getFunction:'__' , initName , '_Init' from:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1155
    initAddr isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1156
	initAddr := self getFunction:'_' , initName , '_Init' from:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1157
	initAddr isNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1158
	    (self getListOfUndefinedSymbolsFrom:handle) size ~~ 0 ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1159
		self listUndefinedSymbolsIn:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1160
		'ObjectFileLoader [info]: undefined symbols in primitive code' errorPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1161
	    ] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1162
		('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1163
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1164
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1165
	    "/
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1166
	    "/ not found - unload
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1167
	    "/
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1168
	    self unloadDynamicObject:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1169
	    ^ nil
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1170
	]
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1171
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1172
1555
9650c861704b Use class based signals
Stefan Vogel <sv@exept.de>
parents: 1543
diff changeset
  1173
    OSSignalInterrupt handle:[:ex |
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1174
	('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1175
	self unloadDynamicObject:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1176
	^ nil
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1177
    ] do:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1178
	"/
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1179
	"/ call it - it returns the new method object
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1180
	"/
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1181
	self                              "/ registration
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1182
	    saveCallInitFunctionAt:initAddr
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1183
	    in:aFileName
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1184
	    specialInit:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1185
	    forceOld:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1186
	    interruptable:false
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1187
	    argument:0
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1188
	    identifyAs:handle
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1189
	    returnsObject:false.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1190
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1191
	self
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1192
	    saveCallInitFunctionAt:initAddr   "/ global setup
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1193
	    in:aFileName
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1194
	    specialInit:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1195
	    forceOld:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1196
	    interruptable:false
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1197
	    argument:1
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1198
	    identifyAs:handle
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1199
	    returnsObject:false.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1200
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1201
	m := self
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1202
	    saveCallInitFunctionAt:initAddr   "/ initialization
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1203
	    in:aFileName
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1204
	    specialInit:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1205
	    forceOld:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1206
	    interruptable:false
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1207
	    argument:2
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1208
	    identifyAs:handle
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1209
	    returnsObject:true.
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1210
    ].
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1211
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1212
    handle method:m.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1213
    ^ handle
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1214
1942
dffae6fd22d8 oops - initialization of single-method objects needs phase1
Claus Gittinger <cg@exept.de>
parents: 1906
diff changeset
  1215
    "Created: / 05-12-1995 / 20:59:46 / cg"
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1216
    "Modified: / 15-11-2010 / 13:20:36 / cg"
4372
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  1217
    "Modified: / 01-03-2019 / 16:03:41 / Claus Gittinger"
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1218
!
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1219
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1220
loadObjectFile:aFileName
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1221
    "load an object file (.o-file) into the image;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1222
     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
  1223
     This may be either a smalltalk object or a C-object file.
4404
6e531fff6ba8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
  1224
     The object file's init function (if any) is called, and the module
472
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1225
     is unloaded if it returns failure (use lowLevel load, to load a file
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1226
     without automatic initialization).
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1227
     Return nil on error, an objectFile handle if ok."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1228
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1229
    ^ self
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1230
	loadObjectFile:aFileName
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1231
	invokeInitializeMethods:true
4404
6e531fff6ba8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
  1232
6e531fff6ba8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4402
diff changeset
  1233
    "Modified (comment): / 10-04-2019 / 05:47:49 / Claus Gittinger"
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1234
    "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
  1235
!
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1236
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1237
loadObjectFile:pathNameOrFilename invokeInitializeMethods:invokeInitializeMethods
1993
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1238
    "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
  1239
     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
  1240
     This may be either a smalltalk object or a C-object file.
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1241
     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
  1242
     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
  1243
     without automatic initialization).
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1244
     Returns nil on error, or the objectFile's handle if ok."
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1245
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1246
    |filename pathName handle initAddr initDefinitionAddr initFunctionName initNames didInit info status
3736
08585739b27a #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 3723
diff changeset
  1247
     dummyHandle msg isCModule doNotUnload definitionClassName definitionClass cRetVal|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1248
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1249
    filename := pathNameOrFilename asFilename.
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1250
    pathName := filename pathName.
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1251
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1252
    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
  1253
    handle notNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1254
	"already loaded"
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1255
	^ 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
  1256
    ].
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
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1258
    handle := self loadDynamicObject:filename.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1259
    handle isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1260
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1261
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1262
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1263
    didInit := false.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1264
    isCModule := false.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1265
1993
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1266
    "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
  1267
     are to be resolved. If that's the case, load all libraries ..."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1268
3890
b4ef457a02a2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  1269
    ParserFlags searchedLibraries notEmptyOrNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1270
	(self hasUndefinedSymbolsIn:handle) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1271
	    self initializeLoader.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1272
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1273
	    ParserFlags searchedLibraries do:[:libName |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1274
		(self hasUndefinedSymbolsIn:handle) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1275
		    Logger info:'   ... trying  %1 to resolve undefined symbols ...' with:libName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1276
		    dummyHandle := Array new:4.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1277
		    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
228
be9939d96cfe removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
  1278
"/                    dummyHandle isNil ifTrue:[
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  1279
"/                        Transcript showCR:'   ... load of library ' , libName , ' failed.'.
228
be9939d96cfe removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
  1280
"/                    ]
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1281
		]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1282
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1283
	    (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1284
		Logger info:'still undefined symbols in %1.' with:pathName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1285
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1286
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1287
    ].
2882
e7fb69ba1a54 Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents: 2806
diff changeset
  1288
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1289
    "
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1290
     first, expect the classes-name to be the fileNames-baseName
4125
b04f970b47cc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  1291
     (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
  1292
      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
  1293
      scheme as well)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1294
    "
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1295
    initFunctionName := self initFunctionBasenameForFile:filename.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1296
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1297
    "look for explicit initDefinition (xxx_InitDefinition) function
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1298
     This is used in ST packaged classLib object files"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1299
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1300
    (initFunctionName startsWith:'lib') ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1301
	definitionClassName := initFunctionName copyFrom:4.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1302
	definitionClass := Smalltalk classNamed:definitionClassName.
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1303
    ].
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1304
    (definitionClass isNil or:[definitionClass isLoaded not or:[definitionClass isObsolete]]) ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1305
	"the project definition class has not been loaded yet.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1306
	 initialize and load it"
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1307
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1308
	initDefinitionAddr := self findInitDefinitionFunction:initFunctionName in:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1309
	initDefinitionAddr isNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1310
	    ('ObjectFileLoader [warning]: no init definitions for: ' , pathName) infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1311
	] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1312
	    Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1313
		('ObjectFileLoader [info]: calling initDefinition at:' , (initDefinitionAddr printStringRadix:16)) infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1314
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1315
	    info := self
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1316
			performModuleInitAt:initDefinitionAddr
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1317
			invokeInitializeMethods:false
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1318
			for:definitionClassName
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1319
			identifyAs:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1320
	    status := info at:1.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1321
	    status == #ok ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1322
		"/ now, we have only loaded and installed the projectDefinition class.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1323
		"/ (but no containing classes or extensions, yet).
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1324
		"/ let the projectDefinition load any prereqs
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1325
	       definitionClassName notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1326
		    definitionClass := Smalltalk classNamed:definitionClassName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1327
		    definitionClass notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1328
			[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1329
			    definitionClass checkForLoad.   "/ raise exception if not supported on platform / not licensed
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1330
			] on:PackageLoadError do:[:ex|
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1331
			    self unloadObjectFileAndRemoveClasses:pathName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1332
			    ex reject.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1333
			    ^ nil.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1334
			].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1335
			definitionClass isObsolete ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1336
			    "we come here when doing a filein and a (illegal) proceed from the PackageLoadError"
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1337
			    ^ nil.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1338
			].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1339
			definitionClass
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1340
			    initialize;
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1341
			    preLoadAction;
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1342
			    loadMandatoryPreRequisitesAsAutoloaded:false.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1343
		    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1344
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1345
	    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1346
	].
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1347
    ].
1993
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1348
    "look for explicit init (xxx_Init) function
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1349
     This is used in ST object files"
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1350
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1351
    initAddr := self findInitFunction:initFunctionName in:handle.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1352
    initAddr notNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1353
	Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1354
	    ('ObjectFileLoader [info]: calling init at:' , (initAddr printStringRadix:16)) infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1355
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1356
	info := self
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1357
		    performModuleInitAt:initAddr
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1358
		    invokeInitializeMethods:invokeInitializeMethods
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1359
		    for:nil
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1360
		    identifyAs:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1361
	status := info at:1.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1362
	status == #ok ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1363
	    didInit := true.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1364
	    definitionClassName notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1365
		definitionClass := Smalltalk classNamed:definitionClassName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1366
	    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1367
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1368
    ] ifFalse:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1369
	"look for explicit C-init (xxx__Init) function
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1370
	 This is used in C object files"
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1371
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1372
	initAddr := self findFunction:initFunctionName suffix:'__Init' in:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1373
	initAddr notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1374
	    isCModule := true.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1375
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1376
	    OSSignalInterrupt handle:[:ex |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1377
		Logger error:'hard error in initFunction of class-module: %1' with:pathName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1378
		status := #initFailed.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1379
	    ] do:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1380
		cRetVal := self
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1381
		    saveCallInitFunctionAt:initAddr
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1382
		    in:pathNameOrFilename
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1383
		    specialInit:false
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1384
		    forceOld:true
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1385
		    interruptable:false
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1386
		    argument:0
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1387
		    identifyAs:handle
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1388
		    returnsObject:false.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1389
		(cRetVal < 0) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1390
		    Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1391
			'ObjectFileLoader [warning]: init function returns failure ... unload' infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1392
		    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1393
		    status := #initFailed.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1394
		] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1395
		    didInit := true.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1396
		]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1397
	    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1398
	] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1399
	    status := #noInitFunction.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1400
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1401
	    "look for any init-function(s); call them all"
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1402
	    Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1403
		'ObjectFileLoader [info]: no good init functions found; looking for candidates ...' infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1404
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1405
	    initNames := self namesMatching:'*_Init' segment:'[tT?]' in:pathName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1406
	    initNames notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1407
		initNames do:[:aName |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1408
		    initAddr := self getFunction:aName from:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1409
		    initAddr isNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1410
			(aName startsWith:'_') ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1411
			    initAddr := self getFunction:(aName copyFrom:2) from:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1412
			].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1413
		    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1414
		    initAddr isNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1415
			Transcript showCR:('no symbol: ',aName,' in ', pathName).
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1416
		    ] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1417
			Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1418
			    ('ObjectFileLoader [info]: calling init at:' , (initAddr printStringRadix:16)) infoPrintCR
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1419
			].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1420
			self
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1421
			    performModuleInitAt:initAddr
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1422
			    invokeInitializeMethods:invokeInitializeMethods
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1423
			    for:nil
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1424
			    identifyAs:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1425
			didInit := true.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1426
		    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1427
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1428
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1429
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1430
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1431
2457
1927f463ca87 changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
  1432
    (invokeInitializeMethods and:[didInit not]) ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1433
	status == #noInitFunction ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1434
	    msg := 'no classLib init function found; assume load ok'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1435
	] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1436
	    (status ~~ #registrationFailed
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1437
		and:[status ~~ #initFailed
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1438
		and:[status ~~ #missingClass
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1439
		and:[status ~~ #versionMismatch]]])
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1440
	    ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1441
		self listUndefinedSymbolsIn:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1442
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1443
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1444
	    Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1445
		'ObjectFileLoader [warning]: unloading, since init failed ...' infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1446
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1447
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1448
	    "/ give caller a chance to prevent unloading (to register later, when a prerequisite class comes)
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1449
	    status == #missingClass ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1450
		doNotUnload := (SuperClassMissingErrorNotification query ? false).
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1451
	    ] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1452
		status == #registrationFailed ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1453
		    doNotUnload := (RegistrationFailedErrorNotification query ? false).
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1454
		] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1455
		    doNotUnload := false.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1456
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1457
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1458
	    doNotUnload ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1459
		self unloadDynamicObject:handle.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1460
		Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1461
		    'ObjectFileLoader [info]: unloaded.' infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1462
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1463
		handle := nil.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1464
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1465
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1466
	    status == #initFailed ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1467
		msg := 'module not loaded (init function signaled failure).'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1468
	    ] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1469
		status == #missingClass ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1470
		    msg := 'module not loaded (superclass missing: ' , (info at:2) , ').'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1471
		] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1472
		    status == #registrationFailed ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1473
			msg :=  'module registration failed (incompatible object or missing superclass)'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1474
		    ] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1475
			status == #versionMismatch ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1476
			    msg :=  'module registration failed (class version mismatch ' , (info at:2) printString , ')'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1477
			] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1478
			    (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:pathName) notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1479
				msg := 'module not loaded (unknown error reason).'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1480
			    ] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1481
				msg := 'module not loaded (no _Init entry in object file ?).'
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1482
			    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1483
			]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1484
		    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1485
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1486
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1487
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1488
	Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1489
	    Logger debug:'%1: %2' with:pathNameOrFilename asFilename baseName with:msg.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1490
	].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1491
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1492
471
508fa84cb122 no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents: 470
diff changeset
  1493
    isCModule ifFalse:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1494
	Smalltalk flushCachedClasses.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1495
	Class flushSubclassInfo.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1496
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1497
	(definitionClass notNil and:[definitionClass isLoaded and:[definitionClass isObsolete not]]) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1498
	    [
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1499
		definitionClass checkForLoad.   "/ raise exception if not supported on platform / not licensed
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1500
	    ] on:PackageLoadError do:[:ex|
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1501
		self unloadObjectFileAndRemoveClasses:pathName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1502
		ex reject.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1503
		^ nil.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1504
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1505
	    definitionClass
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1506
		initialize;
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1507
		preLoadAction;
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1508
		loadMandatoryPreRequisitesAsAutoloaded:false.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1509
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1510
	Smalltalk isInitialized ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1511
	    "really don't know, if and what has changed ...
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1512
	     ... but assume, that new classes have been installed."
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1513
	    Smalltalk changed:#postLoad.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1514
	].
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
  1515
    ].
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1516
    ^ handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1517
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1518
    "Modified: / 15-11-2010 / 13:19:26 / cg"
4125
b04f970b47cc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  1519
    "Modified (comment): / 13-02-2017 / 20:27:55 / cg"
4584
e40bd4b82075 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4583
diff changeset
  1520
    "Modified: / 17-10-2019 / 14:51:08 / Stefan Vogel"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1521
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1522
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1523
unloadAllObsoleteObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1524
    "unload all dynamically loaded object files for which the classes/method
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1525
     has been already garbage collected."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1526
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1527
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1528
	LoadedObjects values copy do:[:eachHandle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1529
	    (eachHandle notNil and:[eachHandle isObsolete]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1530
		self unloadDynamicObject:eachHandle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1531
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1532
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1533
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1534
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1535
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1536
     ObjectFileLoader unloadAllObsoleteObjectFiles
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1537
    "
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1538
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1539
    "Modified: 5.12.1995 / 18:16:52 / cg"
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1540
!
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1541
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1542
unloadObjectFile:aFilename
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1543
    "unload an object file (.o-file) from the image.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1544
     DANGER ALERT: currently, you have to make sure that no references to
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1545
     objects of this module exist - in future versions, the system will keep
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1546
     track of these. For now, use at your own risk.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1547
     (especially critical are blocks-functions)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1548
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1549
    |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1550
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1551
    handle := self handleForDynamicObject:aFilename.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1552
    handle isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1553
	Logger info:'oops - file to be unloaded was not loaded dynamically (%1)' with:aFilename.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1554
	^ self
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1555
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1556
2348
b2a3bb714bf6 comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents: 2346
diff changeset
  1557
    "/ call the modules deInit-function and unload...
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1558
    self unloadDynamicObject:handle
1961
d58dc341a012 suppressable info messages
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
  1559
d58dc341a012 suppressable info messages
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
  1560
    "Modified: / 06-12-2006 / 18:19:13 / cg"
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1561
    "Modified: / 17-10-2019 / 13:35:52 / Stefan Vogel"
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1562
!
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1563
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1564
unloadObjectFileAndRemoveClasses:aFilename
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1565
    "unload an object file (.o-file) from the image and remove all
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1566
     corresponding classes from the system.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1567
     DANGER ALERT: currently, you have to make sure that no references to
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1568
     objects of this module exist - in future versions, the system will keep
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1569
     track of these. For now, use at your own risk.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1570
     (especially critical are blocks-functions)."
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1571
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1572
    |handle|
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1573
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1574
    handle := self handleForDynamicObject:aFilename.
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1575
    handle isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1576
	Logger info:'oops - file to be unloaded was not loaded dynamically (%1)' with:aFilename.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1577
	^ self
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1578
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1579
    handle isClassLibHandle ifFalse:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1580
	self error:'Module is not a classLib module. Proceed to unload anyway' mayProceed:true.
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1581
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1582
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1583
    "/ remove the classes ...
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1584
    Class withoutUpdatingChangesDo:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1585
	handle classes do:[:eachClass |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1586
	    (eachClass notNil and:[eachClass isMeta not]) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1587
		eachClass removeFromSystem.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1588
	    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  1589
	]
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1590
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1591
2348
b2a3bb714bf6 comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents: 2346
diff changeset
  1592
    "/ call the modules deInit-function and unload...
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1593
    self unloadDynamicObject:handle
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1594
1961
d58dc341a012 suppressable info messages
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
  1595
    "Modified: / 06-12-2006 / 18:19:19 / cg"
4583
18c9ee9d89f4 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 4405
diff changeset
  1596
    "Modified: / 17-10-2019 / 13:38:01 / Stefan Vogel"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1597
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1598
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1599
!ObjectFileLoader class methodsFor:'dynamic object queries'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1600
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1601
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
  1602
    "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
  1603
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1604
    |initAddr className nm|
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1605
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1606
    "/ care for colons, as found in nameSpace classes ...
3499
ca9234a7be8f class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3207
diff changeset
  1607
    nm := functionName asString.
ca9234a7be8f class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3207
diff changeset
  1608
    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
  1609
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1610
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1611
     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
  1612
    "
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1613
    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
  1614
    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
  1615
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1616
    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
  1617
    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
  1618
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1619
    "/
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1620
    "/ 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
  1621
    "/ (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
  1622
    "/ 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
  1623
    "/
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1624
    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
  1625
    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
  1626
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1627
    (functionName startsWith:'lib') ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1628
	className := functionName
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1629
    ] ifFalse:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1630
	"
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1631
	 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
  1632
	"
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1633
	className := functionName. "/ Smalltalk classNameForFile:functionName.
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1634
    ].
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1635
    className notNil ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1636
	initAddr := self getFunction:(className , suffix) from:handle.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1637
	initAddr notNil ifTrue:[^ initAddr].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1638
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1639
	initAddr := self getFunction:('_' , className , suffix) from:handle.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1640
	initAddr isNil ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1641
	    "/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1642
	    "/ special for broken ultrix nlist
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1643
	    "/ (will not find symbol with single underscore)
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1644
	    "/ workaround: add another underscore and retry
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1645
	    "/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1646
	    initAddr := self getFunction:('__' , className , suffix) from:handle.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  1647
	].
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1648
    ].
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1649
    ^ initAddr
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1650
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1651
    "Created: / 13-07-1996 / 00:38:01 / cg"
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1652
    "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
  1653
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1654
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1655
findInitDefinitionFunction:functionName in:handle
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1656
    "look for the initDefinition function and return its address or nil"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1657
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1658
    ^ self findFunction:functionName suffix:'_InitDefinition' in:handle
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1659
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1660
    "Modified: 13.7.1996 / 00:38:33 / cg"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1661
!
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1662
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1663
findInitFunction:functionName in:handle
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1664
    "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
  1665
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1666
    ^ 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
  1667
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1668
    "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
  1669
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1670
1745
1f6a7769faf0 allow for symbol-names
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1671
getFunction:aStringOrSymbol from:handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1672
    "return the address of a function from a dynamically loaded object file.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1673
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1674
     Return the address of the function, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1675
1745
1f6a7769faf0 allow for symbol-names
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1676
    ^ self getSymbol:aStringOrSymbol asString function:true from:handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1677
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1678
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1679
getListOfUndefinedSymbolsFrom:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1680
    "return a collection of undefined symbols in a dynamically loaded object file.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1681
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1682
     Not all systems allow an object with undefined symbols to be
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1683
     loaded (actually, only dld does)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1684
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1685
    |list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1686
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1687
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1688
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1689
    void (*func)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1690
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1691
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1692
    int nMax;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1693
    char **undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1694
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1695
    undefNames = dld_list_undefined_sym();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1696
    if (dld_undefined_sym_count > 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1697
	char **nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1698
	int index;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1699
	int count = dld_undefined_sym_count;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1700
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1701
	if (count > 100) count = 100;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1702
	list = __ARRAY_NEW_INT(count);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1703
	if (list) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1704
	    nm = undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1705
	    for (index = 0; index < count; index++) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1706
		OBJ s;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1707
238
4d80cc4b86dd underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 228
diff changeset
  1708
		s = __MKSTRING(*nm);
4d80cc4b86dd underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 228
diff changeset
  1709
		__ArrayInstPtr(list)->a_element[index] = s;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1710
		__STORE(list, s);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1711
		nm++;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1712
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1713
	    free(undefNames);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1714
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1715
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1716
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1717
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1718
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1719
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1720
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1721
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1722
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1723
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1724
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1725
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1726
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1727
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1728
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1729
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1730
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1731
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1732
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1733
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1734
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1735
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1736
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1737
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1738
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1739
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1740
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1741
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1742
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1743
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1744
     * don't know how to do it
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1745
     */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1746
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1747
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1748
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1749
    ^ list
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1750
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1751
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1752
getSymbol:aString function:isFunction from:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1753
    "return the address of a symbol/function from a dynamically loaded object file.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1754
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1755
     Return the address of the symbol, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1756
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1757
    |sysHandle1 sysHandle2 pathName address|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1758
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1759
    sysHandle1 := aHandle sysHandle1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1760
    sysHandle2 := aHandle sysHandle2.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1761
    pathName := aHandle pathName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1762
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1763
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1764
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1765
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1766
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1767
    void (*func)();
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1768
    unsigned INT addr;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1769
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1770
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  1771
    if (__isStringLike(aString)) {
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1772
	name = (char *) __stringVal(aString);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1773
	if (isFunction == false) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1774
	    addr = dld_get_symbol(name);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1775
	    if (addr) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1776
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1777
		    console_printf("addr of %s = %x\n", name, addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1778
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1779
		address = __MKUINT( addr );
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1780
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1781
	} else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1782
	    func = (void (*) ()) dld_get_func(name);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1783
	    if (func) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1784
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1785
		    console_printf("addr of %s = %x\n", name, (INT)func);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1786
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1787
		if (dld_function_executable_p(name)) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1788
		    address = __MKUINT( (INT)func );
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1789
		} else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1790
		    char **undefNames;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1791
		    char **nm;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1792
		    int i;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1793
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1794
		    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1795
			console_printf ("function %s not executable\n", name);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1796
			dld_perror("not executable");
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1797
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1798
			console_printf("undefined:\n");
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1799
			nm = undefNames = dld_list_undefined_sym();
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1800
			for (i=dld_undefined_sym_count; i; i--) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1801
			    console_printf("    %s\n", *nm++);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1802
			}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1803
			free(undefNames);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1804
		    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1805
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1806
	    } else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1807
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1808
		    console_printf ("function %s not found\n", name);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1809
		    dld_perror("get_func");
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1810
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1811
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1812
	}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1813
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1814
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1815
#endif /* GNU_DL */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1816
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1817
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1818
  {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1819
    void *h;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1820
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1821
    INT val;
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1822
    FARPROC entry;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1823
    HMODULE handle;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1824
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1825
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1826
# if __POINTER_SIZE__ == 8
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1827
	val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1828
# else
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1829
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1830
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1831
	handle = (HMODULE)(val);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1832
	if (__isStringLike(aString)) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1833
	    if (@global(Verbose) == true)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1834
		console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1835
	    entry = GetProcAddress(handle, (char *) __stringVal(aString));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1836
	    if (entry != NULL) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1837
		addr = (void *)entry;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1838
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1839
		    console_printf("GetProcAddr %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1840
		}
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  1841
		address = __MKUINT( (INT)addr );
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1842
	    } else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1843
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1844
		    console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1845
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1846
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1847
	}
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1848
    }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1849
  }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1850
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1851
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1852
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1853
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1854
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1855
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1856
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1857
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1858
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  1859
    if (__isStringLike(aString)) {
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1860
	if (__isStringLike(sysHandle1)) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1861
	    if (@global(Verbose) == true)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1862
		console_printf("get sym <%s> handle = %x\n",
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1863
			__stringVal(aString), __stringVal(sysHandle1));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1864
	    addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1865
	    if (addr) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1866
		if (@global(Verbose) == true)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1867
		    console_printf("addr = %x\n", addr);
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  1868
		address = __MKUINT( (INT)addr );
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1869
	    } else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1870
		if (@global(Verbose) == true)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1871
		    console_printf("dl_getsymbol %s failed\n", __stringVal(aString));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1872
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1873
	}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1874
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1875
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1876
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1877
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1878
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1879
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1880
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1881
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1882
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1883
    OBJ low = sysHandle1, hi = sysHandle2;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1884
    extern void *dlsym();
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1885
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1886
    if (__bothSmallInteger(low, hi)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1887
# if __POINTER_SIZE__ == 8
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1888
	val = (__intVal(hi) << 32) + __intVal(low);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1889
# else
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1890
	val = (__intVal(hi) << 16) + __intVal(low);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1891
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1892
	h = (void *)(val);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1893
	if (__isStringLike(aString)) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1894
	    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1895
		console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)h);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1896
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1897
	    addr = dlsym(h, (char *) __stringVal(aString));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1898
	    if (addr) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1899
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1900
		    console_printf("dlsym %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1901
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1902
		address = __MKUINT( (INT)addr );
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1903
	    } else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1904
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1905
		    console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1906
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1907
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1908
	}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1909
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1910
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1911
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1912
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1913
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1914
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1915
    void *h;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1916
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1917
    INT val, ret;
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1918
    OBJ low = sysHandle1, hi = sysHandle2;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1919
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1920
    if (__bothSmallInteger(low, hi)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1921
# if __POINTER_SIZE__ == 8
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1922
	val = (__intVal(hi) << 32) + __intVal(low);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1923
# else
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1924
	val = (_intVal(hi) << 16) + _intVal(low);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1925
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1926
	h = (void *)(val);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1927
	if (__isStringLike(aString)) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1928
	    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1929
		console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1930
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1931
	    ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1932
	    if (ret != 0) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1933
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1934
		    console_printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1935
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1936
	    } else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1937
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1938
		    console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1939
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1940
		address = __MKUINT( (INT)addr );
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1941
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1942
	}
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1943
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1944
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1945
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1946
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1947
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1948
#ifdef AIX_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1949
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1950
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1951
    void *addr;
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1952
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1953
    struct nlist nl[2];
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1954
    OBJ low = sysHandle1, hi = sysHandle2;
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1955
    char nameBuffer[256];
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1956
    static struct funcDescriptor {
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1957
	unsigned vaddr;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1958
	unsigned long2;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1959
	unsigned long3;
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1960
    } descriptor;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1961
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1962
    if (__bothSmallInteger(low, hi)
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  1963
     && __isStringLike(aString) && __isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1964
# if __POINTER_SIZE__ == 8
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1965
	val = (__intVal(hi) << 32) + __intVal(low);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1966
# else
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1967
	val = (__intVal(hi) << 16) + __intVal(low);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1968
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1969
	h = (void *)(val);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1970
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1971
	if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1972
	    console_printf("get sym <%s> handle = %x path= %s\n",
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1973
			__stringVal(aString), h, __stringVal(pathName));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1974
	}
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1975
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1976
#define USE_ENTRY
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1977
#ifdef USE_ENTRY
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1978
	/*
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1979
	 * only works, if the entry-function is the Init function
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1980
	 * (i.e. linked with -e _xxx_Init)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1981
	 */
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1982
	if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1983
	    console_printf("returned handle as addr = %x\n", h);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1984
	}
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  1985
	address = __MKUINT( (INT)(h) );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1986
#else
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1987
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1988
# ifdef USE_DESCRIPTOR
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1989
	if (isFunction == true) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1990
# else
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1991
	if (0) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1992
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1993
	    nameBuffer[0] = '.';
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1994
	    strcpy(nameBuffer+1, aString);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1995
	    nl[0].n_name = nameBuffer;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1996
	} else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1997
	    nl[0].n_name = __stringVal(aString);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1998
	}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  1999
	nl[1].n_name = "";
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2000
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2001
	if (nlist(__stringVal(pathName), &nl) == -1) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2002
	    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2003
		console_printf("nlist error\n");
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2004
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2005
	} else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2006
	    addr = (void *)((unsigned)nl[0].n_value + (unsigned)h);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2007
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2008
	    if (isFunction == true) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2009
# ifdef USE_DESCRIPTOR
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2010
		console_printf("daddr = %x\n", addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2011
		console_printf("daddr[0] = %x\n", ((long *)addr)[0]);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2012
		console_printf("daddr[1] = %x\n", ((long *)addr)[1]);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2013
		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
  2014
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2015
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2016
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2017
	    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2018
		console_printf("value=%x section=%d type=%x sclass=%d\n",
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2019
			nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2020
		console_printf("vaddr = %x\n", addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2021
	    }
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2022
# ifdef DOES_NOT_WORK
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  2023
	    address = __MKUINT( (INT)addr );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2024
# else
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  2025
	    descriptor.vaddr = (unsigned INT) addr;
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2026
	    descriptor.long2 = 0;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2027
	    descriptor.long3 = 0;
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  2028
	    address = __MKUINT( (INT)(&descriptor) );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2029
# endif
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2030
	}
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  2031
#endif /* don't USE_ENTRY */
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2032
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2033
  }
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2034
#endif /* AIX_DL */
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2035
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  2036
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2037
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2038
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2039
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2040
    void *addr;
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  2041
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2042
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2043
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2044
    if (__bothSmallInteger(low, hi)) {
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2045
	val = (_intVal(hi) << 16) + _intVal(low);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2046
	h = (void *)(val);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2047
	if (__isStringLike(aString)) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2048
	    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2049
		console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2050
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2051
	    addr = dlsym(h, __stringVal(aString));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2052
	    if (addr) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2053
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2054
		    console_printf("addr = %x\n", addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2055
		}
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  2056
		address = __MKUINT( (INT)addr );
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2057
	    } else {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2058
		if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2059
		    console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2060
		}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2061
	    }
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2062
	}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2063
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2064
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2065
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2066
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  2067
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2068
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2069
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2070
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2071
    long result;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2072
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2073
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  2074
    if (__isStringLike(aString)) {
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2075
	if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2076
	    console_printf("get sym <%s>\n", __stringVal(aString));
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2077
	}
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2078
	errOut = NXOpenFile(2, 2);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2079
	result = rld_lookup(errOut,
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2080
			    (char *) __stringVal(aString),
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2081
			    &addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2082
	NXClose(errOut);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2083
	if (result) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2084
	    if (@global(Verbose) == true) {
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2085
		console_printf("addr = %x\n", addr);
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2086
	    }
3723
afb01ba96a0a mingw64 fix
Claus Gittinger <cg@exept.de>
parents: 3722
diff changeset
  2087
	    address = __MKUINT( (INT)addr );
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2088
	}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2089
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2090
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2091
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2092
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2093
%}.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2094
    ^ address
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2095
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2096
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2097
hasUndefinedSymbolsIn:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2098
    "return true, if a module has undefined symbols in it.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2099
     This is only possible if the system supports loading
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2100
     modules with undefined things in it - most do not"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2101
4372
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2102
    ^ (self getListOfUndefinedSymbolsFrom:handle) size ~~ 0
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2103
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2104
    "Modified: / 25-04-1996 / 09:47:27 / cg"
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2105
    "Modified: / 01-03-2019 / 16:03:33 / Claus Gittinger"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2106
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2107
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2108
initFunctionBasenameForFile:pathNameOrFilename
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2109
    "return the expected initFunction's name, given a fileName"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2110
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2111
    |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
  2112
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2113
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2114
     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
  2115
    "
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2116
    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
  2117
    suffixLen := 0.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2118
    self validBinaryExtensions do:[:suffix |
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2119
	suffixLen == 0 ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2120
	    (fileName hasSuffix:suffix) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2121
		suffixLen := suffix size + 1
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2122
	    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2123
	]
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2124
    ].
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2125
    name := fileName baseName.
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
  2126
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2127
    suffixLen ~~ 0 ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2128
	name := name copyButLast:suffixLen
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2129
    ] ifFalse:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2130
	('ObjectFileLoader [warning]: invalid binary object file suffix in: ',fileName name) infoPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2131
	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
  2132
    ].
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2133
    ^ name.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2134
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2135
    "
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2136
     ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.so'  (unix)
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2137
     ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.dll' (msdos)
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2138
     ObjectFileLoader initFunctionBasenameForFile:'demo.so'
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2139
     ObjectFileLoader initFunctionBasenameForFile:'demo.o'
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2140
     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
  2141
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2142
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  2143
    "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
  2144
    "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
  2145
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2146
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2147
isCPlusPlusObject:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2148
    "return true, if the loaded object is a c++ object module.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2149
     This is not yet fully implemented/supported."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2150
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2151
    (self getSymbol:'__gnu_compiled_cplusplus' function:true from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2152
    (self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2153
    (self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2154
    (self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2155
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2156
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2157
    "Modified: 25.4.1996 / 09:48:19 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2158
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2159
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2160
isObjectiveCObject:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2161
    "return true, if the loaded object is an objective-C object module.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2162
     This is not yet implemented/supported"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2163
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2164
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2165
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2166
    "Modified: 25.4.1996 / 09:47:59 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2167
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2168
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2169
isSmalltalkObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2170
    "return true, if the loaded object is a smalltalk object module"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2171
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2172
    "not yet implemented - stc_compiled_smalltalk is a static symbol,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2173
     not found in list - need nm-interface, or nlist-walker
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2174
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2175
    ^ true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2176
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
  2177
"/    (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
  2178
"/    (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
  2179
"/    ^ false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2180
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2181
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2182
listUndefinedSymbolsIn:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2183
    "list undefined objects in a module on the transcript"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2184
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2185
    |undefinedNames|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2186
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2187
    undefinedNames := self getListOfUndefinedSymbolsFrom:handle.
4372
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2188
    undefinedNames size ~~ 0 ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2189
	Transcript showCR:'ObjectFileLoader [info]: undefined:'.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2190
	undefinedNames do:[:aName |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2191
	    Transcript showCR:'    ' , aName
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2192
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2193
    ].
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2194
4372
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2195
    "Modified: / 18-05-1996 / 15:43:45 / cg"
f5a6b4abcfa8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4286
diff changeset
  2196
    "Modified: / 01-03-2019 / 16:03:37 / Claus Gittinger"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2197
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2198
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2199
namesMatching:aPattern segment:segmentPattern in:aPathName
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2200
    "search for entries which match a pattern.
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2201
     This is obsolete & rubbish - it will vanish soon"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2202
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2203
    |p l s addr segment name entry|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2204
766
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2205
    OperatingSystem isVMSlike ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2206
	"/ no nm command
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2207
	^ nil
766
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2208
    ].
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2209
    OperatingSystem isMSDOSlike ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2210
	"/ no nm command
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2211
	^ nil
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2212
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2213
    OperatingSystem getOSType = 'aix' ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2214
	"/ no useful nm info
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2215
	^ nil
749
86cf38f5a961 win32 change.
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  2216
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2217
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2218
    l := OrderedCollection new.
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2219
    p := PipeStream readingFrom:(self nm:aPathName).
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2220
    p isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2221
	('ObjectFileLoader [info]: cannot read names from ' , aPathName) infoPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2222
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2223
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2224
    [p atEnd] whileFalse:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2225
	entry := p nextLine.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2226
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2227
	    entry errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2228
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2229
	entry notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2230
	    s := ReadStream on:entry.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2231
	    addr := s nextAlphaNumericWord.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2232
	    s skipSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2233
	    segment := s upToSeparator.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2234
	    s skipSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2235
	    name := s upToEnd withoutSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2236
	    (addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2237
		(aPattern match:name) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2238
		    (segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2239
			l add:name.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2240
			Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2241
			    ('found name: ' , name) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2242
			]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2243
		    ] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2244
			Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2245
			    name errorPrint. ' segment mismatch ' errorPrint.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2246
			    segmentPattern errorPrint. ' ' errorPrint. segment errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2247
			]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2248
		    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2249
		]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2250
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2251
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2252
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2253
    p close.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2254
    ^ l
225
122d8ff18aff nicer message
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
  2255
749
86cf38f5a961 win32 change.
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  2256
    "Modified: / 27.7.1998 / 20:10:57 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2257
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2258
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2259
releaseSymbolTable
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2260
    "this is needed on NeXT to forget loaded names. If this wasnt done,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2261
     the same class could not be loaded in again due to multiple defines.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2262
     On other architectures, this is not needed and therefore a noop."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2263
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2264
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2265
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2266
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2267
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2268
    errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2269
    rld_unload_all(errOut, (long)0);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2270
    rld_load_basefile(errOut, "smalltalk");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2271
    NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2272
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2273
%}
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2274
! !
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2275
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  2276
!ObjectFileLoader class methodsFor:'image save/restart'!
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2277
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2278
invalidateAndRememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2279
    "invalidate code refs into all dynamically loaded object files.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2280
     Required before writing a snapshot image."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2281
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2282
    LoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2283
	ActuallyLoadedObjects := LoadedObjects.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2284
	self rememberAllObjectFiles.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2285
	ActuallyLoadedObjects keys do:[:aFileName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2286
	    |handle|
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2287
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2288
	    handle := ActuallyLoadedObjects at:aFileName.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2289
	    handle isNil ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2290
		self error:'oops, no handle'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2291
	    ] ifFalse:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2292
		(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2293
		    self invalidateModule:handle
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2294
		]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2295
	    ]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2296
	].
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2297
	LoadedObjects := nil.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2298
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2299
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2300
    "Created: 5.10.1995 / 15:48:56 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2301
    "Modified: 5.10.1995 / 16:48:51 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2302
    "Modified: 12.7.1996 / 17:13:45 / cg"
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2303
!
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2304
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2305
reloadAllRememberedObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2306
    "reload all object modules as were loaded when the image was saved.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2307
     Some care has to be taken, if files are missing or otherwise corrupted."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2308
2882
e7fb69ba1a54 Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents: 2806
diff changeset
  2309
    |oldDummyMethod who newHandle
e7fb69ba1a54 Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents: 2806
diff changeset
  2310
     savedOldClasses functions saveOldMethodsPerClass anyModulesToInitialize m|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2311
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2312
    PreviouslyLoadedObjects notNil ifTrue:[
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2313
	anyModulesToInitialize := false.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2314
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2315
	PreviouslyLoadedObjects do:[:entry |
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2316
	    |fileName handle cls sel|
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2317
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2318
	    fileName := entry key.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2319
	    handle := entry value.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2320
	    handle moduleID:nil.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2321
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2322
	    handle isClassLibHandle ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2323
		"/ ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2324
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2325
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2326
		"/ remember all byteCode methods (as added in the session)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2327
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2328
		savedOldClasses := IdentitySet new.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2329
		saveOldMethodsPerClass := IdentityDictionary new.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2330
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2331
		handle classes do:[:eachClass |
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2332
		    (eachClass notNil and:[eachClass ~~ 0]) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2333
			saveOldMethodsPerClass at:eachClass put:eachClass methodDictionary copy.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2334
			savedOldClasses add:eachClass.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2335
		    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2336
		].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2337
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2338
		"/ load the class binary
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2339
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2340
		handle := self loadObjectFile:fileName invokeInitializeMethods:false.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2341
		handle notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2342
		    anyModulesToInitialize := true
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2343
		].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2344
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2345
		"/ after reloading of the objectFile,
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2346
		"/ some of the changes made in the previous life have to be
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2347
		"/ redone here - otherwise, we will be left with the
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2348
		"/ state contained in the loaded objectModule - instead of
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2349
		"/ what we had when saving the image ...
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2350
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2351
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2352
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2353
		"/ re-remove removed methods
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2354
		"/ and re-change method categories
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2355
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2356
		savedOldClasses do:[:oldClass |
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2357
		    |newClass oldMethods newMethodDict newMthd
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2358
		     oldCat oldClassVarString oldClassCategory|
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2359
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2360
		    newClass := Smalltalk classNamed:(oldClass name).
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2361
		    newClass notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2362
			oldClassVarString := oldClass classVariableString.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2363
			newClass classVariableString ~= oldClassVarString ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2364
			    "/ there is no need to recreate the variable
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2365
			    "/ (its in the smalltalk dictionary)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2366
			    newClass setClassVariableString:oldClassVarString
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2367
			].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2368
			newClass isMeta ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2369
			    newClass setSharedPoolNames:(oldClass sharedPoolNames).
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2370
			    oldClassCategory := oldClass category.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2371
			    newClass category ~= oldClassCategory ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2372
				newClass setCategory:oldClassCategory
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2373
			    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2374
			].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2375
			oldMethods := saveOldMethodsPerClass at:oldClass.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2376
			newMethodDict := newClass methodDictionary.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2377
			oldMethods keysAndValuesDo:[:selector :oldMethod|
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2378
			    oldMethod
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2379
				code:nil;
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2380
				mclass:self.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2381
			    oldMethod byteCode isNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2382
				"a compiled method, load the new code (addresses may have been changed)"
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2383
				newMthd := newMethodDict at:selector ifAbsent:nil.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2384
				newMthd notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2385
				     oldMethod code:newMthd code.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2386
				] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2387
				    ('ObjectFileLoader [warning]: ' , oldClass name , ' missing method: ', selector, '.') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2388
				].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2389
			    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2390
			].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2391
			newClass setMethodDictionary:oldMethods.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2392
		    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2393
		].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2394
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2395
		"/
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2396
		"/ validate old-classes vs. new classes.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2397
		"/ and if things look ok, get rid of old stuff
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2398
		"/ and make instances become instances of the new class
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2399
		"/
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2400
"/                ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR.
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2401
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2402
		savedOldClasses do:[:oldClass |
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2403
		    |newClass oldCat oldCVars|
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2404
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2405
		    newClass := Smalltalk classNamed:(oldClass name).
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2406
		    newClass == oldClass ifTrue:[
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2407
"/                        ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR.
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2408
		    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2409
			(newClass isNil or:[newClass == oldClass]) ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2410
			    ('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2411
			] ifFalse:[
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2412
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2413
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2414
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2415
			    oldClass instSize ~~ newClass instSize ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2416
				('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2417
			    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2418
				oldClass class instSize ~~ newClass class instSize ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2419
				    ('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2420
				] ifFalse:[
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2421
"/                                    ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR.
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2422
				    (oldCat := oldClass category) ~= newClass category ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2423
					newClass setCategory:oldCat.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2424
				    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2425
				    (oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2426
					newClass setClassVariableString:oldCVars
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2427
				    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2428
				    "/ copy over the oldClasses class-instVars
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2429
				    (Class instSize + 1) to:(oldClass class instSize) do:[:idx |
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2430
					newClass instVarAt:idx put:(oldClass instVarAt:idx)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2431
				    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2432
				    oldClass becomeSameAs:newClass
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2433
"/                                    oldClass become:newClass
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2434
				]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2435
			    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2436
			]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2437
		    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2438
		]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2439
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2440
	    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2441
		handle isMethodHandle ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2442
		    oldDummyMethod := handle method.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2443
		    (oldDummyMethod isMethod) ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2444
			('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2445
		    ] ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2446
			('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2447
			who := oldDummyMethod who.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2448
			newHandle := self loadMethodObjectFile:fileName.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2449
			newHandle isNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2450
			    ('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2451
			    handle moduleID:nil.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2452
			] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2453
			    m := newHandle method.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2454
			    oldDummyMethod sourceFilename notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2455
				m sourceFilename:(oldDummyMethod sourceFilename)
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2456
				  position:(oldDummyMethod sourcePosition).
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2457
			    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2458
				m source:(oldDummyMethod source).
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2459
			    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2460
			    m setPackage:(oldDummyMethod package).
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2461
			    who notNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2462
				cls := who methodClass.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2463
				sel := who methodSelector.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2464
				m == (cls compiledMethodAt:sel) ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2465
				    'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2466
				] ifTrue:[
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2467
"/                                  cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod).
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2468
				]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2469
			    ].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2470
			]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2471
		    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2472
		] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2473
		    handle isFunctionObjectHandle ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2474
			functions := handle functions.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2475
			functions isEmpty ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2476
			    ('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2477
			] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2478
			    newHandle := self loadDynamicObject:fileName.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2479
			    newHandle isNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2480
				('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2481
				handle moduleID:nil.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2482
			    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2483
				('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2484
				functions do:[:eachFunction |  |addr|
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2485
				    addr := newHandle getFunctionAddress:(eachFunction name) into:eachFunction.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2486
				    addr isNil ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2487
					('ObjectFileLoader [info]: function: ''' , eachFunction name , ''' no longer present.') errorPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2488
					eachFunction invalidate.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2489
				    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2490
					eachFunction setModuleHandle:newHandle.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2491
					('ObjectFileLoader [info]: rebound function: ''' , eachFunction name , '''.') infoPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2492
				    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2493
				].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2494
				handle becomeSameAs:newHandle.      "/ the old handle is now void
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2495
			    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2496
			]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2497
		    ] ifFalse:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2498
			('ObjectFileLoader [info]: ignore invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2499
		    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2500
		]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2501
	    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2502
	].
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2503
	PreviouslyLoadedObjects := nil.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2504
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2505
	"/ now, as we hopefully have all loaded,
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2506
	"/ send #reinitializeAfterLoad to each of them
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2507
	anyModulesToInitialize ifTrue:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2508
	    AbortOperationRequest catch:[
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2509
		self moduleInit:4 forceOld:false interruptable:true.
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2510
	    ]
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  2511
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2512
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2513
2472
8ae818e74044 changed: #reloadAllRememberedObjectFiles
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  2514
    "Modified: / 18-01-2011 / 20:42:57 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2515
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2516
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2517
rememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2518
    "remember all loaded objectModules in the
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  2519
     PreviouslyLoadedObjects classVariable.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2520
     Called when an image is restarted to reload all modules which
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2521
     were loaded in the previous life"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2522
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2523
    LoadedObjects notNil ifTrue:[
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2524
	PreviouslyLoadedObjects := OrderedCollection new.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2525
	LoadedObjects keysAndValuesDo:[:name :handle |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2526
	    handle isObsolete ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2527
		('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2528
	    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2529
		PreviouslyLoadedObjects add:(name -> handle)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2530
	    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2531
	].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2532
	PreviouslyLoadedObjects sort:[:a :b |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2533
		|h1 h2|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2534
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2535
		h1 := a value moduleID.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2536
		h2 := b value moduleID.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2537
		h1 isNil
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2538
		    ifTrue:[true]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2539
		    ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2540
			h2 isNil
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2541
			    ifTrue:[false]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2542
			    ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2543
				h1 < h2
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2544
			    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2545
		    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2546
	].
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2547
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2548
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2549
    "Created: 5.12.1995 / 20:51:07 / cg"
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2550
    "Modified: 10.1.1997 / 15:06:25 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2551
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2552
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2553
revalidateAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2554
    "revalidate code refs into all dynamically loaded object files.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2555
     Required after writing a snapshot image."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2556
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2557
    ActuallyLoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2558
	ActuallyLoadedObjects keys do:[:aFileName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2559
	    |handle|
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2560
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2561
	    handle := ActuallyLoadedObjects at:aFileName.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2562
	    handle isNil ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2563
		self error:'oops, no handle'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2564
	    ] ifFalse:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2565
		(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2566
		    self revalidateModule:handle
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2567
		]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2568
	    ]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2569
	].
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2570
	LoadedObjects := ActuallyLoadedObjects.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2571
	ActuallyLoadedObjects := PreviouslyLoadedObjects := nil.
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2572
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2573
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2574
    "Created: 5.10.1995 / 15:49:08 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2575
    "Modified: 5.10.1995 / 16:49:18 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2576
    "Modified: 12.7.1996 / 17:14:48 / cg"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2577
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2578
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2579
unloadAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2580
    "unload all dynamically loaded object files from the image.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2581
     see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2582
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2583
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2584
	LoadedObjects values copy do:[:eachHandle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2585
	    eachHandle notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2586
		self unloadDynamicObject:eachHandle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2587
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2588
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2589
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2590
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2591
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2592
     ObjectFileLoader unloadAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2593
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2594
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2595
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2596
unloadAndRememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2597
    "remember all modules and unload them"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2598
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2599
    LoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2600
	self rememberAllObjectFiles.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2601
	self unloadAllObjectFiles
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2602
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2603
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2604
    "Modified: 25.4.1996 / 09:46:27 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2605
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2606
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  2607
!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
  2608
4267
692f8ce72b36 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4253
diff changeset
  2609
createLoadableObjectFor:baseFilenameString
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2610
    "given an oFile, arrange for it to be loadable.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2611
     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
  2612
     -shared option into a .so file;
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2613
     DLD based loaders (linux a.out) can directly load a .o file;
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2614
     Other systems may require more ..."
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2615
4267
692f8ce72b36 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4253
diff changeset
  2616
    |osType baseFilename oFileName soFileName expFileName librunExpFileName
4401
4e87a9cca486 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
  2617
     needSharedObject linker ld ldArg expFile ok outfile output libDir libDirBasename
3054
269b9da32620 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3052
diff changeset
  2618
     errorMessage homeDir fmt|
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2619
750
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2620
    osType := OperatingSystem getOSType.
4267
692f8ce72b36 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4253
diff changeset
  2621
    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
  2622
4401
4e87a9cca486 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
  2623
    linker := Filename possiblyQuotedPathname:(self linkCommand).
4e87a9cca486 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
  2624
2025
00f8564566e8 No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents: 2012
diff changeset
  2625
    osType = #win32 ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2626
	self activityNotification:'generating shared object'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2627
	ParserFlags linkArgs isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2628
	    ld := linker , ' ' , (Filename possiblyQuotedPathname:(baseFilenameString,'.obj')).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2629
	    ld := ld
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2630
	       , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2631
	       , ' /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
  2632
"/               , ' /DEF:' , baseFileName , '.def'.
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2633
	] ifFalse:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2634
"/            libDir := ParserFlags libDirectory.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2635
"/            (libDir notNil and:[libDir asFilename exists]) ifFalse:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2636
		ParserFlags useBorlandC ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2637
		    libDirBasename := 'lib\bc'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2638
		] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2639
		    ParserFlags useVisualC ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2640
			libDirBasename := 'lib\vc'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2641
		    ] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2642
			(ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2643
			    libDirBasename := 'lib\mingw'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2644
			] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2645
			    libDirBasename := 'lib\vc'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2646
			]
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2647
		    ]
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2648
		].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2649
		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
  2650
		homeDir notNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2651
		    libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2652
		].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2653
		libDir isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2654
		    "/ some fallback
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2655
		    libDir := #( '..'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2656
				 '..\..'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2657
				 '..\..\..'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2658
				 '..\..\stx'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2659
				 '..\..\..\stx'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2660
			       ) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2661
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2662
		    libDir isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2663
			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
  2664
			ObjectFileLoadError raiseRequestErrorString:errorMessage.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2665
			^ nil
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2666
		    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2667
		].
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2668
"/            ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2669
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2670
	    ParserFlags useBorlandC ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2671
		ld := linker , ' ' , (ParserFlags linkArgs bindWith:baseFilenameString).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2672
		ld := ld , ' c0d32.obj ' , (Filename possiblyQuotedPathname:(baseFilenameString , '.obj')).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2673
		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
  2674
		ld := ld , ' ',(ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2675
		ld := ld , ' ',libDir,'\cs32i.lib,,'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2676
	    ] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2677
		ParserFlags useVisualC ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2678
		    "/ todo: fix for correct link libs
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2679
		    ld := linker , ' ' , (ParserFlags linkArgs bindWith:baseFilenameString).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2680
		    ld := ld , ' c0d32.obj ' , (Filename possiblyQuotedPathname:(baseFilenameString,'.obj')).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2681
		    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
  2682
		    ld := ld , ' ',(ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2683
		    ld := ld , ' ',libDir,'\cs32i.lib,,'.
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
		    (ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2686
			ld := linker , ' ' , (ParserFlags linkArgs bindWith:baseFilenameString).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2687
			ld := ld , ' -shared -o ',(Filename possiblyQuotedPathname:(baseFilenameString,'.dll')).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2688
			ld := ld , ' ',(Filename possiblyQuotedPathname:(baseFilenameString,'.obj')).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2689
			ld := ld , ' ',libDir,'\librun.lib'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2690
			ld := ld , ' ',(ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2691
		    ] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2692
			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
  2693
			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
  2694
			^ nil
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2695
		    ]
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
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2699
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2700
	outfile := (Filename possiblyQuotedPathname:(baseFilenameString , '.out')).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2701
	(Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2702
	    Transcript showCR:('executing: ',ld).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2703
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2704
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2705
	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
  2706
	ok ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2707
	    output := (baseFilenameString , '.out') asFilename contentsOfEntireFile.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2708
	    Transcript showCR:'********************'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2709
	    Transcript showCR:'Failed linkCommand:'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2710
	    Transcript showCR:ld.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2711
	    Transcript showCR:'ParserFlags are:'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2712
	    Transcript showCR:ParserFlags.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2713
	    Transcript showCR:'--------------------'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2714
	    Transcript showCR:output; endEntry.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2715
	    Transcript showCR:'********************'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2716
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2717
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2718
	#('obj' 'out' 'tds' 'ilc' 'ild'
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2719
	  'ilf' 'ils' 'lib' 'map' 'def' 'o') do:[:eachSuffix|
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2720
	    (baseFilename withSuffix:eachSuffix) removeFile.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2721
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2722
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2723
	ok ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2724
	    LastError := output.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2725
	    "/ ObjectFileLoadError raiseRequestErrorString:'link failed'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2726
	    ^ nil
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2727
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2728
	oFileName := (baseFilename withSuffix:self sharedLibrarySuffix) name.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2729
	^ oFileName
750
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2730
    ].
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2731
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2732
    "/ UNIX systems
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2733
4401
4e87a9cca486 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4372
diff changeset
  2734
    ld := linker ? 'ld'.
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
  2735
    needSharedObject := false.
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2736
4005
9567885ed8a7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3999
diff changeset
  2737
    fmt := self loadableBinaryObjectFormat.
4405
a8cd0c4d4599 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
  2738
    (fmt == #elf or:[ fmt == #macho ]) ifTrue:[
4635
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
	 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
  2741
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2742
	needSharedObject := true.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2743
	ld := linker ? 'cc'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2744
	ldArg := self linkSharedArgs.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2745
	ldArg isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2746
	    "/ some default
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2747
	    ExternalBytes sizeofPointer == 4 ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2748
		ldArg := '-m32 -shared'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2749
	    ] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2750
		ldArg := '--shared'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2751
	    ]
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2752
	]
3052
432f183d0ec2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3051
diff changeset
  2753
    ].
432f183d0ec2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3051
diff changeset
  2754
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2755
    osType = #irix ifTrue:[
4635
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
	 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
  2758
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2759
	needSharedObject := true.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2760
	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
  2761
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2762
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2763
    osType = #'sys5_4' ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2764
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2765
	 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
  2766
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2767
	needSharedObject := true.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2768
	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
  2769
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2770
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2771
    osType = #solaris ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2772
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2773
	 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
  2774
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2775
	needSharedObject := true.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2776
	ldArg := self linkSharedArgs ? '-G -Bdynamic'.
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2777
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2778
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2779
    osType = #hpux ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2780
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2781
	 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
  2782
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2783
	needSharedObject := true.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2784
	ldArg := self linkSharedArgs ? '-b -B immediate'.
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2785
    ].
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2786
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2787
    osType = #aix ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2788
	self activityNotification:'create export file'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2789
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2790
	"/ create an exports file.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2791
	expFileName := './' , baseFilenameString , '.exp'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2792
	[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2793
	    expFile := expFileName asFilename writeStream.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2794
	    expFile nextPutAll:'#!! ./' , baseFilenameString , '.', self sharedLibrarySuffix.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2795
	    expFile cr.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2796
	    expFile nextPutAll:'_' , baseFilenameString , '_Init'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2797
	    expFile close.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2798
	] on:OpenError do:[:ex| "do nothing"].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2799
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2800
	self activityNotification:'generating shared object'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2801
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2802
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2803
	 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
  2804
	"
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2805
	needSharedObject := true.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2806
	ld := 'cc'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2807
	librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2808
	librunExpFileName isNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2809
	    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
  2810
	    ^ nil
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2811
	].
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
	ldArg := '-bI:' , librunExpFileName ,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2814
		' -bE:' , baseFilenameString , '.exp' ,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2815
		' -bM:SRE -e _' , baseFilenameString , '_Init'.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2816
    ].
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2817
4267
692f8ce72b36 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4253
diff changeset
  2818
    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
  2819
    needSharedObject ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2820
	self activityNotification:'generating shared object'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2821
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2822
	soFileName := baseFilename withSuffix:self sharedLibrarySuffix.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2823
	soFileName removeFile.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2824
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2825
	ld := ld , ' ' , ldArg , ' ', (ParserFlags linkArgs ? '') ,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2826
		 ' -o ' , soFileName name, ' ' , oFileName name , ' ',
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2827
		 ((ParserFlags searchedLibraries  ? #()) asStringCollection asStringWith: $ ).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2828
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2829
	(Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2830
	    Transcript showCR:('linking with: ',ld).
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2831
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2832
	ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1').
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2833
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2834
	ok ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2835
	    output := 'errorOutput' asFilename contentsOfEntireFile.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2836
	    Transcript showCR:'********************'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2837
	    Transcript showCR:'linker command:'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2838
	    Transcript showCR:ld; endEntry.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2839
	    Transcript showCR:'--------------------'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2840
	    Transcript showCR:'linker error message:'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2841
	    Transcript showCR:output.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2842
	    Transcript showCR:'********************'.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2843
	].
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
	oFileName removeFile.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2846
	expFileName notNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2847
	    expFileName asFilename removeFile.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2848
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  2849
	^ soFileName name.
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2850
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2851
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2852
    "
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2853
     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
  2854
    "
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2855
    ^ oFileName
698
fc359ff36687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  2856
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  2857
    "Modified: / 29-07-2004 / 17:29:44 / stefan"
4134
dc9e0e942bfb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4128
diff changeset
  2858
    "Modified: / 25-02-2017 / 09:18:42 / cg"
4402
365edc34920c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2859
    "Modified: / 28-03-2019 / 16:29:48 / Claus Gittinger"
4405
a8cd0c4d4599 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
  2860
    "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
  2861
! !
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2862
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2863
!ObjectFileLoader class methodsFor:'lowlevel object loading'!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2864
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2865
initializeLoader
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2866
    "initialize dynamic loader if required"
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  2867
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2868
    |stxName stxPathName|
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2869
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2870
    stxPathName := OperatingSystem pathOfSTXExecutable.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2871
%{
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2872
#ifdef GNU_DL
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2873
  {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2874
    static alreadyInitialized = 0;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2875
    extern dld_ignore_redefinitions;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2876
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2877
    if (! alreadyInitialized) {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2878
	alreadyInitialized = 1;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2879
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2880
	if (@global(Verbose) == true) {
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  2881
	    console_printf ("dld_init(%s)\n", __stringVal(stxPathName));
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2882
	}
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2883
	/*
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2884
	 * dld requires the running executables name,
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2885
	 * to resolve symbols.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2886
	 */
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2887
	(void) dld_init (__stringVal(stxPathName));
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2888
	dld_ignore_redefinitions = 1;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2889
    }
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2890
  }
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2891
#endif
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2892
%}.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2893
!
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2894
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2895
loadDynamicObject:pathNameOrFilename
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2896
    "load an object-file (load/map into my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2897
     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
  2898
     No bindings or automatic initializations are done
472
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2899
     - only a pure (low-level) load is performed.
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2900
     For class-files or C-objects to be loaded with this method,
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2901
     it is your responsibility to fetch any init-functions and
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2902
     call them as appropriate.
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2903
     This function is not supported on all architectures."
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2904
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2905
    |filenameToLoad handle buffer pathName tempFilename originalPathName|
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2906
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2907
    filenameToLoad := pathNameOrFilename asFilename.
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2908
    originalPathName := filenameToLoad pathName.
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2909
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2910
    "/ already loaded ?
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2911
    handle := self handleForDynamicObject:filenameToLoad.
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2912
    handle notNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2913
	Verbose ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2914
	    ('... ' , pathNameOrFilename asString , ' already loaded.') errorPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2915
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2916
	^ handle
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  2917
    ].
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2918
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2919
    (filenameToLoad exists and:[self copyLibrariesWhenLoading]) ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2920
	tempFilename := ParserFlags stcModulePath asFilename construct:filenameToLoad baseName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2921
	filenameToLoad copyTo:tempFilename.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2922
	filenameToLoad := tempFilename.
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2923
    ].
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2924
    pathName := filenameToLoad pathName.
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2925
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2926
    Verbose ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2927
	('loadDynamic: ',pathNameOrFilename asString,' (',pathName,')...') errorPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2928
	'initializeLoader...' errorPrintCR.
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2929
    ].
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
  2930
    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
  2931
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2932
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2933
    "/ the 1st two entries are system dependent;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2934
    "/ entry 3 is the pathName
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2935
    "/ entry 4 is a unique ID
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2936
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2937
    buffer := Array new:4.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2938
    buffer at:3 put:pathName.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2939
    buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2940
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2941
    Verbose ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2942
	'primLoadDynamicObject...' errorPrintCR
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2943
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2944
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2945
    buffer := self primLoadDynamicObject:filenameToLoad encodedNameString into:buffer.
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2946
    Verbose ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2947
	'done' errorPrintCR
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2948
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2949
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2950
    buffer isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2951
	LastError == #notImplemented ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2952
	    'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2953
	] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2954
	    LastError == #linkError ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2955
		LinkErrorMessage notNil ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2956
		    ('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2957
		] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2958
		    ('ObjectFileLoader [warning]: load error') infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2959
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2960
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2961
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2962
	('ObjectFileLoader [warning]: failed to load: ' , pathName) infoPrintCR.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2963
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2964
	"sr - no do not print to the Transcript!!
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2965
	 it will corrupt the output of
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2966
	 expecco.exe --version"
3958
5718c550a588 #BUGFIX by sr
sr
parents: 3956
diff changeset
  2967
"/        Transcript showCR:('ObjectFileLoader [warning]: failed to load: ' , pathName).
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2968
	^ nil
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2969
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2970
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2971
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2972
     remember loaded object for later unloading
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2973
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2974
    handle := ObjectFileHandle new.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2975
    handle sysHandle1:(buffer at:1).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2976
    handle sysHandle2:(buffer at:2).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2977
    handle pathName:(buffer at:3).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2978
    handle moduleID:(buffer at:4).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2979
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2980
    LoadedObjects isNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2981
	LoadedObjects := Dictionary new.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2982
    ].
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  2983
    LoadedObjects at:originalPathName 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
  2984
    "/ Smalltalk flushCachedClasses.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2985
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2986
    Verbose ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  2987
	('loadDynamic ok; handle is: ' , handle printString) errorPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2988
    ].
2767
12da7f27dcce changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents: 2746
diff changeset
  2989
    "/ ObjectMemory garbageCollect.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2990
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2991
    ^ handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2992
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2993
    "sys5.4:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2994
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2995
     handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2996
     ObjectFileLoader getFunction:'module1' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2997
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2998
    "next:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2999
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3000
     handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3001
     ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3002
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3003
    "GLD:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3004
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3005
     handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3006
     ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3007
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3008
2767
12da7f27dcce changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents: 2746
diff changeset
  3009
    "Modified: / 06-12-2011 / 15:42:16 / cg"
4286
700de9dd13d5 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4267
diff changeset
  3010
    "Modified: / 22-07-2018 / 18:06:12 / Stefan Vogel"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3011
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3012
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3013
loadModulesFromListOfUndefined:list
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3014
    "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
  3015
     return a list of handles of loaded objects
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
    |inits classNames|
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
    inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3020
    inits notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3021
	classNames := inits collect:[:symbol |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3022
	    (symbol startsWith:'___') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3023
		symbol copyFrom:4 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3024
	    ] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3025
		(symbol startsWith:'__') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3026
		    symbol copyFrom:3 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3027
		] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3028
		    (symbol startsWith:'_') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3029
			symbol copyFrom:2 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3030
		    ] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3031
			symbol
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3032
		    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3033
		]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3034
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3035
	].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3036
	"
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3037
	 autoload those classes
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3038
	"
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3039
	classNames do:[:aClassName |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3040
	    |cls|
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3041
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3042
	    (cls := Smalltalk classNamed:aClassName) notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3043
		'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3044
		cls autoload
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3045
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3046
	]
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3047
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3048
    ^ nil
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3049
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3050
    "Modified: 10.1.1997 / 17:58:23 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3051
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3052
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3053
primLoadDynamicObject:pathName into:anInfoBuffer
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3054
    "load an object-file (map into my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3055
     Return an OS-handle (whatever that is) - where some space
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3056
     (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
  3057
     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
  3058
     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
  3059
     (instead, only pass around handles transparently).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3060
     This function is not supported on all architectures."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3061
1760
09a5b2b97f29 WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents: 1759
diff changeset
  3062
%{  /* CALLSUNLIMITEDSTACK(noWIN32) */
470
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
    if (! __isArray(anInfoBuffer)
646
02b5ea95f888 eliminated some single-underscore macro refs (stringSize, arraySize ...)
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
  3065
     || (__arraySize(anInfoBuffer) < 3)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3066
	RETURN(nil);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3067
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3068
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3069
#ifdef GNU_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3070
  {
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3071
    if (__isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3072
	if (dld_link(__stringVal(pathName))) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3073
	    if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3074
		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
  3075
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3076
	    if (@global(ErrorPrinting) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3077
		dld_perror("ObjectFileLoader - DLD error cant link");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3078
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3079
	    @global(LastError) = @symbol(linkError);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3080
	    @global(LinkErrorMessage) = __MKSTRING("DLD error");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3081
	    RETURN ( nil );
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3082
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3083
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3084
	__STORE(anInfoBuffer, pathName);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3085
	RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3086
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3087
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3088
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3089
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3090
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3091
#ifdef WIN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3092
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3093
    HINSTANCE handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3094
    int err;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3095
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3096
    if (__isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3097
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3098
	    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
  3099
	    console_fflush(__win32_stderr());
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3100
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3101
	//
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3102
	// 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
  3103
	// 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
  3104
	// the library has been provided.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3105
	// 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
  3106
	//       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
  3107
	//
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3108
	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
  3109
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3110
	    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
  3111
	    console_fflush(__win32_stderr());
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3112
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3113
	if (handle == NULL) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3114
	    char *msg;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3115
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3116
	    err = GetLastError();
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3117
	    if ((@global(ErrorPrinting) == true)
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3118
	     || (@global(Verbose) == true)) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3119
		console_fprintf (__win32_stderr(),
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3120
				 "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n",
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3121
				 __stringVal(pathName), err);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3122
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3123
	    @global(LastError) = @symbol(loadError);;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3124
	    @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3125
	    switch (err) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3126
		case ERROR_BAD_FORMAT:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3127
		    msg = "LoadLibrary error - bad format";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3128
		default:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3129
		    msg = "LoadLibrary error";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3130
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3131
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3132
	    @global(LinkErrorMessage) = __MKSTRING(msg);
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
	}
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3135
# if __POINTER_SIZE__ == 8
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3136
	__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
  3137
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((UINT)handle >> 32) & 0xFFFFFFFFL );
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3138
# else
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3139
	__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
  3140
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((UINT)handle >> 16) & 0xFFFF );
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3141
# endif
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3142
	RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3143
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3144
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3145
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3146
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3147
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3148
#ifdef DL1_6
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3149
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3150
    extern char *__myName__;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3151
    char *ldname;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3152
    OBJ tmpName;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3153
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3154
    if (__isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3155
	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
  3156
	    if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3157
		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
  3158
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3159
	    @global(LinkErrorMessage) = __MKSTRING("dl_load error");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3160
	    RETURN ( nil );
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3161
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3162
	/*
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3163
	 * returns the name of the temporary ld-file
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3164
	 * use that as handle ...
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3165
	 */
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3166
	tmpName = __MKSTRING(ldname);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3167
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3168
	__STORE(anInfoBuffer, tmpName);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3169
	RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3170
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3171
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3172
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3173
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3174
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3175
#ifdef AIX_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3176
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3177
    char *objName, *libPath;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3178
    int *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3179
    extern errno;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3180
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3181
    if (__isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3182
	objName = __stringVal(pathName);
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
	if (__isStringLike(@global(LibPath))) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3185
	    libPath = __stringVal(@global(LibPath));
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3186
	} else {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3187
	    libPath = (char *)0;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3188
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3189
	if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3190
	    if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3191
		char *messages[64];
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3192
		int i;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3193
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3194
		console_fprintf (stderr,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3195
			 "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
  3196
			 objName, errno);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3197
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3198
		switch (errno) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3199
		    case ENOEXEC:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3200
			console_fprintf(stderr, "   load messages:\n");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3201
			loadquery(L_GETMESSAGES, messages, sizeof(messages));
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3202
			for (i=0; messages[i]; i++) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3203
			    console_fprintf(stderr, "      %s\n", messages[i]);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3204
			}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3205
			break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3206
		}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3207
	    } else {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3208
		if (@global(ErrorPrinting) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3209
		    console_fprintf (stderr,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3210
			     "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
  3211
			     objName, errno);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3212
		}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3213
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3214
	    @global(LinkErrorMessage) = __MKSTRING("load error");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3215
	    RETURN ( nil );
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3216
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3217
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3218
	    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
  3219
	}
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3220
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3221
# if __POINTER_SIZE__ == 8
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3222
	__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
  3223
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3224
# else
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3225
	__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
  3226
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3227
# endif
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3228
	RETURN (anInfoBuffer);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3229
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3230
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3231
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3232
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3233
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3234
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3235
#ifdef SYSV4_DL
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
    void *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3238
    char *nm;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3239
    char *errMsg;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3240
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3241
    if ((pathName == nil) || __isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3242
	INT lowHandle, hiHandle;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3243
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3244
	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
  3245
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3246
	if (! handle) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3247
	    errMsg = (char *) dlerror();
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3248
	    if (@global(ErrorPrinting) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3249
		console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3250
		console_fprintf(stderr, "    <%s>\n", errMsg);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3251
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3252
	    @global(LastError) = @symbol(linkError);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3253
	    @global(LinkErrorMessage) = __MKSTRING(errMsg);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3254
	    RETURN (nil);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3255
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3256
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3257
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3258
	    console_fprintf(stderr, "ObjectFileLoader [info]: 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
  3259
	}
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3260
1607
074a99bb9a50 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 1602
diff changeset
  3261
#if __POINTER_SIZE__ == 8
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3262
	lowHandle = (INT)handle & 0xFFFFFFFFL;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3263
	hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3264
#else
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3265
	lowHandle = (INT)handle & 0xFFFF;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3266
	hiHandle = ((INT)handle >> 16) & 0xFFFF;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3267
#endif
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3268
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3269
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3270
	RETURN (anInfoBuffer);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3271
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3272
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3273
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3274
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3275
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3276
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3277
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3278
    void *handle;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3279
    char *nm;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3280
    char *errMsg;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3281
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3282
    if (__isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3283
	handle = (void *)shl_load(__stringVal(pathName),
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3284
				  BIND_IMMEDIATE, 0L /* address */);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3285
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3286
	if (! handle) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3287
	    if (@global(ErrorPrinting) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3288
		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
  3289
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3290
	    @global(LastError) = @symbol(linkError);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3291
	    switch (errno) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3292
		case ENOEXEC:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3293
		    errMsg = "not a shared library";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3294
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3295
		case ENOSYM:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3296
		    errMsg = "undefined symbols";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3297
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3298
		case ENOMEM:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3299
		    errMsg = "out of memory";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3300
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3301
		case ENOENT:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3302
		    errMsg = "non existing library";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3303
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3304
		case EACCES:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3305
		    errMsg = "permission denied";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3306
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3307
		default:
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3308
		    errMsg = "unspecified error";
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3309
		    break;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3310
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3311
	    @global(LinkErrorMessage) = __MKSTRING(errMsg);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3312
	    RETURN (nil);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3313
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3314
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3315
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3316
	    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
  3317
	}
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3318
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3319
# if __POINTER_SIZE__ == 8
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3320
	__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
  3321
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3322
# else
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3323
	__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
  3324
	__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
  3325
	RETURN (anInfoBuffer);
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3326
# endif
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3327
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3328
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3329
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3330
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3331
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3332
#ifdef SUN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3333
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3334
    void *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3335
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3336
    if ((pathName == nil) || __isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3337
	if (pathName == nil)
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3338
	    handle = dlopen((char *)0, 1);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3339
	else
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3340
	    handle = dlopen(__stringVal(pathName), 1);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3341
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3342
	if (! handle) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3343
	    if (@global(ErrorPrinting) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3344
		console_fprintf(stderr, "dlopen %s error: <%s>\n",
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3345
				__stringVal(pathName), dlerror());
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3346
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3347
	    @global(LastError) = @symbol(linkError);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3348
	    @global(LinkErrorMessage) = __MKSTRING("dlopen error");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3349
	    RETURN (nil);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3350
	}
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 (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3353
	    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
  3354
	}
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
	__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
  3357
	__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
  3358
	RETURN (anInfoBuffer);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3359
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3360
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3361
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3362
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3363
#ifdef NEXT_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3364
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3365
    long result;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3366
    char *files[2];
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3367
    NXStream *errOut;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3368
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3369
    if (__isStringLike(pathName)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3370
	files[0] = (char *) __stringVal(pathName);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3371
	files[1] = (char *) 0;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3372
	errOut = NXOpenFile(2, 2);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3373
	result = rld_load(errOut,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3374
			  (struct mach_header **)0,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3375
			  files,
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3376
			  (char *)0);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3377
	NXClose(errOut);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3378
	if (! result) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3379
	    @global(LinkErrorMessage) = __MKSTRING("rld_load error");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3380
	    @global(LastError) = @symbol(linkError);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3381
	    if (@global(ErrorPrinting) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3382
		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
  3383
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3384
	    RETURN (nil);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3385
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3386
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3387
	if (@global(Verbose) == true)
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3388
	    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
  3389
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3390
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3391
	__STORE(anInfoBuffer, pathName);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3392
	RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3393
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3394
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3395
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3396
%}.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3397
    LastError := #notImplemented.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3398
    ^ nil
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
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3401
primUnloadDynamicObject:aHandle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3402
    "unload an object-file (unmap from my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3403
     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
  3404
     still any code references (from blocks or methods) to this
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3405
     module. Calling it for still living classes will definitely
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3406
     lead to some fatal conditions to occur later."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3407
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3408
    |sysHandle1 sysHandle2|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3409
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3410
    sysHandle1 := aHandle sysHandle1.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3411
    sysHandle2 := aHandle sysHandle2.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3412
1760
09a5b2b97f29 WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents: 1759
diff changeset
  3413
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3414
#ifdef GNU_DL
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3415
    if (__isStringLike(sysHandle1)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3416
	if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3417
	    if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3418
		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
  3419
		dld_perror("cant unlink");
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
	    RETURN (false);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3422
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3423
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3424
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3425
    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3426
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3427
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3428
#ifdef WIN_DL
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3429
# if defined(__BORLANDC__)
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3430
    // FreeLibrary in Borland C calls exit, catches it with setjmp()
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3431
    // but hangs after this.
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3432
    if (@global(Verbose) == true) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3433
	console_fprintf (__win32_stderr(),
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3434
			 "ObjectFileLoader [info]: FreeLibrary is not supported in Borland C\n");
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3435
    }
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3436
    RETURN (true);
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3437
# else // ! __BORLAND_C__
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3438
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3439
	UINT val;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3440
	HINSTANCE handle;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3441
	int err;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3442
	jmp_buf exitJmpBuf;
4631
143d0563fb48 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4616
diff changeset
  3443
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  3444
# if __POINTER_SIZE__ == 8
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3445
	val = ((UINT)_intVal(sysHandle2) << 32) + (UINT)_intVal(sysHandle1);
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  3446
# else
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3447
	val = ((UINT)_intVal(sysHandle2) << 16) + (UINT)_intVal(sysHandle1);
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  3448
# endif
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3449
	handle = (HINSTANCE)val;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3450
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3451
	if (!setjmp(exitJmpBuf)) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3452
	    __setAtExitLongJmp(exitJmpBuf);
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_fprintf (__win32_stderr(),
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3455
				 "ObjectFileLoader [info]: FreeLibrary handle: %"_lx_"\n",
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3456
				 (INT)handle);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3457
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3458
	    if (FreeLibrary(handle) != TRUE) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3459
		__setAtExitLongJmp(0);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3460
		err = GetLastError();
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3461
		if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3462
		    console_fprintf (__win32_stderr(),
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3463
				     "ObjectFileLoader [warning]: FreeLibrary failed; error: %x\n",
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3464
				     err);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3465
		}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3466
		@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3467
		RETURN (false);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3468
	    } else {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3469
		__setAtExitLongJmp(0);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3470
	    }
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3471
	} else {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3472
	    // arrive here if FreeLibrary does exit
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3473
	    __setAtExitLongJmp(0);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3474
	    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
  3475
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3476
	RETURN (true);
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3477
     }
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3478
     RETURN (false);
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3479
# endif // !defined(__BORLAND_C__)
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3480
#endif // WIN_DL
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3481
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3482
#ifdef SYSV4_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3483
  {
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3484
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3485
	void *handle;
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3486
	unsigned INT val;
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3487
1607
074a99bb9a50 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 1602
diff changeset
  3488
#if __POINTER_SIZE__ == 8
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3489
	val = ((unsigned INT)__intVal(sysHandle2) << 32) + (unsigned INT)__intVal(sysHandle1);
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3490
#else
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3491
	val = ((unsigned INT)_intVal(sysHandle2) << 16) + (unsigned INT)_intVal(sysHandle1);
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3492
#endif
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3493
	handle = (void *)(val);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3494
	if (@global(Verbose) == true)
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3495
	    console_printf("close handle = %p\n", handle);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3496
	if (dlclose(handle) != 0) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3497
	    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
  3498
	    RETURN (false);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3499
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3500
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3501
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3502
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3503
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3504
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3505
#ifdef SUN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3506
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3507
    void *h;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3508
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3509
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3510
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3511
    if (__bothSmallInteger(low, hi)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3512
	val = (_intVal(hi) << 16) + _intVal(low);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3513
	h = (void *)(val);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3514
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3515
	    console_printf("close handle = %x\n", h);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3516
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3517
	dlclose(h);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3518
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3519
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3520
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3521
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3522
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3523
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3524
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3525
    int *h;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3526
    int val;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3527
    OBJ low = sysHandle1, hi = sysHandle2;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3528
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3529
    if (__bothSmallInteger(low, hi)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3530
	val = (_intVal(hi) << 16) + _intVal(low);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3531
	h = (void *)(val);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3532
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3533
	    console_printf("unload handle = %x\n", h);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3534
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3535
	shl_unload(h);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3536
	RETURN (true);
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3537
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3538
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3539
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3540
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3541
#ifdef AIX_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3542
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3543
    int *h;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3544
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3545
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3546
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3547
    if (__bothSmallInteger(low, hi)) {
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3548
	val = (_intVal(hi) << 16) + _intVal(low);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3549
	h = (int *)(val);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3550
	if (@global(Verbose) == true) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3551
	    console_printf("unload handle = %x\n", h);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3552
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3553
	if ( unload(h) != 0) {
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3554
	    console_fprintf(stderr, "unload failed\n");
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3555
	    RETURN (false);
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3556
	}
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3557
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3558
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3559
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3560
#endif
529
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3561
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3562
#ifdef NEXT_DL
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3563
  {
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  3564
    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
  3565
  }
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3566
#endif
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3567
%}.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3568
    ^ false
4631
143d0563fb48 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4616
diff changeset
  3569
4633
a40a1a077728 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4632
diff changeset
  3570
    "Modified: / 13-02-2020 / 15:46:13 / Stefan Vogel"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3571
!
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
unloadDynamicObject:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3574
    "close an object-file (unmap from my address space)
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3575
     and remove the entry from the remembered object file set.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3576
     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
  3577
     still any code references (from blocks or methods) to this
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3578
     module. Calling it for still living classes will definitely
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3579
     lead to some fatal conditions to occur later."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3580
4634
5590d17e84fb #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4633
diff changeset
  3581
    |key fileName functionName deInitAddr method|
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3582
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3583
    Verbose ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3584
	'unload module name=' errorPrint. handle pathName errorPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3585
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3586
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3587
    handle isUnknownHandle ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3588
	Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3589
	    '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
  3590
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3591
	self unregisterModule:handle.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3592
	handle makeClassLibHandle.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3593
    ] ifFalse:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3594
	handle isClassLibHandle ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3595
	    Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3596
		'a classLib - deinit classes' errorPrintCR.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3597
	    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3598
	    self deinitializeClassesFromModule:handle.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3599
	    Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3600
		'unregister' errorPrintCR.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3601
	    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3602
	    self unregisterModule:handle.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3603
	] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3604
	    handle isMethodHandle ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3605
		Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3606
		    'a methodHandle - unregister' errorPrintCR.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3607
		].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3608
		self unregisterModule:handle.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3609
	    ] ifFalse:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3610
		handle isFunctionObjectHandle ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3611
		    Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3612
			'a functionObject - fixup functionRefs' errorPrintCR.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3613
		    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3614
		    handle functions do:[:f |
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3615
				    f notNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3616
					f invalidate
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3617
				    ]
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3618
				].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3619
		].
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
		"/
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3622
		"/ call its deInit function (if present)
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3623
		"/
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3624
		Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3625
		    'search for deInit function...' errorPrintCR.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3626
		].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3627
		fileName := handle pathName asFilename baseName.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3628
		functionName := self initFunctionBasenameForFile:fileName.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3629
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3630
		deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3631
		deInitAddr notNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3632
		    Verbose ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3633
			'invoke deInit function...' errorPrintCR.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3634
		    ].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3635
		    self
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3636
			saveCallInitFunctionAt:deInitAddr
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3637
			in:fileName
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3638
			specialInit:false
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3639
			forceOld:true
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3640
			interruptable:false
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3641
			argument:0
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3642
			identifyAs:handle
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3643
			returnsObject:false.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3644
		]
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3645
	    ]
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3646
	].
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3647
    ].
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3648
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3649
    Verbose ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3650
	'cleanup done - now unload...' errorPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3651
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3652
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
    "/ now, really unload
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3655
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3656
    (self primUnloadDynamicObject:handle) ifFalse:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3657
	^ self error:'unloadDynamic failed' mayProceed:true
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3658
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3659
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3660
    Verbose ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3661
	'unload done ...' errorPrintCR.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3662
    ].
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3663
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3664
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3665
    "/ remove from loaded objects
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3666
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3667
    LoadedObjects notNil ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3668
	key := LoadedObjects keyAtEqualValue:handle.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3669
	key notNil ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3670
	    LoadedObjects removeKey:key
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3671
	]
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3672
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3673
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3674
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3675
     for individual methods, we keep the methodObject,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3676
     but make it unexecutable. Its still visible in the browser.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3677
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3678
    handle isMethodHandle ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3679
	method := handle method.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3680
	(method  notNil and:[method ~~ 0]) ifTrue:[
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3681
	    method makeUnloaded.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3682
	].
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3683
	ObjectMemory flushCaches.
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3684
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3685
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3686
    handle isClassLibHandle ifTrue:[
4635
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3687
	Smalltalk flushCachedClasses.
d8c0804e23e3 unsigned INT vs. UINT (on OSX)
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
  3688
	Class flushSubclassInfo.
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3689
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3690
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3691
    handle moduleID:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3692
    handle sysHandle1:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3693
    handle sysHandle2:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3694
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  3695
    "Modified: / 15-11-2010 / 13:20:20 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3696
! !
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3697
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  3698
!ObjectFileLoader class methodsFor:'queries'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3699
3556
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3700
binaryClassFilenameForPackage:aPackageId inDirectory:packageDirOrNil
4010
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3701
    |tryAction shLibName exePath exeDir|
3556
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3702
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3703
    "Is there a shared library (.dll or .so) ?"
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3704
    shLibName := aPackageId asPackageId libraryName asFilename
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3705
			withSuffix:(self sharedLibrarySuffix).
4010
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3706
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3707
    tryAction :=
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3708
	[:dir |
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3709
	    |binaryClassLibraryFilename|
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3710
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3711
	    binaryClassLibraryFilename := dir / shLibName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3712
	    binaryClassLibraryFilename exists ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3713
		"/ mhmh - is this a good idea ? (temporary kludge)
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3714
		ExternalBytes sizeofPointer == 4 ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3715
		    binaryClassLibraryFilename := dir / 'objbc' / shLibName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3716
		    binaryClassLibraryFilename exists ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3717
			binaryClassLibraryFilename := dir / 'objvc' / shLibName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3718
		    ]
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3719
		] ifFalse:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3720
		    binaryClassLibraryFilename := dir / 'objmingw' / shLibName.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3721
		].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3722
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3723
	    (binaryClassLibraryFilename notNil and:[binaryClassLibraryFilename exists]) ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3724
		^ binaryClassLibraryFilename
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3725
	    ].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3726
	].
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3727
4010
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3728
    packageDirOrNil notNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3729
	tryAction value:packageDirOrNil.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3730
	^ nil
3556
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3731
    ].
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3732
4010
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3733
    exePath := OperatingSystem pathOfSTXExecutable.
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3734
    exePath notNil ifTrue:[
4609
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3735
	exeDir := exePath asFilename directory.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3736
	tryAction value:exeDir.
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3737
	exeDir baseName = 'bin' ifTrue:[
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3738
	    tryAction value:(exeDir directory / 'lib').
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3739
	].
cb98eb15cfeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4584
diff changeset
  3740
	tryAction value:(exeDir directory / 'plugin').
4010
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3741
    ].
d9ce3f4aabe2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4006
diff changeset
  3742
    ^ nil
3556
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3743
!
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3744
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3745
canLoadObjectFiles
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  3746
    "return true, if dynamic loading is possible.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3747
     Currently, only ELF based systems, AIX and linux a.out can do this."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3748
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3749
    self primCanLoadObjectFiles ifTrue:[^true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3750
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3751
    "/ can add a return true here, if I ever get manual loading to work
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3752
    "/ for some specific machine
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3753
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  3754
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3755
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3756
     ObjectFileLoader canLoadObjectFiles
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3757
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3758
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3759
    "Modified: 8.1.1997 / 18:13:01 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3760
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3761
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3762
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
  3763
    "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
  3764
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3765
    |pathName|
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3766
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
  3767
    LoadedObjects isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3768
	^ 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
  3769
    ].
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3770
    pathName := pathNameOrFilename asFilename pathName.
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
  3771
    ^ LoadedObjects at:pathName ifAbsent:nil.
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3772
!
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3773
2393
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3774
handleFromID:id
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3775
    "given an id, return the pathName, or nil for static modules"
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3776
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3777
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3778
	LoadedObjects keysAndValuesDo:[:name :handle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3779
	    handle moduleID == id ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3780
		^ handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3781
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3782
	].
2393
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3783
    ].
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3784
    ^ nil
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3785
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3786
    "
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3787
     ObjectFileLoader handleFromID:1
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3788
    "
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3789
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3790
    "Modified: 28.8.1995 / 18:08:28 / claus"
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3791
!
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3792
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3793
loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3794
    "return a collection containing the names of all
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3795
     dynamically loaded objects."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3796
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3797
    LoadedObjects isNil ifTrue:[^ #()].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3798
    ^ LoadedObjects keys copy
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3799
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3800
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3801
     ObjectFileLoader loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3802
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3803
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3804
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3805
loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3806
    "return a collection of all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3807
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3808
    LoadedObjects isNil ifTrue:[^ #()].
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  3809
    ^ LoadedObjects
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3810
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3811
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3812
     ObjectFileLoader loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3813
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3814
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3815
    "Created: 17.9.1995 / 14:28:55 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3816
    "Modified: 17.9.1995 / 16:13:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3817
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3818
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3819
loadedObjectHandlesDo:aBlock
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3820
    "enumerate all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3821
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3822
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3823
	LoadedObjects copy do:aBlock.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3824
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3825
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3826
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3827
     ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3828
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3829
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3830
    "Created: 14.9.1995 / 22:03:13 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3831
    "Modified: 14.9.1995 / 22:32:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3832
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3833
1602
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3834
moduleNamed:aNameString
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3835
    "return the module named aNameString"
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3836
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3837
    |moduleDescriptor|
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3838
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3839
    moduleDescriptor :=
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3840
	ObjectMemory binaryModuleInfo
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3841
	    detect:[:eachModuleDescriptor | eachModuleDescriptor libraryName = aNameString]
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3842
	    ifNone:[^ nil].
1742
2a2f0bf6342d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  3843
2a2f0bf6342d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  3844
    ^ LoadedObjects at:(moduleDescriptor pathName) ifAbsent:[].
1602
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3845
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3846
    "
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3847
     ObjectFileLoader moduleNamed:'ctypes'
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3848
    "
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3849
!
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3850
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3851
pathNameFromID:id
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3852
    "given an id, return the pathName, or nil for static modules"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3853
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3854
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3855
	LoadedObjects keysAndValuesDo:[:name :handle |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3856
	    handle moduleID == id ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3857
		^ handle pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3858
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3859
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3860
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3861
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3862
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3863
    "
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  3864
     ObjectFileLoader pathNameFromID:1
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3865
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3866
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3867
    "Modified: 28.8.1995 / 18:08:28 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3868
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3869
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3870
primCanLoadObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3871
    "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
  3872
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3873
%{  /* NOCONTEXT */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3874
#ifdef HAS_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3875
# if !defined(OS_DEFINE) || defined(unknownOS)
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  3876
    console_fprintf(stderr, "*** OS_DEFINE not correct\n");
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3877
# else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3878
#  if !defined(CPU_DEFINE) || defined(unknownCPU)
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  3879
    console_fprintf(stderr, "*** CPU_DEFINE not correct\n");
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3880
#  else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3881
    RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3882
#  endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3883
# endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3884
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3885
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3886
    ^ false
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3887
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3888
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3889
     ObjectFileLoader primCanLoadObjectFiles
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3890
    "
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  3891
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  3892
3556
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3893
!ObjectFileLoader class methodsFor:'signal access'!
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3894
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3895
objectFileLoadErrorNotification
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3896
    ^ ObjectFileLoadErrorNotification
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3897
! !
19e4081ac833 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3516
diff changeset
  3898
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  3899
!ObjectFileLoader class methodsFor:'st object file handling'!
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3900
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3901
callInitFunctionAt:address specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3902
    "call a function at address - a very dangerous operation.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3903
     This is needed to call the classes init-function after loading in a
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3904
     class-object file or to call the CTORS when c++ modules are loaded.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3905
     ForceOld (if true) will have the memory manager
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3906
     allocate things in oldSpace instead of newSpace.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3907
     If special is true, this is a smalltalk moduleInit (i.e. pass the vm-entries table);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3908
     otherwise, its called without arguments.
4125
b04f970b47cc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  3909
     If it's a smalltalk-moduleInit, it may be either for a classPackage (which should
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3910
     install all of its classes) or for a single incrementally compiled methdod
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3911
     (it should then NOT install it, but return the method object instead).
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3912
4034
0a8789ead3b6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4010
diff changeset
  3913
     DANGER: Internal & highly specialized. Don't use in your programs.
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3914
	     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
  3915
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3916
    |moduleID retVal oldSpaceReserve|
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3917
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3918
    handle notNil ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3919
	moduleID := handle moduleID
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3920
    ].
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3921
    "/
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3922
    "/ 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
  3923
    "/ 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
  3924
    "/ 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
  3925
    "/ 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
  3926
    "/ 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
  3927
    "/ (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
  3928
    "/
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3929
    oldSpaceReserve := OldSpaceReserve ? (1024*1024).
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3930
1033
f5bad5027056 More Stack when calling init function.
Stefan Vogel <sv@exept.de>
parents: 1024
diff changeset
  3931
%{  /* CALLSSTACK: 128000 */
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3932
    OBJ (*addr)();
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3933
    int prevSpace, force;
591
9c48953d9fab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 590
diff changeset
  3934
    INT arg = 0, ret = 0;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3935
    int wasBlocked = 1;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3936
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3937
    if (__isInteger(address)) {
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3938
	if (_isSmallInteger(argument)) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3939
	    arg = __intVal(argument);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3940
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3941
	    addr = (OBJFUNC)(__longIntVal(address));
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3942
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3943
	    /*
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3944
	     * allow function to be interrupted
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3945
	     */
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3946
	    if (interruptable != true) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3947
		wasBlocked = (__BLOCKINTERRUPTS() == true);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3948
	    }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3949
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3950
	    force = (forceOld == true);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3951
	    if (force) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3952
		int reserve = __intVal(oldSpaceReserve);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3953
		if ((__oldSpaceSize() - __oldSpaceUsed()) < reserve) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3954
		    __moreOldSpace(__thisContext, reserve);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3955
		}
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3956
		prevSpace = __allocForceSpace(OLDSPACE);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3957
	    }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3958
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3959
	    if (@global(Verbose) == true) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3960
		console_printf("calling initfunc %lx(%lx) ...\n", (long)addr, (long)arg);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3961
	    }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3962
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3963
	    if (special == true) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3964
		if (__isSmallInteger(moduleID)) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3965
		    __SET_MODULE_ID(__intVal(moduleID));
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3966
		}
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3967
		retVal = (*addr)(arg, __pRT__);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3968
		__SET_MODULE_ID(0);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3969
		if (returnsObject != true) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3970
		    retVal = nil;
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3971
		}
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3972
	    } else {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3973
		if (returnsObject == true) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3974
		    retVal = (*addr)(arg);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3975
		} else {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3976
		    ret = (INT) ((*addr)(arg));
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3977
		    retVal = __mkSmallInteger(ret);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3978
	       }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3979
	    }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3980
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3981
	    if (force) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3982
		__allocForceSpace(prevSpace);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3983
	    }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3984
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3985
	    if (! wasBlocked) {
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3986
		__UNBLOCKINTERRUPTS();
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3987
	    }
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3988
	    RETURN (retVal);
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  3989
	}
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3990
    }
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3991
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3992
    self primitiveFailed
4125
b04f970b47cc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  3993
b04f970b47cc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4122
diff changeset
  3994
    "Modified (comment): / 13-02-2017 / 20:27:51 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3995
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3996
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
  3997
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
  3998
    "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
  3999
     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
  4000
     (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
  4001
    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
  4002
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4003
    |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
  4004
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4005
    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
  4006
	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
  4007
	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
  4008
    ] 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
  4009
	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
  4010
	    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
  4011
	    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
  4012
	] 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
  4013
	    '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
  4014
	    ^ 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
  4015
	]
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4016
    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4017
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4018
    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
  4019
	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
  4020
	    ('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
  4021
	].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4022
	"/ 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
  4023
	^ 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
  4024
    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4025
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4026
    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
  4027
	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
  4028
	    ('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
  4029
	].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4030
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4031
	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
  4032
	(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
  4033
	    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
  4034
		('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
  4035
	    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4036
	    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
  4037
	    ^ 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
  4038
	].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4039
    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4040
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4041
    ('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
  4042
    ^ 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
  4043
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4044
    "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
  4045
!
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  4046
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4047
deinitializeClassesFromModule:handle
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  4048
    "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
  4049
     to all classes of a module."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4050
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4051
    |classes|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4052
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4053
    classes := handle classes.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4054
    classes notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4055
	classes do:[:aClass |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4056
	    aClass notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4057
		aClass isMeta ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4058
		    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4059
			'send #deinitialize to:' errorPrint. aClass name errorPrintCR.
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4060
		    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4061
		    aClass deinitialize.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4062
		    aClass update:#aboutToUnload with:nil from:self
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4063
		]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4064
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4065
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4066
    ]
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  4067
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4068
    "Modified: 10.1.1997 / 17:56:50 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4069
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4070
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4071
invalidateModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4072
    "invalidate all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4073
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4074
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4075
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4076
    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4077
	'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
  4078
	' id=' errorPrint. handle moduleID errorPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4079
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4080
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4081
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4082
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4083
    __INVALIDATE_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4084
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4085
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4086
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4087
loadStatusFor:className
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4088
    "ask VM if class-hierarchy has been completely loaded, and return the status.
4128
abac292e8568 #DOCUMENTATION by mawalch
mawalch
parents: 4125
diff changeset
  4089
     If className is non-nil, check the load status of this class only,
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4090
     otherwise check the status of all known classes.
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4091
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4092
     Answer an array with the status symbol and optionally the name of
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4093
     a class with a bad status."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4094
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4095
    |checker checkSymbol statusCode status badClassName1 badClassName2|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4096
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4097
    checker := self.
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4098
    checkSymbol := #classPresentCheck:.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4099
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4100
%{  /* NOREGISTER */
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4101
    char *badName1 = NULL;
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4102
    char *badName2 = NULL;
2705
82da3252db2a changed: #loadStatusFor:
Stefan Vogel <sv@exept.de>
parents: 2661
diff changeset
  4103
    char interestingClassName[512], *classNameP = 0;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4104
1759
a49b7066594c UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents: 1745
diff changeset
  4105
    if (__isStringLike(className)) {
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4106
	strncpy(interestingClassName, __stringVal(className), sizeof(interestingClassName));
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4107
	classNameP = interestingClassName;
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4108
    }
2705
82da3252db2a changed: #loadStatusFor:
Stefan Vogel <sv@exept.de>
parents: 2661
diff changeset
  4109
    statusCode = __MKSMALLINT(__check_registration__(classNameP,
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4110
						     &checker, &checkSymbol,
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4111
						     &badName1, &badName2));
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4112
    if (badName1) {
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4113
	badClassName1 = __MKSTRING(badName1);
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4114
    }
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4115
    if (badName2) {
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4116
	badClassName2 = __MKSTRING(badName2);
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4117
    }
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4118
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4119
    statusCode == 0 ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4120
	status := #ok
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4121
    ] ifFalse:[ statusCode == -1 ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4122
	status := #missingClass
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4123
    ] ifFalse:[ statusCode == -2 ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4124
	status := #versionMismatch
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4125
    ] ifFalse:[ statusCode == -3 ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4126
	status := #unregisteredSuperclass
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4127
    ] ifFalse:[ statusCode == -4 ifTrue:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4128
	status := #tryAgain
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4129
    ] ifFalse:[
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4130
	status := #loadFailed
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4131
    ] ] ] ] ].
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4132
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4133
    ^ Array with:status with:badClassName1 with:badClassName2.
4128
abac292e8568 #DOCUMENTATION by mawalch
mawalch
parents: 4125
diff changeset
  4134
abac292e8568 #DOCUMENTATION by mawalch
mawalch
parents: 4125
diff changeset
  4135
    "Modified: / 21-02-2017 / 14:24:55 / mawalch"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4136
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4137
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4138
moduleInit:phase forceOld:forceOld interruptable:interruptable
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4139
    "initialization phases after registration.
1759
a49b7066594c UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents: 1745
diff changeset
  4140
     DANGER: Pure magic; internal only -> don't use in your programs."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4141
1959
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4142
    self primModuleInit:phase forceOld:forceOld interruptable:interruptable
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4143
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4144
    "Modified: / 06-12-2006 / 13:09:43 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4145
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4146
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4147
performModuleInitAt:initAddr for:className identifyAs:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4148
    "Initialize a loaded smalltalk module."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4149
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4150
    ^ self
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4151
	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
  4152
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4153
!
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4154
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4155
performModuleInitAt:initAddr invokeInitializeMethods:invokeInitializeMethods for:className identifyAs:handle
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4156
    "Initialize a loaded smalltalk module."
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4157
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4158
    |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
  4159
     stillTrying|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4160
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4161
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4162
     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
  4163
			    0b check if modules superclasses are all loaded
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4164
			    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
  4165
			    2: let it install install class, methods and literals
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4166
			    3: let it send #initialize to its class object
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4167
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4168
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4169
    Verbose ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4170
	'start' errorPrintCR
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4171
    ].
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4172
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4173
    [
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4174
	stillTrying := false.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4175
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4176
	"/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4177
	"/ let it register itself
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4178
	"/ and define its globals
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4179
	"/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4180
	Verbose ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4181
	    'phase 0 (module registration) ...' errorPrintCR
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4182
	].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4183
	self
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4184
	    saveCallInitFunctionAt:initAddr
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4185
	    in:nil
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4186
	    specialInit:true
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4187
	    forceOld:true
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4188
	    interruptable:false
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4189
	    argument:0
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4190
	    identifyAs:handle
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4191
	    returnsObject:false.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4192
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4193
	"/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4194
	"/ check if superclasses are present
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4195
	"/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4196
	info := self loadStatusFor:className.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4197
	status := info at:1.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4198
	badClassName1 := info at:2.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4199
	badClassName2 := info at:3.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4200
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4201
	Verbose ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4202
	    '... info is ' errorPrint. info errorPrintCR
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4203
	].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4204
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4205
	(status ~~ #ok) ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4206
	    (status == #missingClass) ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4207
		('ObjectFileLoader [error]: load failed - missing class: ' , badClassName1) infoPrintCR.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4208
		^ info
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4209
	    ].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4210
	    (status == #versionMismatch) ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4211
		('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
  4212
		^ info
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4213
	    ].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4214
	    (status == #unregisteredSuperclass) ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4215
		('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName1) infoPrintCR.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4216
		^ info
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4217
	    ].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4218
	    (status == #tryAgain) ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4219
		"/ tryAgain:
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4220
		"/   must retry after initialization, to initialize
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4221
		"/   sub-subclasses of autoloaded classes
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4222
		"/   (sigh - class objects are created in phase 3,
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4223
		"/    so we must first complete the initialization cycle,
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4224
		"/    then do all again, for remaining modules)
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4225
		stillTrying := true.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4226
		'ObjectFileLoader [info]: retry registration of: ' infoPrint.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4227
		(className ? 'a classLib') infoPrint. ' after init' infoPrintCR.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4228
	    ] ifFalse:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4229
		'ObjectFileLoader [error]: load failed: ' infoPrint. className infoPrintCR.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4230
		^ #(loadFailed nil)
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4231
	    ].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4232
	].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4233
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4234
	Smalltalk flushCachedClasses.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4235
	Class flushSubclassInfo.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4236
	"/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4237
	"/ remaining initialization
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4238
	"/
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4239
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4240
	"/ module exports: declare module-globals & symbols ...
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4241
	Verbose ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4242
	    'phase 1 (resolve globals) ...' errorPrintCR
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4243
	].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4244
	self moduleInit:1 forceOld:true interruptable:false.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4245
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4246
	"/ module-imports: resolve globals ...
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4247
	"/ create methods & install ...
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4248
	Verbose ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4249
	    'phase 2 (create objects) ...' errorPrintCR
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4250
	].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4251
	self moduleInit:2 forceOld:true interruptable:false.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4252
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4253
	Verbose ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4254
	    'stillTrying is ' errorPrint. stillTrying errorPrintCR
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4255
	].
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4256
    ] doWhile:[stillTrying].
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4257
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4258
    Verbose ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4259
	'end' errorPrintCR
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4260
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4261
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4262
    ObjectMemory flushCaches.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4263
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4264
    invokeInitializeMethods ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4265
	Verbose ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4266
	    'phase 3 (send #initialize) ...' errorPrintCR
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4267
	].
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4268
	"/ initialize ...
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4269
	self moduleInit:3 forceOld:false interruptable:true.
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4270
    ].
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4271
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4272
    "/ ask objectMemory for the classes we have just loaded
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4273
    "/ and register them in the handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4274
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4275
    infoCollection := ObjectMemory binaryModuleInfo.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4276
    info := infoCollection at:handle moduleID ifAbsent:nil.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4277
    info isNil ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4278
	"/ mhmh registration failed -
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4279
	'ObjectFileLoader [error]: registration failed: ' infoPrint.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4280
	(className ? 'some classLib') infoPrintCR.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4281
	^ #(registrationFailed nil)
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4282
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4283
405
92cb91b82cf7 changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4284
    classNames := info classNames.
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  4285
    classNames notEmptyOrNil ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4286
	classes := OrderedCollection new:classNames size.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4287
	classNames do:[:eachClassName | |class|
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4288
	    class := Smalltalk classNamed:eachClassName.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4289
	    class notNil ifTrue:[
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4290
		classes add:class.
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
	].
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4293
    ].
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  4294
    classes notEmptyOrNil ifTrue:[
3956
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4295
	classes := classes asArray.
81b8cd7a75ec more detail from check_registration
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  4296
	classes := classes , (classes collect:[:aClass | aClass class]).
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4297
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4298
    handle classes:classes.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4299
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4300
"/    invokeinitializemethods iftrue:[
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4301
"/        verbose iftrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4302
"/            'phase 3 (send #initialize) ...' errorPrintCR
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4303
"/        ].
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4304
"/        "/ INITIALIZE ...
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4305
"/        self moduleinit:3 forceold:false interruptable:true.
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4306
"/    ].
881
ed4efb1b161e perform moduleInit3 AFTER registering the module.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
  4307
3933
bcbec36bc79d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3905
diff changeset
  4308
    ^ #(ok nil)
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4309
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  4310
    "Modified: / 29-07-2004 / 17:12:28 / stefan"
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4311
    "Modified: / 15-11-2010 / 13:20:11 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4312
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4313
1959
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4314
primModuleInit:phase forceOld:forceOld interruptable:interruptable
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4315
    "initialization phases after registration.
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4316
     DANGER: Pure magic; internal only -> don't use in your programs."
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4317
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4318
%{
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4319
    int prevSpace, force;
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4320
    int wasBlocked = 1;
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4321
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4322
    if (__isSmallInteger(phase)) {
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4323
	if (interruptable != true) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4324
	    wasBlocked = (__BLOCKINTERRUPTS() == true);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4325
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4326
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4327
	force = (forceOld == true);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4328
	if (force) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4329
	    prevSpace = __allocForceSpace(OLDSPACE);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4330
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4331
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4332
	__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
  4333
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4334
	if (force) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4335
	    __allocForceSpace(prevSpace);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4336
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4337
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4338
	if (! wasBlocked) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4339
	    __UNBLOCKINTERRUPTS();
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4340
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4341
	RETURN (self);
1959
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4342
    }
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4343
%}.
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4344
    self primitiveFailed
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4345
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4346
    "Created: / 06-12-2006 / 13:09:24 / cg"
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4347
!
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4348
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4349
revalidateModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4350
    "revalidate all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4351
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4352
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4353
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4354
    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4355
	'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
  4356
	' id=' errorPrint. handle moduleID errorPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4357
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4358
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4359
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4360
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4361
    __REVALIDATE_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4362
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4363
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4364
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4365
saveCallInitFunctionAt:address in:aFilenameOrNil specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4366
    OSSignalInterrupt handle:[:ex |
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4367
	aFilenameOrNil notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4368
	    ('ObjectFileLoader [warning]: SignalInterrupt from initFunction in %1' bindWith:(aFilenameOrNil asFilename pathName)) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4369
	] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4370
	    'ObjectFileLoader [warning]: SignalInterrupt from initFunction' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4371
	].
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4372
    ] do:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4373
	^ self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4374
	    callInitFunctionAt:address
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4375
	    specialInit:special
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4376
	    forceOld:forceOld
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4377
	    interruptable:interruptable
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4378
	    argument:argument
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4379
	    identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4380
	    returnsObject:returnsObject
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4381
    ].
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4382
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4383
    "Created: / 15-11-2010 / 13:21:59 / cg"
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4384
!
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4385
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4386
unregisterModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4387
    "unregister classes in the VM.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4388
     This invalidates all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4389
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4390
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4391
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4392
    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4393
	'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
  4394
	' id=' errorPrint. handle moduleID errorPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4395
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4396
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4397
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4398
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4399
    __UNREGISTER_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4400
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4401
! !
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4402
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4403
!ObjectFileLoader class methodsFor:'under test - loading dlls'!
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4404
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4405
loadObjectFiles:aSeqOfFiles
4006
3d53d41791a7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4005
diff changeset
  4406
    "load a sequence of DLLs... first load all dlls with #moduleInit:0
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4407
     then call #moduleInit:1, #moduleInit:2 and #moduleInit:3 for all loaded DLLs.
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4408
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4409
     *** UNDER TEST ...
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4410
	used by ExpeccoStartup under windows.
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4411
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4412
     not supported is C,...
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4413
    "
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4414
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4415
    |filename handle initAddr className infoCollection handles info|
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4416
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4417
    aSeqOfFiles isEmptyOrNil ifTrue:[^ self].
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4418
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4419
    handles := OrderedCollection new.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4420
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4421
    Smalltalk flushCachedClasses.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4422
    Class flushSubclassInfo.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4423
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4424
    aSeqOfFiles do:[:each|
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4425
	filename := each asFilename.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4426
	handle   := self handleForDynamicObject:filename.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4427
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4428
	handle isNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4429
	    Smalltalk showSplashMessage:('loading ', filename baseName).
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4430
	    handle := self loadDynamicObject:filename.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4431
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4432
	    handle notNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4433
		className := self initFunctionBasenameForFile:filename.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4434
		initAddr := self findInitFunction:className in:handle.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4435
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4436
		initAddr notNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4437
		    [
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4438
			self
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4439
			    saveCallInitFunctionAt:initAddr
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4440
			    in:filename
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4441
			    specialInit:true
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4442
			    forceOld:true
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4443
			    interruptable:false
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4444
			    argument:0
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4445
			    identifyAs:handle
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4446
			    returnsObject:false.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4447
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4448
			info := self loadStatusFor:nil.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4449
			(info first == #tryAgain)
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4450
		    ] whileTrue.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4451
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4452
		    info first == #ok ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4453
			handles add:handle
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4454
		    ] ifFalse:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4455
			( '%1: error during init: %2' bindWith:each with:info) errorPrintCR.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4456
		    ].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4457
		].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4458
	    ].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4459
	].
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4460
    ].
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4461
    Smalltalk showSplashMessage:('initializing modules-1...').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4462
    self moduleInit:1 forceOld:true interruptable:false.
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4463
    Smalltalk showSplashMessage:('initializing modules-2...').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4464
    self moduleInit:2 forceOld:true interruptable:false.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4465
    ObjectMemory flushCaches.
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4466
    Smalltalk showSplashMessage:('initializing modules-3...').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4467
    self moduleInit:3 forceOld:false interruptable:true.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4468
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4469
    infoCollection := ObjectMemory binaryModuleInfo.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4470
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4471
    handles do:[:each|
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4472
	|classNames classes|
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4473
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4474
	info := infoCollection at:(handle moduleID) ifAbsent:nil.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4475
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4476
	info isNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4477
	    ('error - nil info: %1' bindWith:handle ) errorPrintCR.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4478
	] ifFalse:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4479
	    classNames := info classNames.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4480
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4481
	    classNames notEmptyOrNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4482
		classes := OrderedCollection new:classNames size.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4483
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4484
		classNames do:[:eachClassName | |class|
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4485
		    class := Smalltalk classNamed:eachClassName.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4486
		    class notNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4487
			classes add:class.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4488
		    ].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4489
		].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4490
		classes notEmptyOrNil ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4491
		    classes := classes asArray.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4492
		    classes := classes , (classes collect:[:aClass | aClass class]).
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4493
		].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4494
		handle classes:classes.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4495
	    ].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4496
	].
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4497
    ].
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4498
    Smalltalk showSplashMessage:('done loading modules.').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4499
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4500
"
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4501
    |directory filename dlls|
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4502
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4503
    directory := 'C:\Dokumente und Einstellungen\Steffen Jung\work\exept\expecco\application' asFilename.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4504
    filename := directory construct:'modules.stx'.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4505
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4506
    dlls := OrderedCollection new.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4507
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4508
    filename readingLinesDo:[:aLine|
4224
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4509
	|line dllFile|
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4510
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4511
	line := aLine withoutSeparators.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4512
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4513
	line size > 3 ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4514
	    line first ~~ $# ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4515
		dllFile := directory construct:(line, '.dll').
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4516
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4517
		dllFile exists ifTrue:[
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4518
		    dlls add:dllFile.
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4519
		].
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4520
	    ]
9ba8be62f290 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4194
diff changeset
  4521
	]
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4522
    ].
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4523
    ObjectFileLoader loadObjectFiles:dlls.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4524
"
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4525
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4526
    "Modified: / 11-08-2011 / 17:25:52 / cg"
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4527
! !
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4528
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  4529
!ObjectFileLoader class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4530
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4531
version
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4532
    ^ '$Header$'
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  4533
!
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  4534
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  4535
version_CVS
3721
7005e8d826cb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3611
diff changeset
  4536
    ^ '$Header$'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4537
! !
1358
d36c7e6c9e45 refactored
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4538
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
  4539
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  4540
ObjectFileLoader initialize!