ObjectFileLoader.st
author Claus Gittinger <cg@exept.de>
Mon, 11 Mar 2013 12:01:04 +0100
changeset 3034 1d1f847c0fc2
parent 3032 23178d70d10f
child 3035 f8b3a98cbb1c
permissions -rw-r--r--
class: ObjectFileLoader changed: #loadObjectFile:invokeInitializeMethods: still install autoloaded classes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     1
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
     3
	      All Rights Reserved
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     4
7ad01559b262 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
7ad01559b262 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
7ad01559b262 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7ad01559b262 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7ad01559b262 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
7ad01559b262 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    11
"
1116
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
    12
"{ Package: 'stx:libcomp' }"
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
    13
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    14
Object subclass:#ObjectFileLoader
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    15
	instanceVariableNames:''
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    16
	classVariableNames:'MySymbolTable Verbose LastError LinkErrorMessage NextHandleID
149
3dc42a5ab417 default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    17
		LoadedObjects PreviouslyLoadedObjects ActuallyLoadedObjects
2982
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
    18
		ErrorPrinting LastErrorNumber OldSpaceReserve
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
    19
		CopyLibrariesWhenLoading'
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    20
	poolDictionaries:''
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    21
	category:'System-Compiler'
47
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    22
!
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    23
2627
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    24
Error subclass:#ObjectFileLoadError
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    25
	instanceVariableNames:''
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    26
	classVariableNames:''
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    27
	poolDictionaries:''
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    28
	privateIn:ObjectFileLoader
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    29
!
a34348df953a changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
    30
2284
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    31
Notification subclass:#ObjectFileLoadErrorNotification
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    32
	instanceVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    33
	classVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    34
	poolDictionaries:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    35
	privateIn:ObjectFileLoader
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    36
!
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    37
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    38
ObjectFileLoader::ObjectFileLoadErrorNotification subclass:#RegistrationFailedErrorNotification
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    39
	instanceVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    40
	classVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    41
	poolDictionaries:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    42
	privateIn:ObjectFileLoader
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    43
!
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    44
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    45
ObjectFileLoader::ObjectFileLoadErrorNotification subclass:#SuperClassMissingErrorNotification
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    46
	instanceVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    47
	classVariableNames:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    48
	poolDictionaries:''
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    49
	privateIn:ObjectFileLoader
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    50
!
ace9886a301e changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2256
diff changeset
    51
53
c5dd7abf8431 *** empty log message ***
claus
parents: 51
diff changeset
    52
!ObjectFileLoader primitiveDefinitions!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    53
%{
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    54
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
    55
#undef true
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
    56
#undef false
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
    57
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    58
/*
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    59
 * by default, use whatever the system provides
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    60
 */
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
    61
#if defined(SYSV4) || defined(HAS_DLOPEN)   /* sys5.4 dlopen interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    62
# define SYSV4_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    63
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    64
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    65
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    66
#ifdef __VMS__
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    67
# undef __new
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    68
#endif
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    69
95
claus
parents: 94
diff changeset
    70
#ifdef DL1_6    /* dl1.6 COFF loader */
claus
parents: 94
diff changeset
    71
# define HAS_DL
claus
parents: 94
diff changeset
    72
#endif
claus
parents: 94
diff changeset
    73
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    74
#include <stdio.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    75
95
claus
parents: 94
diff changeset
    76
#ifdef NEXT_DL
claus
parents: 94
diff changeset
    77
# ifndef _RLD_H_
claus
parents: 94
diff changeset
    78
#  define _RLD_H_
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    79
#  ifdef NEXT3
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    80
#   include <mach-o/rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    81
#  else
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    82
#   include <rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
    83
#  endif
95
claus
parents: 94
diff changeset
    84
# endif
claus
parents: 94
diff changeset
    85
#endif /* NEXT_DL */
claus
parents: 94
diff changeset
    86
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
    87
#ifdef SYSV4_DL
1903
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    88
# ifndef dlfcn_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    89
#  include <dlfcn.h>
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    90
#  define dlfcn_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
    91
# endif
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
    92
#endif
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
    93
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    94
#ifdef GNU_DL
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    95
#  ifndef dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    96
#   include "dld.h"
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    97
#   define dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    98
#  endif
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
    99
#endif
95
claus
parents: 94
diff changeset
   100
claus
parents: 94
diff changeset
   101
#ifdef DL1_6
claus
parents: 94
diff changeset
   102
#  ifndef dl_h
claus
parents: 94
diff changeset
   103
#   include "dl.h"
claus
parents: 94
diff changeset
   104
#   define dl_h
claus
parents: 94
diff changeset
   105
#  endif
claus
parents: 94
diff changeset
   106
#endif
claus
parents: 94
diff changeset
   107
97
claus
parents: 96
diff changeset
   108
#ifdef AIX_DL
claus
parents: 96
diff changeset
   109
# include <nlist.h>
100
claus
parents: 98
diff changeset
   110
# include <sys/ldr.h>
claus
parents: 98
diff changeset
   111
# include <errno.h>
97
claus
parents: 96
diff changeset
   112
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   113
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   114
#ifdef HPUX10_DL
1903
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   115
# ifndef dl_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   116
#  include <dl.h>
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   117
#  define dl_h
82280b3e8178 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1897
diff changeset
   118
# endif
524
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
   119
# include <errno.h>
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   120
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   121
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   122
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   123
# include <be/kernel/image.h>
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   124
#endif
Claus Gittinger <cg@exept.de>
parents: 881
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:
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   284
	a) if there exists some dynamic-link facility such as:
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   285
	   GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   286
	   or LoadLibrary (Win32), this is used
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   287
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   288
	b) if no such facility exists, the normal linker is used to
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   289
	   link the module to text/data address as previously malloced,
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   290
	   and the object file loaded into that space.
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   291
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   292
    Currently, not all mechanisms work fully satisfying.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   293
    For example, the sun dl*-functions do an exit on link-errors (which
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   294
    is certainly not what we want here :-(; the NeXT mechanism does not
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   295
    allow for selective unloading (only all or the last loaded module).
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   296
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   297
    The only really useful packages are the GNU-dl package,
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   298
    the SGI/Unixware/sys5.4/linux libdl packages and the win32 dll's.
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   299
    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
   300
    (which is more or less obsolete);
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   301
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   302
    For the above reasons, dynamic object loading is currently only
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   303
    officially released for SYS5.4-based, LINUX and win32 systems.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   304
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   305
    Once stable, the functionality contained herein will be moved into
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   306
    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
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   310
    Right now, reloading of object files is done by smalltalk code,
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).
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   315
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   316
    [author:]
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   317
	Claus Gittinger
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   318
"
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
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   321
!ObjectFileLoader class methodsFor:'initialization'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   322
7ad01559b262 Initial revision
claus
parents:
diff changeset
   323
initialize
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   324
    |systemType libDir linkCommand linkArgs libPath searchedLibraries|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   325
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
   326
    Verbose := false.
2745
d3c89036c184 changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
   327
    "/ Verbose := true.
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
   328
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   329
    OperatingSystem isMSDOSlike ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   330
	"/ default setup for msc
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   331
	ParserFlags useBorlandC ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   332
	    libDir := '..\lib\bc'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   333
	    libDir asFilename exists ifFalse:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   334
		libDir := '..\lib\lib\bc'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   335
		libDir asFilename exists ifFalse:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   336
		    libDir := '..\lib'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   337
		]
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   338
	    ].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   339
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   340
	    linkCommand isNil ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   341
		"/ linkCommand := 'tlink32'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   342
		linkCommand := 'ilink32'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   343
	    ].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   344
	    linkArgs isNil ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   345
		"/ linkArgs := '-L',libDir,' -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ',libDir,'\librun.lib'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   346
		linkArgs := '-L',libDir,' -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   347
	    ].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   348
	    searchedLibraries := #(
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   349
				    'import32.lib'
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   350
				  ).
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   351
	] ifFalse:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   352
	    linkCommand isNil ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   353
		linkCommand := 'link'
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   354
	    ].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   355
	    linkArgs isNil ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   356
		linkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   357
	    ].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   358
	].
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   359
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   360
201
66bd5f9c781c only init once
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
   361
    MySymbolTable isNil ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   362
	NextHandleID := 1.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   363
	ObjectMemory addDependent:self.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   364
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   365
	OperatingSystem isMSDOSlike ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   366
	    searchedLibraries := #(
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   367
				    'import32.lib'
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   368
				  ).
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   369
	].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   370
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   371
	OperatingSystem isUNIXlike ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   372
	    |ldLibraryPath|
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   373
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   374
	    systemType := OperatingSystem getOSType.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   375
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   376
	    "/ name of object file, where initial symbol table is found
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   377
	    "/ not req'd for all architectures.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   378
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   379
	    MySymbolTable := 'stx'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   380
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   381
	    searchedLibraries := #().
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   382
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   383
	    "/ default libraryPath where shared objects are expected
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   384
	    "/ when a sharedObject load requires other objects to be loaded.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   385
	    "/ For more compatibility with ELF systems, look for a shell variable
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   386
	    "/ named LD_LIBRARY_PATH, and - if present - take that instead if a default.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   387
	    "/ Can (should) be set in the smalltalk.rc file.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   388
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   389
	    ldLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   390
	    ldLibraryPath isEmptyOrNil ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   391
		libPath := '.:lib:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   392
	    ] ifFalse:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   393
		"/ only needed for AIX - the dynamic linker of other Unixes use LD_LIBRARY_PATH implicitly
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   394
		systemType = #aix ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   395
		    libPath := ldLibraryPath.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   396
		].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   397
	    ]
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   398
	]
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   399
    ].
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
    ParserFlags linkCommand:linkCommand.
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   402
    ParserFlags linkArgs:linkArgs.
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
   403
    ParserFlags libPath:libPath ? ''.
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   404
    ParserFlags searchedLibraries:searchedLibraries.
107
claus
parents: 106
diff changeset
   405
claus
parents: 106
diff changeset
   406
    "
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   407
     LinkArgs := LinkCommand := nil.
107
claus
parents: 106
diff changeset
   408
     ObjectFileLoader initialize
claus
parents: 106
diff changeset
   409
    "
316
ee3426730cfc on sunos: link dynamic objects against libc.a for unresolved symbols.
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   410
2933
8d05290d3b98 changed: #initialize
Claus Gittinger <cg@exept.de>
parents: 2932
diff changeset
   411
    "Modified: / 28-09-2012 / 18:19:28 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   412
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   413
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   414
lastError
780
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   415
    ^ LastError ? 'unknown error'
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   416
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   417
    "Modified: / 30.9.1998 / 17:21:23 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   418
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   419
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   420
libPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   421
    "see comment in #libPath:"
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   422
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   423
    ^ ParserFlags libPath
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   424
!
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
libPath:aSharedLibraryPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   427
    "set the pathnames of directories, where other shared objects
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   428
     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
   429
     library object to be loaded.
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   430
     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
   431
     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
   432
     LD_LIBRARY_PATH environment variable."
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   433
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   434
    ParserFlags libPath:aSharedLibraryPath
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   435
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
     ObjectFileLoader libPath:'.:/usr/lib:/usr/local/lib'
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   438
    "
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   439
!
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   440
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   441
linkErrorMessage
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
!
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
searchedLibraries
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   446
    "see comment in #searchedLibraries:"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   447
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   448
    ^ ParserFlags searchedLibraries
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   449
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   450
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   451
searchedLibraries:aCollectionOfArchivePathNames
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   452
    "set the pathnames of archives which are to be searched
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   453
     when unresolved references occur while loading in an object
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   454
     file. On systems which support shared libraries (all SYS5.4 based
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   455
     systems), this is usually not required. Instead, modules which are to
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   456
     be filed in (.so files) are to be prelinked with the appropriate
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   457
     shared libraries. The dynamic loader then cares about loading those
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   458
     modules (keeping track of which modules are already loaded).
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   459
     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
   460
     (i.e. currently only linux and a.out-sunos) need to set this."
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   461
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   462
    ParserFlags searchedLibraries:aCollectionOfArchivePathNames
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   463
!
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   464
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   465
verbose
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   466
    "return true, if debug traces are turned on"
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   467
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   468
    ^ Verbose
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   469
!
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   470
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   471
verbose:aBoolean
7ad01559b262 Initial revision
claus
parents:
diff changeset
   472
    "turn on/off debug traces"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   473
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
   474
    Verbose := aBoolean
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   475
7ad01559b262 Initial revision
claus
parents:
diff changeset
   476
    "ObjectFileLoader verbose:true"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   477
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   478
2982
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   479
!ObjectFileLoader class methodsFor:'accessing'!
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   480
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   481
copyLibrariesWhenLoading
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   482
    "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
   483
     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
   484
     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
   485
     so that the original can still be recompiled.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   486
     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
   487
     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
   488
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   489
    ^ CopyLibrariesWhenLoading ? false
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   490
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
     self copyLibrariesWhenLoading
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   493
     self copyLibrariesWhenLoading:true
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   494
    "
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   495
!
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   496
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   497
copyLibrariesWhenLoading:aBoolean
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   498
    "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
   499
     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
   500
     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
   501
     so that the original can still be recompiled.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   502
     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
   503
     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
   504
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   505
    CopyLibrariesWhenLoading := aBoolean.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
   506
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
     self copyLibrariesWhenLoading:true
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
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   512
!ObjectFileLoader class methodsFor:'change & update'!
291
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   513
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   514
update:something with:aParameter from:changedObject
107
claus
parents: 106
diff changeset
   515
    "sent, when image is saved or restarted"
claus
parents: 106
diff changeset
   516
claus
parents: 106
diff changeset
   517
    (something == #aboutToSnapshot) ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   518
	self invalidateAndRememberAllObjectFiles
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   519
    ].
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   520
    (something == #finishedSnapshot) ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   521
	self revalidateAllObjectFiles
107
claus
parents: 106
diff changeset
   522
    ].
226
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   523
"/    (something == #restarted) ifTrue:[
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   524
"/        self reloadAllRememberedObjectFiles
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   525
"/    ].
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   526
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   527
    "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
   528
    "Modified: 8.3.1996 / 23:34:29 / cg"
291
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   529
    "Created: 21.6.1996 / 19:50:01 / cg"
107
claus
parents: 106
diff changeset
   530
! !
claus
parents: 106
diff changeset
   531
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   532
!ObjectFileLoader class methodsFor:'defaults'!
115
claus
parents: 114
diff changeset
   533
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   534
hasValidBinaryExtension:aFilename
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   535
    "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
   536
     This checks only the extension - not its contents.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   537
     (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
   538
     This is very machine specific."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   539
1697
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   540
    |suffix|
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   541
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   542
    suffix := aFilename asFilename suffix.
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   543
    ^ self validBinaryExtensions includes:suffix.
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   544
"/    |fn|
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   545
"/
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   546
"/    fn := aFilename asFilename.
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   547
"/    self validBinaryExtensions do:[:ext |
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   548
"/        (fn hasSuffix:ext) ifTrue:[^ true].
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   549
"/    ].
886b80091d5e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
   550
"/    ^ false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   551
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   552
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   553
     ObjectFileLoader hasValidBinaryExtension:'foo.st'
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   554
     ObjectFileLoader hasValidBinaryExtension:'foo.o'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   555
     ObjectFileLoader hasValidBinaryExtension:'foo.so'
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   556
     ObjectFileLoader hasValidBinaryExtension:'foo.dll'
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   557
     ObjectFileLoader hasValidBinaryExtension:'foo.DLL'
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   558
     ObjectFileLoader hasValidBinaryExtension:'foo.obj'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   559
     ObjectFileLoader hasValidBinaryExtension:'foo.sl'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   560
    "
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   561
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   562
    "Modified: / 1.10.1998 / 12:47:01 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   563
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   564
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   565
linkArgs
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   566
    ^ ParserFlags linkArgs
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   567
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   568
    "Created: / 12.8.1998 / 21:41:16 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   569
    "Modified: / 12.8.1998 / 21:42:50 / cg"
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
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   572
linkArgs:anArgString
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   573
    ParserFlags linkArgs:anArgString
759
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
    "
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   576
     MSC:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   577
	ParserFlags linkCommand:'link32'.
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   578
	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
   579
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   580
     Borland:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   581
	ParserFlags linkCommand:'ilink32'.
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   582
	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
   583
'
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   584
'/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
   585
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   586
     Unix:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   587
	ParserFlags linkCommand:'ld'
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   588
	ParserFlags linkArgs:'-shared'
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   589
    "
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   590
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   591
    "Created: / 12.8.1998 / 21:43:16 / cg"
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   592
    "Modified: / 4.9.1998 / 00:33:46 / cg"
759
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
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   595
linkCommand
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   596
    ^ ParserFlags linkCommand
759
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
    "Created: / 12.8.1998 / 21:41:16 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   599
!
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
linkCommand:aCommand
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
   602
    ParserFlags linkCommand:aCommand
759
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
    "Created: / 12.8.1998 / 21:40:44 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   605
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   606
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   607
linkSharedArgs
2651
ee993b9ebefb changed:
Stefan Vogel <sv@exept.de>
parents: 2650
diff changeset
   608
    ^ ParserFlags linkSharedArgs
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   609
!
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   610
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   611
linkSharedArgs:anArgString
1897
49bb87ddc41b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1896
diff changeset
   612
    ParserFlags linkSharedArgs:anArgString
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   613
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   614
    "
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   615
     Linux on AMD64 in 32bit mode:
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
   616
	LinkSharedArgs := '-shared -m elf_i386'
1609
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   617
    "
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   618
!
ffccd234a5bb separate setting for shared-link-arguments
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   619
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   620
loadableBinaryObjectFormat
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   621
    "return a symbol describing the expected binary format
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   622
     for object files to be loadable.
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   623
     This is very machine specific."
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   624
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   625
%{  /* NOCONTEXT */
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   626
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   627
#ifdef HAS_DL
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   628
# if defined(SYSV4) || defined(ELF)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   629
    RETURN ( @symbol(elf));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   630
# endif
1607
074a99bb9a50 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 1602
diff changeset
   631
# if defined(__alpha__) && defined(__osf__)
590
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   632
    RETURN ( @symbol(coff));
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   633
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   634
# if defined(GNU_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   635
    RETURN ( @symbol(aout));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   636
# endif
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   637
# if defined(AIX_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   638
    RETURN ( @symbol(xcoff));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   639
# endif
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   640
# if defined(HPUX10_DL)
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   641
    RETURN ( @symbol(hpcoff));
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   642
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   643
# if defined(DL1_6)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   644
    RETURN ( @symbol(coff));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   645
# endif
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   646
# if defined(WIN_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   647
    RETURN ( @symbol(dll));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   648
# endif
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   649
# if defined(BEOS_DL)
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   650
    RETURN ( @symbol(beobj));
Claus Gittinger <cg@exept.de>
parents: 881
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
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   655
#endif
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   656
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   657
%}.
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   658
    ^ nil
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   659
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   660
    "
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   661
     ObjectFileLoader loadableBinaryObjectFormat
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
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   665
nm:file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   666
   "this should return a string to list the namelist of file.
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   667
    The output of the command should be one line for each symbol,
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   668
    formatted as:
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   669
	addr  segment  name
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   670
    This is parsed and read by #namesMatching:segment:in:.
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   671
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   672
    If your default nm command cannot produce this, write a little
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   673
    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
   674
    below.
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   675
    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
   676
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   677
    |os|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   678
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   679
    os := OperatingSystem getOSType.
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
   680
    (os = #irix or:[os = #osf]) ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   681
	^ 'nm -B ' , file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   682
    ].
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
   683
    (os = #solaris) ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
   684
	^ 'nm -p ' , file
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   685
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   686
    ^ 'nm ' , file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   687
702
80f90a274837 more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   688
    "Modified: / 4.5.1998 / 12:18:47 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   689
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   690
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   691
objectFileExtension
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   692
    "return the fileName extension used for objects,
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   693
     as generated by myself (output of cc).
115
claus
parents: 114
diff changeset
   694
     This is very machine specific."
claus
parents: 114
diff changeset
   695
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   696
    OperatingSystem isMSDOSlike ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   697
	"/ includes all of win32s, win95, winNT & os/2
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   698
	^ '.obj'
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   699
    ].
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   700
    OperatingSystem isVMSlike ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   701
	^ '.obj'
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   702
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   703
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   704
    ^ '.o'
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
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   707
     ObjectFileLoader objectFileExtension
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
    "Modified: / 4.5.1998 / 12:17:34 / cg"
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
sharedLibraryExtension
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   714
    "return the fileName extension used for dynamic loadable objects,
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   715
     as generated by myself (output of linker).
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   716
     This is very machine specific."
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   717
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   718
    |suff|
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   719
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   720
    suff := self sharedLibrarySuffix.
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   721
    suff notNil ifTrue:[^ '.' , suff].
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   722
    ^ suff
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   723
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   724
    "
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   725
     ObjectFileLoader sharedLibraryExtension
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   726
    "
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   727
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   728
    "Modified: / 4.5.1998 / 12:17:34 / cg"
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   729
!
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   730
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   731
sharedLibrarySuffix
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   732
    "return the fileName suffix used for dynamic loadable objects,
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   733
     as generated by myself (output of linker).
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   734
     This is very machine specific."
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   735
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   736
    |os|
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   737
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   738
    OperatingSystem isMSDOSlike ifTrue:[
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   739
	"/ includes all Windows systems & os/2
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   740
	^ 'dll'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   741
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   742
    OperatingSystem isVMSlike ifTrue:[
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   743
	^ 'exe'
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   744
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   745
115
claus
parents: 114
diff changeset
   746
    os := OperatingSystem getSystemType.
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
   747
    (os = #linux and:[self loadableBinaryObjectFormat == #aout]) ifTrue:[
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   748
	"/ not really shared, but loadable
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   749
	^ 'o'
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   750
    ].
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
   751
    (os = #hpux) ifTrue:[
2999
364e8c4013a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2998
diff changeset
   752
	^ 'sl'
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
   753
    ].
119
claus
parents: 118
diff changeset
   754
1287
d1199118e73d sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   755
    ^ 'so'
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   756
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   757
    "
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   758
     ObjectFileLoader sharedLibrarySuffix
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   759
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   760
702
80f90a274837 more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   761
    "Modified: / 4.5.1998 / 12:17:34 / cg"
115
claus
parents: 114
diff changeset
   762
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   763
2012
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   764
useBorlandC
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   765
    ^ ParserFlags useBorlandC
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   766
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   767
    "Created: / 15-03-2007 / 13:32:29 / cg"
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   768
!
c4943f373f06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
   769
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   770
validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   771
    "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
   772
     This is very machine specific."
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   773
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   774
    |os|
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   775
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   776
    OperatingSystem isMSDOSlike ifTrue:[
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   777
	"/ includes all of win32s, win95, winNT & os/2
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   778
	^ #('dll')
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   779
    ].
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   780
    OperatingSystem isVMSlike ifTrue:[
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   781
	^ #('exe')
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   782
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   783
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   784
    os := OperatingSystem getSystemType.
2156
2cb69ec50829 #validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents: 2154
diff changeset
   785
    (os = 'linux') ifTrue:[
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   786
	self loadableBinaryObjectFormat == #aout ifTrue:[
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   787
	    ^ #('o' 'obj' 'a')
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   788
	].
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
   789
	^ #('so')
2156
2cb69ec50829 #validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents: 2154
diff changeset
   790
    ].
2cb69ec50829 #validBinaryExtensions - update for current OSes.
Stefan Vogel <sv@exept.de>
parents: 2154
diff changeset
   791
    (os = 'hpux') ifTrue:[^ #('sl') ].
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   792
    (os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   793
    (os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ].
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   794
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
   795
    "/ a useful default
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   796
1287
d1199118e73d sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   797
    ^ #('so')
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   798
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   799
    "
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   800
     ObjectFileLoader validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   801
    "
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   802
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   803
    "Modified: / 1.10.1998 / 12:46:03 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   804
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   805
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   806
!ObjectFileLoader class methodsFor:'dynamic object loading'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   807
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   808
loadCPlusPlusObjectFile:aFileName
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   809
    "load a c++ object file (.o-file) into the image.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   810
     This method is not maintained (name mangling and static
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   811
     initialization is so different among systems ...)"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   812
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   813
    |handle initAddr list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   814
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   815
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   816
    handle isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   817
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   818
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   819
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   820
    list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   821
list size == 1 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   822
"/    (self isCPlusPlusObject:handle) ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   823
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   824
	    'a c++ object file' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   825
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   826
	"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   827
	 what I would like to get is the CTOR_LIST,
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   828
	 and call each function.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   829
	 But dld cannot (currently) handle SET-type symbols, therefore
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   830
	 we search (using nm) for all __GLOBAL_$I* syms, get their values
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   831
	 and call them each
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   835
"/        initAddr := self getFunction:'__CTOR_LIST__' from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   836
"/        Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
   837
"/            ('calling CTORs at:' , (initAddr printStringRadix:16)) errorPrintCR
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   838
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   839
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   840
	initAddr := self getFunction:list first from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   841
	initAddr isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   842
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   843
	     try with added underscore
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   844
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   845
	    initAddr := self getFunction:('_' , list first) from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   846
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   847
	(initAddr isNil and:[list first startsWith:'_']) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   848
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   849
	     try with removed underscore
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   850
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   851
	    initAddr := self getFunction:(list first copyFrom:2) from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   852
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   853
	initAddr isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   854
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   855
		('no CTOR-func found (' , list first , ')') errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   856
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   857
	    self unloadDynamicObject:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   858
	    ^ nil
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
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   861
	    ('calling CTORs at:' , (initAddr printStringRadix:16)) errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   862
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   863
	self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   864
	    saveCallInitFunctionAt:initAddr
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   865
	    in:aFileName
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   866
	    specialInit:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   867
	    forceOld:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   868
	    interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   869
	    argument:0
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   870
	    identifyAs:nil
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   871
	    returnsObject:false.
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
	    'done with CTORs.' 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
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   877
	"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   878
	 cannot create a CPlusPlus class automatically (there could be more than
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   879
	 one classes in it too ...)
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   880
	"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   881
	^ handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   882
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   883
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   884
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   885
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   886
	'unknown object file' errorPrintCR
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   887
    ].
2348
b2a3bb714bf6 comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents: 2346
diff changeset
   888
    self unloadDynamicObject:handle.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   889
    ^ nil
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
   890
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
   891
    "Modified: / 15-11-2010 / 13:19:06 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   892
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   893
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   894
loadClass:aClassName fromObjectFile:aFileName
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   895
    "load a compiled class (.o-file) into the image.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   896
     Returns the class or nil."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   897
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
   898
    |handle initAddr symName newClass moreHandles info status
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   899
     otherClass knownToBeOk|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   900
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   901
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   902
    handle isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   903
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   904
    ].
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
     get the Init-function; let the class install itself
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   908
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   909
    symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   910
    initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   911
    initAddr isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   912
	"try with added underscore"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   913
	symName := '__' , aClassName , '_Init'.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   914
	initAddr := self getFunction:symName from:handle.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   915
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   916
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   917
    knownToBeOk := true.
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
"/    knownToBeOk ifFalse:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   920
"/        |list|
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
   921
"/
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   922
"/        Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
   923
"/            'looking for undefs ...' errorPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   924
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   925
"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   926
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   927
"/         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
   928
"/         files (libs, other modules)
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
"/        list := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   931
"/        list notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   932
"/            moreHandles := self loadModulesFromListOfUndefined:list.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   933
"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   934
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   935
"/             now, try again
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   936
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   937
"/            symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   938
"/            initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   939
"/            initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   940
"/                "try with added underscore"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   941
"/                symName := '__' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   942
"/                initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   943
"/            ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   944
"/        ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   945
"/    ].
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
    initAddr notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   948
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   949
	    ('calling init at: ' , (initAddr printStringRadix:16)) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   950
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   951
	info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   952
	status := info at:1.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   953
	"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   954
	 if any classes are missing ...
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   955
	"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   956
	(status == #missingClass) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   957
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   958
	     ... and we are loading a module ...
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   959
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   960
	    Transcript showCR:'try for missing class in same object ...'.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   961
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   962
		'try for missing class:' errorPrint. (info at:2) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   963
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   964
	    otherClass := self loadClass:(info at:2) fromObjectFile:aFileName.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   965
	    otherClass notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   966
		"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   967
		 try again ...
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   968
		"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   969
		Transcript showCR:'missing class is here; try again ...'.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   970
		info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   971
		status := info at:1.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   972
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   973
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   974
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   975
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   976
	    'done init status=' errorPrint. info errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   977
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   978
	(status == #unregisteredSuperclass) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   979
	    Transcript showCR:'superclass is not registered'.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   980
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   981
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   982
	(Symbol hasInterned:aClassName) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   983
	    newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   984
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   985
		'newClass is: ' errorPrint. newClass errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   986
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   987
	    newClass notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   988
		Smalltalk at:aClassName asSymbol put:newClass.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   989
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   990
		(newClass includesSelector:#initialize) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   991
		    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   992
			'initialize newClass ...' errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   993
		    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   994
		    newClass initialize.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   995
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   996
		"force cache flush"
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   997
		Smalltalk isInitialized ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   998
		    Smalltalk changed.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
   999
		]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1000
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1001
	] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1002
	    'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1003
	    ' did not define itself' errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1004
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1005
	     do not unload - could have installed other classes/methods ...
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1006
	    "
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1007
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1008
	^ newClass
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1009
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1010
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1011
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1012
	('no symbol: ', symName,' in ',aFileName) errorPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1013
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1014
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1015
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1016
     unload
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1017
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1018
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1019
	'unloading due to init failure:' errorPrint. handle pathName errorPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1020
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1021
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1022
    moreHandles notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1023
	moreHandles do:[:eachHandle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1024
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1025
		('unloading: ', eachHandle printString) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1026
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1027
	    self unloadDynamicObject:eachHandle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1028
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1029
    ].
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:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1032
	('unloading: ', handle printString) errorPrintCR.
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1033
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1034
    self unloadDynamicObject:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1035
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1036
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1037
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1038
     ObjectFileLoader loadClass:'Tetris'      fromObjectFile:'../clients/Tetris/Tetris.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1039
     ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1040
     ObjectFileLoader loadClass:'Foo'         fromObjectFile:'classList.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1041
    "
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  1042
582
9a00e2dbdc97 must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
  1043
    "Modified: 6.7.1997 / 12:34:48 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1044
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1045
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1046
loadLibrary:aLibraryFileName
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1047
    "load a library; search in some standard places and using
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1048
     standard suffixes (i.e. no suffix should be given in the arg).
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1049
     Returns a handle or nil.
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1050
     Use this to attach C-libraries."
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1051
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1052
    |s suffixes handle libFilename libPath|
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1053
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1054
    Verbose ifTrue:[
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1055
	('loadLibrary:' , aLibraryFileName) errorPrintCR.
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1056
    ].
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1057
    libFilename := aLibraryFileName asFilename.
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1058
    (s := libFilename suffix) isEmpty ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1059
	suffixes := self validBinaryExtensions
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1060
    ] ifFalse:[
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1061
	suffixes := Array with:s
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1062
    ].
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1063
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1064
    "/ try each suffix ...
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1065
    suffixes do:[:aSuffix |
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1066
	|fn f|
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1067
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1068
	aSuffix isEmptyOrNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1069
	    fn := libFilename.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1070
	] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1071
	    fn := libFilename withSuffix:aSuffix.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1072
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1073
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1074
	Verbose ifTrue:[
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1075
	    ('loadLibrary try:' , fn asString) errorPrintCR.
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1076
	].
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1077
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1078
	handle := self loadObjectFile:fn asString.
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1079
	handle notNil ifTrue:[^ handle].
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1080
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1081
	(libFilename isAbsolute
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1082
	 or:[(aLibraryFileName startsWith:'./')
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1083
	 or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1084
	    "/ already tried...
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1085
	] ifFalse:[
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1086
	    "/ try to load it by name - maybe someone else knows
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1087
	    "/ how to find it (the system itself)
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1088
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  1089
	    "/ try each directory in libPath
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1090
	    libPath := self libPath.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1091
	    libPath notEmptyOrNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1092
		(libPath asCollectionOfSubstringsSeparatedBy:$:) do:[:eachSinglePath |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1093
		    f := eachSinglePath asFilename construct:fn.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1094
		    f exists ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1095
			handle := self loadObjectFile:f pathName.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1096
			handle notNil ifTrue:[^ handle].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1097
		    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1098
		]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1099
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1100
	]
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1101
    ].
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1102
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1103
    ^ nil
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1104
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1105
    "
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1106
     ObjectFileLoader loadLibrary:'libjpeg'
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
  1107
     ObjectFileLoader loadLibrary:'odbc32'
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1108
    "
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1109
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
  1110
    "Modified: / 4.5.1999 / 17:01:47 / cg"
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1111
!
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1112
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1113
loadMethodObjectFile:aFileName
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1114
    "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
  1115
     This does a slightly different initialization.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1116
     Return an object handle; nil on error"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1117
346
29fe74c22e1e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1118
    |handle initAddr initName m|
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1119
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1120
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1121
    "/ load the objectfile
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1122
    "/
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1123
    handle := self loadDynamicObject:aFileName.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1124
    handle isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1125
	^ nil
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1126
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1127
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1128
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1129
    "/ find the entry function
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1130
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1131
    initName := aFileName asFilename withoutSuffix baseName.
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1132
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1133
    initAddr := self getFunction:'__' , initName , '_Init' from:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1134
    initAddr isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1135
	initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1136
	initAddr isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1137
	    (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1138
		self listUndefinedSymbolsIn:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1139
		'ObjectFileLoader [info]: undefined symbols in primitive code' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1140
	    ] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1141
		('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1142
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1143
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1144
	    "/
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1145
	    "/ not found - unload
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1146
	    "/
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1147
	    self unloadDynamicObject:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1148
	    ^ nil
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1149
	]
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1150
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1151
1555
9650c861704b Use class based signals
Stefan Vogel <sv@exept.de>
parents: 1543
diff changeset
  1152
    OSSignalInterrupt handle:[:ex |
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1153
	('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1154
	self unloadDynamicObject:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1155
	^ nil
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1156
    ] do:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1157
	"/
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1158
	"/ call it - it returns the new method object
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1159
	"/
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1160
	self                              "/ registration
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1161
	    saveCallInitFunctionAt:initAddr
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1162
	    in:aFileName
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1163
	    specialInit:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1164
	    forceOld:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1165
	    interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1166
	    argument:0
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1167
	    identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1168
	    returnsObject:false.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1169
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1170
	self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1171
	    saveCallInitFunctionAt:initAddr   "/ global setup
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1172
	    in:aFileName
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1173
	    specialInit:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1174
	    forceOld:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1175
	    interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1176
	    argument:1
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1177
	    identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1178
	    returnsObject:false.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1179
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1180
	m := self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1181
	    saveCallInitFunctionAt:initAddr   "/ initialization
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1182
	    in:aFileName
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1183
	    specialInit:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1184
	    forceOld:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1185
	    interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1186
	    argument:2
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1187
	    identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1188
	    returnsObject:true.
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1189
    ].
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1190
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1191
    handle method:m.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1192
    ^ handle
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1193
1942
dffae6fd22d8 oops - initialization of single-method objects needs phase1
Claus Gittinger <cg@exept.de>
parents: 1906
diff changeset
  1194
    "Created: / 05-12-1995 / 20:59:46 / cg"
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1195
    "Modified: / 15-11-2010 / 13:20:36 / cg"
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1196
!
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1197
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1198
loadObjectFile:aFileName
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1199
    "load an object file (.o-file) into the image;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1200
     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
  1201
     This may be either a smalltalk object or a C-object file.
472
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1202
     The object files init function (if any) is called, and the module
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1203
     is unloaded if it returns failure (use lowLevel load, to load a file
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1204
     without automatic initialization).
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1205
     Return nil on error, an objectFile handle if ok."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1206
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1207
    ^ self
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1208
	loadObjectFile:aFileName
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1209
	invokeInitializeMethods:true
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1210
!
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1211
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1212
loadObjectFile:pathNameOrFilename invokeInitializeMethods:invokeInitializeMethods
1993
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1213
    "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
  1214
     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
  1215
     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
  1216
     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
  1217
     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
  1218
     without automatic initialization).
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1219
     Returns nil on error, or the objectFile's handle if ok."
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1220
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1221
    |filename pathName handle initAddr initDefinitionAddr initFunctionName initNames didInit info status
3007
202281d1ff47 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3006
diff changeset
  1222
     dummyHandle msg isCModule doNotUnload definitionClassName definitionClass|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1223
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1224
    filename := pathNameOrFilename asFilename.
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1225
    pathName := filename pathName.
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1226
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1227
    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
  1228
    handle notNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1229
        "already loaded"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1230
        ^ 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
  1231
    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  1232
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  1233
    handle := self loadDynamicObject:filename.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1234
    handle isNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1235
        ^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1236
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1237
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1238
    didInit := false.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1239
    isCModule := false.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1240
1993
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1241
    "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
  1242
     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
  1243
1659
5ba3deaefc09 flags moved to ParserFlags
Claus Gittinger <cg@exept.de>
parents: 1613
diff changeset
  1244
    ParserFlags searchedLibraries notNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1245
        (self hasUndefinedSymbolsIn:handle) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1246
            self initializeLoader.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1247
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1248
            ParserFlags searchedLibraries do:[:libName |
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1249
                (self hasUndefinedSymbolsIn:handle) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1250
                    Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1251
                    dummyHandle := Array new:4.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1252
                    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
228
be9939d96cfe removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
  1253
"/                    dummyHandle isNil ifTrue:[
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  1254
"/                        Transcript showCR:'   ... load of library ' , libName , ' failed.'.
228
be9939d96cfe removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
  1255
"/                    ]
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1256
                ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1257
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1258
            (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1259
                Transcript showCR:('ObjectFileLoader [info]: still undefined symbols in ', pathName,'.').
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1260
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1261
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1262
    ].
2882
e7fb69ba1a54 Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents: 2806
diff changeset
  1263
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1264
    "
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1265
     first, expect the classes-name to be the fileNames-baseName
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1266
     (if its not, it may be a method or function module;
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1267
      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
  1268
      scheme as well)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1269
    "
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1270
    initFunctionName := self initFunctionBasenameForFile:filename.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1271
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1272
    "look for explicit initDefinition (xxx_InitDefinition) function
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1273
     This is used in ST packaged classLib object files"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1274
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1275
    (initFunctionName startsWith:'lib') ifTrue:[
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1276
        definitionClassName := initFunctionName copyFrom:4.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1277
        definitionClass := Smalltalk classNamed:definitionClassName.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1278
    ].
3030
ebfdf6943817 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3029
diff changeset
  1279
    (definitionClass isNil or:[definitionClass isLoaded not]) ifTrue:[
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1280
        "the project definition class has not been loaded yet.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1281
         initialize and load it"
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1282
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1283
        initDefinitionAddr := self findInitDefinitionFunction:initFunctionName in:handle.
3032
23178d70d10f class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3031
diff changeset
  1284
        initDefinitionAddr isNil ifTrue:[
23178d70d10f class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3031
diff changeset
  1285
            ('WARNING: no init definitions for: ' , pathName) errorPrintCR.
23178d70d10f class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3031
diff changeset
  1286
        ] ifFalse:[
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1287
            Verbose ifTrue:[
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1288
                ('calling initDefinition at:' , (initDefinitionAddr printStringRadix:16)) errorPrintCR.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1289
            ].
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1290
            info := self
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1291
                        performModuleInitAt:initDefinitionAddr
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1292
                        invokeInitializeMethods:false
3030
ebfdf6943817 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3029
diff changeset
  1293
                        for:definitionClassName
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1294
                        identifyAs:handle.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1295
            status := info at:1.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1296
            status == #ok ifTrue:[
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1297
                "/ now, we have only loaded and installed the projectDefinition class.
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1298
                "/ (but no containing classes or extensions, yet).
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1299
                "/ let the projectDefinition load any prereqs
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1300
               definitionClassName notNil ifTrue:[
3030
ebfdf6943817 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3029
diff changeset
  1301
                    definitionClass := Smalltalk classNamed:definitionClassName.
ebfdf6943817 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3029
diff changeset
  1302
                    definitionClass notNil ifTrue:[
ebfdf6943817 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3029
diff changeset
  1303
                        definitionClass 
ebfdf6943817 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3029
diff changeset
  1304
                            initialize;
3034
1d1f847c0fc2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1305
                            loadPreRequisitesAsAutoloaded:false;
1d1f847c0fc2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1306
                            "/ install autoload stubs for missing classes
1d1f847c0fc2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1307
                            loadAllClassesAsAutoloaded:true.
3029
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1308
                    ].
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1309
                ].
b7834ee3b06c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  1310
            ]
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1311
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1312
    ].
1993
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1313
    "look for explicit init (xxx_Init) function
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1314
     This is used in ST object files"
b83da4907a07 more info when library cannot be loaded
Stefan Vogel <sv@exept.de>
parents: 1988
diff changeset
  1315
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1316
    initAddr := self findInitFunction:initFunctionName in:handle.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1317
    initAddr notNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1318
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1319
            ('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1320
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1321
        info := self
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1322
                    performModuleInitAt:initAddr
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1323
                    invokeInitializeMethods:invokeInitializeMethods
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1324
                    for:nil
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1325
                    identifyAs:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1326
        status := info at:1.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1327
        status == #ok ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1328
            didInit := true.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1329
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1330
    ] ifFalse:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1331
        "look for explicit C-init (xxx__Init) function
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1332
         This is used in C object files"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1333
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1334
        initAddr := self findFunction:initFunctionName suffix:'__Init' in:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1335
        initAddr notNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1336
            isCModule := true.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1337
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1338
            OSSignalInterrupt handle:[:ex |
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1339
                ('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , pathName) errorPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1340
                status := #initFailed.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1341
            ] do:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1342
                (self
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1343
                    saveCallInitFunctionAt:initAddr
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1344
                    in:pathNameOrFilename
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1345
                    specialInit:false
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1346
                    forceOld:true
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1347
                    interruptable:false
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1348
                    argument:0
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1349
                    identifyAs:handle
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1350
                    returnsObject:false) < 0
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1351
                ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1352
                    Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1353
                        'init function return failure ... unload' errorPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1354
                    ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1355
                    status := #initFailed.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1356
                ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1357
                    didInit := true.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1358
                ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1359
            ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1360
        ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1361
            status := #noInitFunction.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1362
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1363
            "look for any init-function(s); call them all"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1364
            Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1365
                'no good init functions found; looking for candidates ...' errorPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1366
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1367
            initNames := self namesMatching:'*_Init' segment:'[tT?]' in:pathName.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1368
            initNames notNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1369
                initNames do:[:aName |
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1370
                    initAddr := self getFunction:aName from:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1371
                    initAddr isNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1372
                        (aName startsWith:'_') ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1373
                            initAddr := self getFunction:(aName copyFrom:2) from:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1374
                        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1375
                    ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1376
                    initAddr isNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1377
                        Transcript showCR:('no symbol: ',aName,' in ', pathName).
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1378
                    ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1379
                        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1380
                            ('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1381
                        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1382
                        self
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1383
                            performModuleInitAt:initAddr
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1384
                            invokeInitializeMethods:invokeInitializeMethods
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1385
                            for:nil
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1386
                            identifyAs:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1387
                        didInit := true.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1388
                    ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1389
                ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1390
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1391
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1392
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1393
2457
1927f463ca87 changed: #loadObjectFile:invokeInitializeMethods:
Claus Gittinger <cg@exept.de>
parents: 2456
diff changeset
  1394
    (invokeInitializeMethods and:[didInit not]) ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1395
        status == #noInitFunction ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1396
            msg := 'no init function; assume load ok'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1397
        ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1398
            (status ~~ #registrationFailed
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1399
                and:[status ~~ #initFailed
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1400
                and:[status ~~ #missingClass
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1401
                and:[status ~~ #versionMismatch]]])
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1402
            ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1403
                self listUndefinedSymbolsIn:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1404
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1405
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1406
            Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1407
                'unloading, since init failed ...' errorPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1408
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1409
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1410
            "/ give caller a chance to prevent unloading (to register later, when a prerequisite class comes)
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1411
            status == #missingClass ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1412
                self breakPoint:#sv.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1413
                doNotUnload := (SuperClassMissingErrorNotification query ? false).
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1414
            ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1415
                status == #registrationFailed ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1416
                    self breakPoint:#sv.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1417
                    doNotUnload := (RegistrationFailedErrorNotification query ? false).
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1418
                ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1419
                    doNotUnload := false.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1420
                ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1421
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1422
            doNotUnload ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1423
                self unloadDynamicObject:handle.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1424
                Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1425
                    'unloaded.' errorPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1426
                ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1427
                handle := nil.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1428
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1429
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1430
            status == #initFailed ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1431
                msg := 'module not loaded (init function signaled failure).'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1432
            ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1433
                status == #missingClass ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1434
                    msg := 'module not loaded (superclass missing: ' , (info at:2) , ').'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1435
                ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1436
                    status == #registrationFailed ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1437
                        msg :=  'module registration failed (incompatible object or missing superclass)'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1438
                    ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1439
                        status == #versionMismatch ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1440
                            msg :=  'module registration failed (class version mismatch ' , (info at:2) printString , ')'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1441
                        ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1442
                            (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:pathName) notNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1443
                                msg := 'module not loaded (unknown error reason).'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1444
                            ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1445
                                msg := 'module not loaded (no _Init entry in object file ?).'
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1446
                            ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1447
                        ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1448
                    ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1449
                ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1450
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1451
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1452
        msg := 'ObjectFileLoader [info]: <1p>: <2p>' expandMacrosWith:pathNameOrFilename asFilename baseName with:msg.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1453
        Smalltalk isStandAloneApp ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1454
            msg errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1455
        ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1456
            Transcript showCR:msg
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1457
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1458
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1459
471
508fa84cb122 no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents: 470
diff changeset
  1460
    isCModule ifFalse:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1461
        Smalltalk flushCachedClasses.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1462
        Class flushSubclassInfo.
3032
23178d70d10f class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3031
diff changeset
  1463
        (definitionClass notNil and:[definitionClass isLoaded]) ifTrue:[
3034
1d1f847c0fc2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  1464
            definitionClass loadAllClassesAsAutoloaded:true.
3031
00700dea8600 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3030
diff changeset
  1465
            definitionClass projectIsLoaded:true.
00700dea8600 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 3030
diff changeset
  1466
        ].
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1467
        Smalltalk isInitialized ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1468
            "really don't know, if and what has changed ...
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1469
             ... but assume, that new classes have been installed."
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1470
            Smalltalk changed.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1471
        ].
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
  1472
    ].
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1473
    ^ handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1474
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1475
    "Modified: / 15-11-2010 / 13:19:26 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1476
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1477
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1478
unloadAllObsoleteObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1479
    "unload all dynamically loaded object files for which the classes/method
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1480
     has been already garbage collected."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1481
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1482
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1483
	LoadedObjects values copy do:[:eachHandle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1484
	    (eachHandle notNil and:[eachHandle isObsolete]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1485
		self unloadDynamicObject:eachHandle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1486
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1487
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1488
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1489
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1490
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1491
     ObjectFileLoader unloadAllObsoleteObjectFiles
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1492
    "
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1493
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1494
    "Modified: 5.12.1995 / 18:16:52 / cg"
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1495
!
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1496
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1497
unloadObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1498
    "unload an object file (.o-file) from the image.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1499
     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
  1500
     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
  1501
     track of these. For now, use at your own risk.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1502
     (especially critical are blocks-functions)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1503
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1504
    |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1505
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1506
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1507
	handle := LoadedObjects at:aFileName ifAbsent:nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1508
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1509
    handle isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1510
	('ObjectFileLoader [info]: oops - file to be unloaded was not loaded dynamically (', aFileName , ')') infoPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1511
	^ self
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1512
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1513
2348
b2a3bb714bf6 comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents: 2346
diff changeset
  1514
    "/ call the modules deInit-function and unload...
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1515
    self unloadDynamicObject:handle
1961
d58dc341a012 suppressable info messages
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
  1516
d58dc341a012 suppressable info messages
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
  1517
    "Modified: / 06-12-2006 / 18:19:13 / cg"
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1518
!
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1519
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1520
unloadObjectFileAndRemoveClasses:aFileName
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1521
    "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
  1522
     corresponding classes from the system.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1523
     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
  1524
     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
  1525
     track of these. For now, use at your own risk.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1526
     (especially critical are blocks-functions)."
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1527
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1528
    |handle|
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1529
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1530
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1531
	handle := LoadedObjects at:aFileName ifAbsent:nil
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1532
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1533
    handle isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1534
	('ObjectFileLoader [info]: oops - file to be unloaded was not loaded dynamically (', (aFileName ? 'unknown-file') , ')') infoPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1535
	^ self
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1536
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1537
    handle isClassLibHandle ifFalse:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1538
	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
  1539
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1540
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1541
    "/ remove the classes ...
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1542
    Class withoutUpdatingChangesDo:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1543
	handle classes do:[:eachClass |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1544
	    (eachClass notNil and:[eachClass isMeta not]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1545
		eachClass removeFromSystem.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1546
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  1547
	]
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1548
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1549
2348
b2a3bb714bf6 comment/format in: #unloadObjectFile:
Stefan Vogel <sv@exept.de>
parents: 2346
diff changeset
  1550
    "/ call the modules deInit-function and unload...
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1551
    self unloadDynamicObject:handle
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1552
1961
d58dc341a012 suppressable info messages
Claus Gittinger <cg@exept.de>
parents: 1959
diff changeset
  1553
    "Modified: / 06-12-2006 / 18:19:19 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1554
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1555
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1556
!ObjectFileLoader class methodsFor:'dynamic object queries'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1557
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1558
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
  1559
    "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
  1560
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1561
    |initAddr className nm|
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1562
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1563
    "/ care for colons, as found in nameSpace classes ...
747
cd749767d808 use #copyReplaceAll:with:
Claus Gittinger <cg@exept.de>
parents: 741
diff changeset
  1564
    nm := functionName asString copyReplaceAll:$: with:$_.
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1565
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1566
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1567
     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
  1568
    "
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1569
    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
  1570
    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
  1571
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1572
    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
  1573
    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
  1574
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1575
    "/
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  1576
    "/ 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
  1577
    "/ (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
  1578
    "/ 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
  1579
    "/
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1580
    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
  1581
    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
  1582
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1583
    (functionName startsWith:'lib') ifTrue:[
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1584
	className := functionName
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1585
    ] ifFalse:[
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1586
	"
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1587
	 look for reverse abbreviation - slow, because abbrevs are recursively read
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1588
	"
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1589
	className := Smalltalk classNameForFile:functionName.
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1590
    ].
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1591
    className notNil ifTrue:[
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1592
	initAddr := self getFunction:(className , suffix) from:handle.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1593
	initAddr notNil ifTrue:[^ initAddr].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1594
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1595
	initAddr := self getFunction:('_' , className , suffix) from:handle.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1596
	initAddr isNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1597
	    "/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1598
	    "/ special for broken ultrix nlist
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1599
	    "/ (will not find symbol with single underscore)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1600
	    "/ workaround: add another underscore and retry
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1601
	    "/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1602
	    initAddr := self getFunction:('__' , className , suffix) from:handle.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  1603
	].
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1604
    ].
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1605
    ^ initAddr
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1606
2784
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1607
    "Created: / 13-07-1996 / 00:38:01 / cg"
6e2515a22a6c changed: #findFunction:suffix:in:
Claus Gittinger <cg@exept.de>
parents: 2767
diff changeset
  1608
    "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
  1609
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1610
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1611
findInitDefinitionFunction:functionName in:handle
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1612
    "look for the initDefinition function and return its address or nil"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1613
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1614
    ^ self findFunction:functionName suffix:'_InitDefinition' in:handle
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1615
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1616
    "Modified: 13.7.1996 / 00:38:33 / cg"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1617
!
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1618
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1619
findInitFunction:functionName in:handle
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  1620
    "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
  1621
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1622
    ^ 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
  1623
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1624
    "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
  1625
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1626
1745
1f6a7769faf0 allow for symbol-names
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1627
getFunction:aStringOrSymbol from:handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1628
    "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
  1629
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1630
     Return the address of the function, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1631
1745
1f6a7769faf0 allow for symbol-names
Claus Gittinger <cg@exept.de>
parents: 1742
diff changeset
  1632
    ^ self getSymbol:aStringOrSymbol asString function:true from:handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1633
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1634
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1635
getListOfUndefinedSymbolsFrom:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1636
    "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
  1637
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1638
     Not all systems allow an object with undefined symbols to be
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1639
     loaded (actually, only dld does)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1640
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1641
    |list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1642
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1643
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1644
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1645
    void (*func)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1646
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1647
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1648
    int nMax;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1649
    char **undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1650
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1651
    undefNames = dld_list_undefined_sym();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1652
    if (dld_undefined_sym_count > 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1653
	char **nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1654
	int index;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1655
	int count = dld_undefined_sym_count;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1656
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1657
	if (count > 100) count = 100;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1658
	list = __ARRAY_NEW_INT(count);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1659
	if (list) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1660
	    nm = undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1661
	    for (index = 0; index < count; index++) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1662
		OBJ s;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1663
238
4d80cc4b86dd underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 228
diff changeset
  1664
		s = __MKSTRING(*nm);
4d80cc4b86dd underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 228
diff changeset
  1665
		__ArrayInstPtr(list)->a_element[index] = s;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1666
		__STORE(list, s);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1667
		nm++;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1668
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1669
	    free(undefNames);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1670
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1671
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1672
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1673
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1674
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1675
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1676
     * don't know how to do it
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
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1679
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1680
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1681
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1682
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1683
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1684
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1685
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1686
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1687
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1688
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1689
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1690
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1691
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1692
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1693
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1694
     * don't know how to do it
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1695
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1696
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1697
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1698
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1699
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1700
     * don't know how to do it
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1701
     */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1702
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1703
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1704
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1705
    /*
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1706
     * don't know how to do it
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1707
     */
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1708
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1709
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1710
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1711
    ^ list
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1714
getSymbol:aString function:isFunction from:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1715
    "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
  1716
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1717
     Return the address of the symbol, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1718
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1719
    |sysHandle1 sysHandle2 pathName address|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1720
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1721
    sysHandle1 := aHandle sysHandle1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1722
    sysHandle2 := aHandle sysHandle2.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1723
    pathName := aHandle pathName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1724
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1725
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1726
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1727
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1728
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1729
    void (*func)();
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  1730
    unsigned INT addr;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1731
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1732
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  1733
    if (__isStringLike(aString)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1734
        name = (char *) __stringVal(aString);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1735
        if (isFunction == false) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1736
            addr = dld_get_symbol(name);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1737
            if (addr) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1738
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1739
                    console_printf("addr of %s = %x\n", name, addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1740
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1741
                address = __MKUINT( addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1742
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1743
        } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1744
            func = (void (*) ()) dld_get_func(name);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1745
            if (func) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1746
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1747
                    console_printf("addr of %s = %x\n", name, (INT)func);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1748
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1749
                if (dld_function_executable_p(name)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1750
                    address = __MKUINT( (INT)func );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1751
                } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1752
                    char **undefNames;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1753
                    char **nm;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1754
                    int i;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1755
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1756
                    if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1757
                        console_printf ("function %s not executable\n", name);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1758
                        dld_perror("not executable");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1759
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1760
                        console_printf("undefined:\n");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1761
                        nm = undefNames = dld_list_undefined_sym();
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1762
                        for (i=dld_undefined_sym_count; i; i--) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1763
                            console_printf("    %s\n", *nm++);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1764
                        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1765
                        free(undefNames);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1766
                    }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1767
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1768
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1769
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1770
                    console_printf ("function %s not found\n", name);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1771
                    dld_perror("get_func");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1772
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1773
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1774
        }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1775
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1776
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1777
#endif /* GNU_DL */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1778
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1779
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1780
  {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1781
    void *h;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1782
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1783
    INT val;
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1784
    FARPROC entry;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1785
    HMODULE handle;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1786
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1787
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1788
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1789
        val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1790
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1791
        val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1792
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1793
        handle = (HMODULE)(val);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1794
        if (__isStringLike(aString)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1795
            if (@global(Verbose) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1796
                console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1797
            entry = GetProcAddress(handle, (char *) __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1798
            if (entry != NULL) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1799
                addr = (void *)entry;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1800
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1801
                    console_printf("GetProcAddr %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1802
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1803
                address = __MKUINT( (int)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1804
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1805
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1806
                    console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1807
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1808
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1809
        }
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1810
    }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1811
  }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1812
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1813
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1814
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1815
  {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1816
    void *h;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1817
    void *addr;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1818
    INT val;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1819
    void *handle;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1820
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1821
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1822
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1823
        val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1824
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1825
        val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1826
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1827
        handle = (void *)(val);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1828
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1829
        if (__isStringLike(aString)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1830
            if (@global(Verbose) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1831
                console_printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1832
            entry = NULL;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1833
            get_image_symbol((image_id) handle, (char *) __stringVal(aString), B_SYMBOL_TYPE_TEXT, &entry);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1834
            if (entry != NULL) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1835
                addr = (void *)entry;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1836
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1837
                    console_printf("get_image_symbol %s ok; addr = %x\n", __stringVal(aString), addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1838
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1839
                address = __MKUINT( (int)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1840
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1841
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1842
                    console_printf("get_image_symbol %s error\n", __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1843
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1844
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1845
        }
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1846
    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1847
  }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1848
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1849
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1850
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1851
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1852
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1853
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1854
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1855
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  1856
    if (__isStringLike(aString)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1857
        if (__isStringLike(sysHandle1)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1858
            if (@global(Verbose) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1859
                console_printf("get sym <%s> handle = %x\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1860
                        __stringVal(aString), __stringVal(sysHandle1));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1861
            addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1862
            if (addr) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1863
                if (@global(Verbose) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1864
                    console_printf("addr = %x\n", addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1865
                address = __MKUINT( (int)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1866
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1867
                if (@global(Verbose) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1868
                    console_printf("dl_getsymbol %s failed\n", __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1869
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1870
        }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1871
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1872
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1873
#endif
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
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1876
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1877
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1878
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1879
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1880
    OBJ low = sysHandle1, hi = sysHandle2;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1881
    extern void *dlsym();
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1882
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1883
    if (__bothSmallInteger(low, hi)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1884
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1885
        val = (__intVal(hi) << 32) + __intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1886
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1887
        val = (__intVal(hi) << 16) + __intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1888
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1889
        h = (void *)(val);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1890
        if (__isStringLike(aString)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1891
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1892
                console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)h);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1893
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1894
            addr = dlsym(h, (char *) __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1895
            if (addr) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1896
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1897
                    console_printf("dlsym %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1898
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1899
                address = __MKUINT( (INT)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1900
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1901
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1902
                    console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1903
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1904
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1905
        }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1906
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1907
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1908
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1909
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1910
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1911
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1912
    void *h;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1913
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1914
    INT val, ret;
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1915
    OBJ low = sysHandle1, hi = sysHandle2;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1916
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1917
    if (__bothSmallInteger(low, hi)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1918
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1919
        val = (__intVal(hi) << 32) + __intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1920
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1921
        val = (_intVal(hi) << 16) + _intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1922
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1923
        h = (void *)(val);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1924
        if (__isStringLike(aString)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1925
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1926
                console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1927
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1928
            ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1929
            if (ret != 0) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1930
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1931
                    console_printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1932
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1933
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1934
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1935
                    console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1936
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1937
                address = __MKUINT( (INT)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1938
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1939
        }
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1940
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1941
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1942
#endif
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
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1945
#ifdef AIX_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1946
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1947
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1948
    void *addr;
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1949
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1950
    struct nlist nl[2];
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1951
    OBJ low = sysHandle1, hi = sysHandle2;
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1952
    char nameBuffer[256];
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1953
    static struct funcDescriptor {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1954
        unsigned vaddr;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1955
        unsigned long2;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1956
        unsigned long3;
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1957
    } descriptor;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1958
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1959
    if (__bothSmallInteger(low, hi)
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  1960
     && __isStringLike(aString) && __isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1961
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1962
        val = (__intVal(hi) << 32) + __intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1963
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1964
        val = (__intVal(hi) << 16) + __intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1965
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1966
        h = (void *)(val);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1967
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1968
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1969
            console_printf("get sym <%s> handle = %x path= %s\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1970
                        __stringVal(aString), h, __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1971
        }
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1972
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1973
#define USE_ENTRY
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1974
#ifdef USE_ENTRY
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1975
        /*
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1976
         * only works, if the entry-function is the Init function
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1977
         * (i.e. linked with -e _xxx_Init)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1978
         */
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1979
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1980
            console_printf("returned handle as addr = %x\n", h);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1981
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1982
        address = __MKUINT( (int)(h) );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1983
#else
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1984
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1985
# ifdef USE_DESCRIPTOR
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1986
        if (isFunction == true) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1987
# else
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1988
        if (0) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1989
# endif
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1990
            nameBuffer[0] = '.';
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1991
            strcpy(nameBuffer+1, aString);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1992
            nl[0].n_name = nameBuffer;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1993
        } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1994
            nl[0].n_name = __stringVal(aString);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1995
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1996
        nl[1].n_name = "";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1997
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1998
        if (nlist(__stringVal(pathName), &nl) == -1) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  1999
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2000
                console_printf("nlist error\n");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2001
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2002
        } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2003
            addr = (void *)((unsigned)nl[0].n_value + (unsigned)h);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2004
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2005
            if (isFunction == true) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2006
# ifdef USE_DESCRIPTOR
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2007
                console_printf("daddr = %x\n", addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2008
                console_printf("daddr[0] = %x\n", ((long *)addr)[0]);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2009
                console_printf("daddr[1] = %x\n", ((long *)addr)[1]);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2010
                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
  2011
# endif
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2012
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2013
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2014
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2015
                console_printf("value=%x section=%d type=%x sclass=%d\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2016
                        nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2017
                console_printf("vaddr = %x\n", addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2018
            }
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2019
# ifdef DOES_NOT_WORK
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2020
            address = __MKUINT( (int)addr );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2021
# else
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2022
            descriptor.vaddr = (unsigned) addr;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2023
            descriptor.long2 = 0;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2024
            descriptor.long3 = 0;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2025
            address = __MKUINT( (int)(&descriptor) );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2026
# endif
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2027
        }
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  2028
#endif /* don't USE_ENTRY */
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2029
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2030
  }
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  2031
#endif /* AIX_DL */
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2032
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  2033
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2034
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2035
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2036
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2037
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2038
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2039
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2040
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2041
    if (__bothSmallInteger(low, hi)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2042
        val = (_intVal(hi) << 16) + _intVal(low);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2043
        h = (void *)(val);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2044
        if (__isStringLike(aString)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2045
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2046
                console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2047
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2048
            addr = dlsym(h, __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2049
            if (addr) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2050
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2051
                    console_printf("addr = %x\n", addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2052
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2053
                address = __MKUINT( (int)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2054
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2055
                if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2056
                    console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2057
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2058
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2059
        }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2060
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2061
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2062
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2063
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  2064
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2065
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2066
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2067
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2068
    long result;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2069
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2070
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  2071
    if (__isStringLike(aString)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2072
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2073
            console_printf("get sym <%s>\n", __stringVal(aString));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2074
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2075
        errOut = NXOpenFile(2, 2);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2076
        result = rld_lookup(errOut,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2077
                            (char *) __stringVal(aString),
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2078
                            &addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2079
        NXClose(errOut);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2080
        if (result) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2081
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2082
                console_printf("addr = %x\n", addr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2083
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2084
            address = __MKUINT( (int)addr );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  2085
        }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2086
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2087
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2088
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2089
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2090
%}.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2091
    ^ address
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2092
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2093
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2094
hasUndefinedSymbolsIn:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2095
    "return true, if a module has undefined symbols in it.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2096
     This is only possible if the system supports loading
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2097
     modules with undefined things in it - most do not"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2098
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2099
    ^ (self getListOfUndefinedSymbolsFrom:handle) size > 0
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2100
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2101
    "Modified: 25.4.1996 / 09:47:27 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2102
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2103
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2104
initFunctionBasenameForFile:pathNameOrFilename
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2105
    "return the expected initFunction's name, given a fileName"
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2106
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2107
    |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
  2108
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2109
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2110
     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
  2111
    "
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2112
    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
  2113
    suffixLen := 0.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2114
    self validBinaryExtensions do:[:suffix |
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2115
        suffixLen == 0 ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2116
            (fileName hasSuffix:suffix) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2117
                suffixLen := suffix size + 1
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2118
            ]
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2119
        ]
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2120
    ].
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2121
    name := fileName baseName.
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
  2122
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2123
    suffixLen ~~ 0 ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2124
        name := name copyWithoutLast:suffixLen
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2125
    ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2126
        ('ObjectFileLoader [warning]: invalid binary object file suffix in: ',fileName name) infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2127
        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
  2128
    ].
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2129
    ^ name.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2130
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2131
    "
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2132
     ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.so'  (unix)
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2133
     ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.dll' (msdos)
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2134
     ObjectFileLoader initFunctionBasenameForFile:'demo.so'     
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2135
     ObjectFileLoader initFunctionBasenameForFile:'demo.o'      
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  2136
     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
  2137
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2138
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  2139
    "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
  2140
    "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
  2141
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2142
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2143
isCPlusPlusObject:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2144
    "return true, if the loaded object is a c++ object module.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2145
     This is not yet fully implemented/supported."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2146
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2147
    (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
  2148
    (self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2149
    (self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2150
    (self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2151
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2152
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2153
    "Modified: 25.4.1996 / 09:48:19 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2154
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2155
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2156
isObjectiveCObject:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2157
    "return true, if the loaded object is an objective-C object module.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2158
     This is not yet implemented/supported"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2159
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2160
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2161
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2162
    "Modified: 25.4.1996 / 09:47:59 / cg"
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2165
isSmalltalkObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2166
    "return true, if the loaded object is a smalltalk object module"
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
    "not yet implemented - stc_compiled_smalltalk is a static symbol,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2169
     not found in list - need nm-interface, or nlist-walker
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2170
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2171
    ^ true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2172
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
  2173
"/    (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
  2174
"/    (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
  2175
"/    ^ false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2176
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2177
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2178
listUndefinedSymbolsIn:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2179
    "list undefined objects in a module on the transcript"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2180
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2181
    |undefinedNames|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2182
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2183
    undefinedNames := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2184
    undefinedNames size > 0 ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2185
	Transcript showCR:'undefined:'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2186
	undefinedNames do:[:aName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2187
	    Transcript showCR:'    ' , aName
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2188
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2189
    ].
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2190
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  2191
    "Modified: 18.5.1996 / 15:43:45 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2192
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2193
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2194
namesMatching:aPattern segment:segmentPattern in:aPathName
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2195
    "search for entries which match a pattern.
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2196
     This is obsolete & rubbish - it will vanish soon"
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
    |p l s addr segment name entry|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2199
766
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2200
    OperatingSystem isVMSlike ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2201
	"/ no nm command
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2202
	^ nil
766
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2203
    ].
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2204
    OperatingSystem isMSDOSlike ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2205
	"/ no nm command
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2206
	^ nil
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2207
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2208
    OperatingSystem getOSType = 'aix' ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2209
	"/ no useful nm info
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2210
	^ nil
749
86cf38f5a961 win32 change.
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  2211
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2212
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2213
    l := OrderedCollection new.
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2214
    p := PipeStream readingFrom:(self nm:aPathName).
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2215
    p isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2216
	('ObjectFileLoader [info]: cannot read names from ' , aPathName) infoPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2217
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2218
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2219
    [p atEnd] whileFalse:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2220
	entry := p nextLine.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2221
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2222
	    entry errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2223
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2224
	entry notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2225
	    s := ReadStream on:entry.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2226
	    addr := s nextAlphaNumericWord.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2227
	    s skipSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2228
	    segment := s upToSeparator.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2229
	    s skipSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2230
	    name := s upToEnd withoutSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2231
	    (addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2232
		(aPattern match:name) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2233
		    (segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2234
			l add:name.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2235
			Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2236
			    ('found name: ' , name) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2237
			]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2238
		    ] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2239
			Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2240
			    name errorPrint. ' segment mismatch ' errorPrint.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2241
			    segmentPattern errorPrint. ' ' errorPrint. segment 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
		    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2244
		]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2245
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2246
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2247
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2248
    p close.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2249
    ^ l
225
122d8ff18aff nicer message
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
  2250
749
86cf38f5a961 win32 change.
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  2251
    "Modified: / 27.7.1998 / 20:10:57 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2252
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2253
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2254
releaseSymbolTable
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2255
    "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
  2256
     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
  2257
     On other architectures, this is not needed and therefore a noop."
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
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2260
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2261
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2262
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2263
    errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2264
    rld_unload_all(errOut, (long)0);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2265
    rld_load_basefile(errOut, "smalltalk");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2266
    NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2267
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2268
%}
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2269
! !
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2270
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  2271
!ObjectFileLoader class methodsFor:'image save/restart'!
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2272
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2273
invalidateAndRememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2274
    "invalidate code refs into all dynamically loaded object files.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2275
     Required before writing a snapshot image."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2276
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2277
    LoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2278
	ActuallyLoadedObjects := LoadedObjects.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2279
	self rememberAllObjectFiles.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2280
	ActuallyLoadedObjects keys do:[:aFileName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2281
	    |handle|
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2282
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2283
	    handle := ActuallyLoadedObjects at:aFileName.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2284
	    handle isNil ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2285
		self error:'oops, no handle'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2286
	    ] ifFalse:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2287
		(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2288
		    self invalidateModule:handle
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2289
		]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2290
	    ]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2291
	].
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2292
	LoadedObjects := nil.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2293
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2294
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2295
    "Created: 5.10.1995 / 15:48:56 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2296
    "Modified: 5.10.1995 / 16:48:51 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2297
    "Modified: 12.7.1996 / 17:13:45 / cg"
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2298
!
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2299
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2300
reloadAllRememberedObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2301
    "reload all object modules as were loaded when the image was saved.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2302
     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
  2303
2882
e7fb69ba1a54 Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents: 2806
diff changeset
  2304
    |oldDummyMethod who newHandle
e7fb69ba1a54 Fix #loadObjectFile:invokeInitializeMethods: for snapshot reload
Stefan Vogel <sv@exept.de>
parents: 2806
diff changeset
  2305
     savedOldClasses functions saveOldMethodsPerClass anyModulesToInitialize m|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2306
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2307
    PreviouslyLoadedObjects notNil ifTrue:[
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2308
	anyModulesToInitialize := false.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2309
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2310
	PreviouslyLoadedObjects do:[:entry |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2311
	    |fileName handle cls sel|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2312
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2313
	    fileName := entry key.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2314
	    handle := entry value.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2315
	    handle moduleID:nil.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2316
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2317
	    handle isClassLibHandle ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2318
		"/ ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2319
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2320
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2321
		"/ remember all byteCode methods (as added in the session)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2322
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2323
		savedOldClasses := IdentitySet new.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2324
		saveOldMethodsPerClass := IdentityDictionary new.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2325
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2326
		handle classes do:[:eachClass |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2327
		    (eachClass notNil and:[eachClass ~~ 0]) ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2328
			saveOldMethodsPerClass at:eachClass put:eachClass methodDictionary copy.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2329
			savedOldClasses add:eachClass.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2330
		    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2331
		].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2332
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2333
		"/ load the class binary
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2334
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2335
		handle := self loadObjectFile:fileName invokeInitializeMethods:false.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2336
		handle notNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2337
		    anyModulesToInitialize := true
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2338
		].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2339
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2340
		"/ after reloading of the objectFile,
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2341
		"/ some of the changes made in the previous life have to be
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2342
		"/ redone here - otherwise, we will be left with the
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2343
		"/ state contained in the loaded objectModule - instead of
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2344
		"/ what we had when saving the image ...
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2345
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2346
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2347
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2348
		"/ re-remove removed methods
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2349
		"/ and re-change method categories
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2350
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2351
		savedOldClasses do:[:oldClass |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2352
		    |newClass oldMethods newMethodDict newMthd
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2353
		     oldCat oldClassVarString oldClassCategory|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2354
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2355
		    newClass := Smalltalk classNamed:(oldClass name).
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2356
		    newClass notNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2357
			oldClassVarString := oldClass classVariableString.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2358
			newClass classVariableString ~= oldClassVarString ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2359
			    "/ there is no need to recreate the variable
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2360
			    "/ (its in the smalltalk dictionary)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2361
			    newClass setClassVariableString:oldClassVarString
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2362
			].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2363
			newClass isMeta ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2364
			    newClass setSharedPoolNames:(oldClass sharedPoolNames).
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2365
			    oldClassCategory := oldClass category.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2366
			    newClass category ~= oldClassCategory ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2367
				newClass setCategory:oldClassCategory
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2368
			    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2369
			].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2370
			oldMethods := saveOldMethodsPerClass at:oldClass.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2371
			newMethodDict := newClass methodDictionary.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2372
			oldMethods keysAndValuesDo:[:selector :oldMethod|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2373
			    oldMethod
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2374
				code:nil;
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2375
				mclass:self.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2376
			    oldMethod byteCode isNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2377
				"a compiled method, load the new code (addresses may have been changed)"
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2378
				newMthd := newMethodDict at:selector ifAbsent:nil.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2379
				newMthd notNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2380
				     oldMethod code:newMthd code.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2381
				] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2382
				    ('ObjectFileLoader [warning]: ' , oldClass name , ' missing method: ', selector, '.') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2383
				].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2384
			    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2385
			].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2386
			newClass setMethodDictionary:oldMethods.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2387
		    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2388
		].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2389
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2390
		"/
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2391
		"/ validate old-classes vs. new classes.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2392
		"/ and if things look ok, get rid of old stuff
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2393
		"/ and make instances become instances of the new class
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2394
		"/
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2395
"/                ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR.
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2396
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2397
		savedOldClasses do:[:oldClass |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2398
		    |newClass oldCat oldCVars|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2399
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2400
		    newClass := Smalltalk classNamed:(oldClass name).
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2401
		    newClass == oldClass ifTrue:[
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2402
"/                        ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR.
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2403
		    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2404
			(newClass isNil or:[newClass == oldClass]) ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2405
			    ('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2406
			] ifFalse:[
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2407
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2408
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2409
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2410
			    oldClass instSize ~~ newClass instSize ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2411
				('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2412
			    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2413
				oldClass class instSize ~~ newClass class instSize ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2414
				    ('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2415
				] ifFalse:[
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2416
"/                                    ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR.
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2417
				    (oldCat := oldClass category) ~= newClass category ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2418
					newClass setCategory:oldCat.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2419
				    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2420
				    (oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2421
					newClass setClassVariableString:oldCVars
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2422
				    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2423
				    "/ copy over the oldClasses class-instVars
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2424
				    (Class instSize + 1) to:(oldClass class instSize) do:[:idx |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2425
					newClass instVarAt:idx put:(oldClass instVarAt:idx)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2426
				    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2427
				    oldClass becomeSameAs:newClass
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2428
"/                                    oldClass become:newClass
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2429
				]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2430
			    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2431
			]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2432
		    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2433
		]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2434
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2435
	    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2436
		handle isMethodHandle ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2437
		    oldDummyMethod := handle method.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2438
		    (oldDummyMethod isKindOf:Method) ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2439
			('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2440
		    ] ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2441
			('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2442
			who := oldDummyMethod who.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2443
			newHandle := self loadMethodObjectFile:fileName.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2444
			newHandle isNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2445
			    ('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2446
			    handle moduleID:nil.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2447
			] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2448
			    m := newHandle method.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2449
			    oldDummyMethod sourceFilename notNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2450
				m sourceFilename:(oldDummyMethod sourceFilename)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2451
				  position:(oldDummyMethod sourcePosition).
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2452
			    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2453
				m source:(oldDummyMethod source).
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2454
			    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2455
			    m setPackage:(oldDummyMethod package).
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2456
			    who notNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2457
				cls := who methodClass.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2458
				sel := who methodSelector.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2459
				m == (cls compiledMethodAt:sel) ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2460
				    'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2461
				] ifTrue:[
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2462
"/                                  cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod).
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2463
				]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2464
			    ].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2465
			]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2466
		    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2467
		] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2468
		    handle isFunctionObjectHandle ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2469
			functions := handle functions.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2470
			functions isEmpty ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2471
			    ('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2472
			] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2473
			    newHandle := self loadDynamicObject:fileName.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2474
			    newHandle isNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2475
				('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2476
				handle moduleID:nil.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2477
			    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2478
				('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2479
				functions do:[:eachFunction |  |addr|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2480
				    addr := newHandle getFunctionAddress:(eachFunction name) into:eachFunction.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2481
				    addr isNil ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2482
					('ObjectFileLoader [info]: function: ''' , eachFunction name , ''' no longer present.') errorPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2483
					eachFunction invalidate.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2484
				    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2485
					eachFunction setModuleHandle:newHandle.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2486
					('ObjectFileLoader [info]: rebound function: ''' , eachFunction name , '''.') infoPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2487
				    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2488
				].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2489
				handle becomeSameAs:newHandle.      "/ the old handle is now void
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2490
			    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2491
			]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2492
		    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2493
			('ObjectFileLoader [info]: ignore invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2494
		    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2495
		]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2496
	    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2497
	].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2498
	PreviouslyLoadedObjects := nil.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2499
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2500
	"/ now, as we hopefully have all loaded,
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2501
	"/ send #reinitializeAfterLoad to each of them
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2502
	anyModulesToInitialize ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2503
	    AbortOperationRequest catch:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2504
		self moduleInit:4 forceOld:false interruptable:true.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2505
	    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2506
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2507
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2508
2472
8ae818e74044 changed: #reloadAllRememberedObjectFiles
Claus Gittinger <cg@exept.de>
parents: 2459
diff changeset
  2509
    "Modified: / 18-01-2011 / 20:42:57 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2510
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2511
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2512
rememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2513
    "remember all loaded objectModules in the
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  2514
     PreviouslyLoadedObjects classVariable.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2515
     Called when an image is restarted to reload all modules which
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2516
     were loaded in the previous life"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2517
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2518
    LoadedObjects notNil ifTrue:[
2919
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2519
	PreviouslyLoadedObjects := OrderedCollection new.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2520
	LoadedObjects keysAndValuesDo:[:name :handle |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2521
	    handle isObsolete ifTrue:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2522
		('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2523
	    ] ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2524
		PreviouslyLoadedObjects add:(name -> handle)
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2525
	    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2526
	].
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2527
	PreviouslyLoadedObjects sort:[:a :b |
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2528
		|h1 h2|
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2529
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2530
		h1 := a value moduleID.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2531
		h2 := b value moduleID.
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2532
		h1 isNil
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2533
		    ifTrue:[true]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2534
		    ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2535
			h2 isNil
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2536
			    ifTrue:[false]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2537
			    ifFalse:[
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2538
				h1 < h2
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2539
			    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2540
		    ]
0e10cd134388 compilability
Claus Gittinger <cg@exept.de>
parents: 2885
diff changeset
  2541
	].
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2542
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2543
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2544
    "Created: 5.12.1995 / 20:51:07 / cg"
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2545
    "Modified: 10.1.1997 / 15:06:25 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2546
!
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
revalidateAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2549
    "revalidate code refs into all dynamically loaded object files.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2550
     Required after writing a snapshot image."
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
    ActuallyLoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2553
	ActuallyLoadedObjects keys do:[:aFileName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2554
	    |handle|
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2555
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2556
	    handle := ActuallyLoadedObjects at:aFileName.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2557
	    handle isNil ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2558
		self error:'oops, no handle'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2559
	    ] ifFalse:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2560
		(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2561
		    self revalidateModule:handle
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2562
		]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2563
	    ]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2564
	].
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2565
	LoadedObjects := ActuallyLoadedObjects.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2566
	ActuallyLoadedObjects := PreviouslyLoadedObjects := nil.
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2567
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2568
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2569
    "Created: 5.10.1995 / 15:49:08 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2570
    "Modified: 5.10.1995 / 16:49:18 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2571
    "Modified: 12.7.1996 / 17:14:48 / cg"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2572
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2573
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2574
unloadAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2575
    "unload all dynamically loaded object files from the image.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2576
     see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:"
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
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2579
	LoadedObjects values copy do:[:eachHandle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2580
	    eachHandle notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2581
		self unloadDynamicObject:eachHandle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2582
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  2583
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2584
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2585
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2586
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2587
     ObjectFileLoader unloadAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2588
    "
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
unloadAndRememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2592
    "remember all modules and unload them"
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
    LoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2595
	self rememberAllObjectFiles.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2596
	self unloadAllObjectFiles
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2597
    ]
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
    "Modified: 25.4.1996 / 09:46:27 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2600
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2601
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  2602
!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
  2603
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2604
createLoadableObjectFor:baseFileName
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2605
    "given an oFile, arrange for it to be loadable.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2606
     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
  2607
     -shared option into a .so file;
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2608
     DLD based loaders (linux a.out) can directly load a .o file;
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2609
     Other systems may require more ..."
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2610
513
445a382e8c65 Ultrix support.
Stefan Vogel <sv@exept.de>
parents: 504
diff changeset
  2611
    |osType oFileName soFileName expFileName librunExpFileName
2806
a49002898137 changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2802
diff changeset
  2612
     needSharedObject ld ldArg expFile ok outfile output libDir libDirBasename|
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2613
750
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2614
    osType := OperatingSystem getOSType.
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2615
2025
00f8564566e8 No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents: 2012
diff changeset
  2616
    osType = #win32 ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2617
        self activityNotification:'generating shared object'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2618
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2619
        ParserFlags linkArgs isNil ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2620
            ld := self linkCommand , ' ' , baseFileName , '.obj'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2621
            ld := ld
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2622
               , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2623
               , ' /OUT:' , baseFileName , '.dll '
2025
00f8564566e8 No need for a .def-file in win32 any longer
Stefan Vogel <sv@exept.de>
parents: 2012
diff changeset
  2624
"/               , ' /DEF:' , baseFileName , '.def'.
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2625
        ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2626
"/            libDir := ParserFlags libDirectory.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2627
"/            (libDir notNil and:[libDir asFilename exists]) ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2628
                ParserFlags useBorlandC ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2629
                    libDirBasename := 'lib\bc'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2630
                ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2631
                    ParserFlags useVisualC ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2632
                        libDirBasename := 'lib\vc'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2633
                    ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2634
                        (ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2635
                            libDirBasename := 'lib\mingw'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2636
                        ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2637
                            libDirBasename := 'lib\vc' 
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2638
                        ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2639
                    ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2640
                ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2641
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2642
                libDir := '..\',libDirBasename.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2643
                libDir asFilename exists ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2644
                    libDir := '..\lib\',libDirBasename.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2645
                    libDir asFilename exists ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2646
                        libDir := '..\lib'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2647
                        libDir asFilename exists ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2648
                            libDir := '..\..\',libDirBasename.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2649
                            libDir asFilename exists ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2650
                                ObjectFileLoadError raiseRequestErrorString:'could not locate directory where .lib files are'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2651
                                LastError := 'could not locate directory where .lib files are'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2652
                                ^ nil
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2653
                            ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2654
                        ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2655
                    ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2656
                ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2657
"/            ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2658
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2659
            ParserFlags useBorlandC ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2660
                ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2661
                ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2662
                ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2663
                ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2664
                ld := ld , ' ',libDir,'\cs32i.lib,,'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2665
            ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2666
                ParserFlags useVisualC ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2667
                    "/ todo: fix for correct link libs
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2668
                    ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2669
                    ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2670
                    ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2671
                    ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2672
                    ld := ld , ' ',libDir,'\cs32i.lib,,'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2673
                ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2674
                    (ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2675
                        ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2676
                        ld := ld , ' -shared -o ',baseFileName,'.dll '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2677
                        ld := ld , baseFileName,'.obj '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2678
                        ld := ld , libDir,'\librun.lib '.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2679
                        ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2680
                    ] ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2681
                        ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2682
                        LastError := 'for dynamic objects, only borlandC is (currently) supported'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2683
                        ^ nil
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2684
                    ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2685
                ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2686
            ]
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2687
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2688
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2689
        outfile := (baseFileName , '.out').
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2690
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2691
        ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2692
        ok ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2693
            output := (baseFileName , '.out') asFilename contentsOfEntireFile.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2694
            Transcript showCR:output; endEntry.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2695
            Transcript showCR:'Failed linkCommand:'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2696
            Transcript showCR:ld.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2697
            Transcript showCR:'ParserFlags are:'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2698
            Transcript showCR:ParserFlags.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2699
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2700
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2701
        #('.obj' '.out' '.tds' '.ilc' '.ild'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2702
          '.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix|
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2703
            (baseFileName , eachSuffix) asFilename delete.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2704
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2705
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2706
        ok ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2707
            LastError := output.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2708
            "/ ObjectFileLoadError raiseRequestErrorString:'link failed'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2709
            ^ nil
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2710
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2711
        oFileName := (baseFileName , self sharedLibraryExtension) asFilename name.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2712
        ^ oFileName
750
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2713
    ].
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2714
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2715
    "/ UNIX systems
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2716
2653
e228edb0b67a changed: #createLoadableObjectFor:
Stefan Vogel <sv@exept.de>
parents: 2651
diff changeset
  2717
    ld := self linkCommand ? 'ld'.
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
  2718
    needSharedObject := false.
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2719
1287
d1199118e73d sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2720
    ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2721
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2722
         link it to a shared object with 'ld -shared'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2723
         Currently, we support 32-bit objects only.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2724
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2725
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2726
        ld := self linkCommand ? 'cc'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2727
        ldArg := self linkSharedArgs ? '-m32 -shared'.
1287
d1199118e73d sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2728
    ].
d1199118e73d sharedLib loading (esp. freeBSD)
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
  2729
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2730
    osType = #irix ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2731
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2732
         link it to a shared object with 'ld -shared'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2733
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2734
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2735
        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
  2736
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2737
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2738
    osType = #'sys5_4' ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2739
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2740
         link it to a shared object with 'ld -G'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2741
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2742
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2743
        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
  2744
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2745
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2746
    osType = #osf ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2747
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2748
         link it to a shared object with 'ld -shared'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2749
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2750
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2751
        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
  2752
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2753
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2754
    osType = #solaris ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2755
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2756
         link it to a shared object with 'ld -G -B dynamic'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2757
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2758
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2759
        ldArg := self linkSharedArgs ? '-G -Bdynamic'.
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2760
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2761
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2762
    osType = #hpux ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2763
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2764
         link it to a shared object with 'ld -b -B immediate'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2765
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2766
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2767
        ldArg := self linkSharedArgs ? '-b -B immediate'.
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2768
    ].
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2769
2935
6b6e5c7fd093 use symbols for ostype
Stefan Vogel <sv@exept.de>
parents: 2933
diff changeset
  2770
    osType = #aix ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2771
        self activityNotification:'create export file'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2772
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2773
        "/ create an exports file.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2774
        expFileName := './' , baseFileName , '.exp'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2775
        [
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2776
            expFile := expFileName asFilename writeStream.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2777
            expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2778
            expFile cr.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2779
            expFile nextPutAll:'_' , baseFileName , '_Init'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2780
            expFile close.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2781
        ] on:FileStream openErrorSignal do:[:ex| "do nothing"].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2782
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2783
        self activityNotification:'generating shared object'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2784
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2785
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2786
         link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE'
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2787
        "
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2788
        needSharedObject := true.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2789
        ld := 'cc'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2790
        librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2791
        librunExpFileName isNil ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2792
            LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2793
            ^ nil
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2794
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2795
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2796
        ldArg := '-bI:' , librunExpFileName ,
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2797
                ' -bE:' , baseFileName , '.exp' ,
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2798
                ' -bM:SRE -e _' , baseFileName , '_Init'.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2799
    ].
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2800
2648
2d046cf8c90e changed: #createLoadableObjectFor:
Stefan Vogel <sv@exept.de>
parents: 2627
diff changeset
  2801
    oFileName := baseFileName , self objectFileExtension.
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2802
    needSharedObject ifTrue:[
3011
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2803
        self activityNotification:'generating shared object'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2804
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2805
        soFileName := baseFileName , self sharedLibraryExtension.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2806
        OperatingSystem removeFile:soFileName.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2807
        ld := ld , ' ' , ldArg , ' ', (ParserFlags linkArgs ? '') ,
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2808
                 ' -o ' , soFileName , ' ' , oFileName , ' ',
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2809
                 ((ParserFlags searchedLibraries  ? #()) asStringCollection asStringWith: $ ).
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2810
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2811
        Verbose ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2812
            'linking with:' errorPrintCR.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2813
            '   ' errorPrint. ld errorPrintCR.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2814
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2815
        ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1').
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2816
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2817
        ok ifFalse:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2818
            output := 'errorOutput' asFilename contentsOfEntireFile.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2819
            Transcript showCR:'linker error message:'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2820
            Transcript showCR:output.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2821
            Transcript showCR:'linker command:'.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2822
            Transcript showCR:ld; endEntry.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2823
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2824
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2825
        OperatingSystem removeFile:oFileName.
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2826
        expFileName notNil ifTrue:[
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2827
            OperatingSystem removeFile:expFileName
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2828
        ].
45a1c18607b6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3008
diff changeset
  2829
        ^ soFileName.
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2830
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2831
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2832
    "
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2833
     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
  2834
    "
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2835
    ^ oFileName
698
fc359ff36687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  2836
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  2837
    "Modified: / 29-07-2004 / 17:29:44 / stefan"
2932
d61b51867682 changed: #createLoadableObjectFor:
Claus Gittinger <cg@exept.de>
parents: 2931
diff changeset
  2838
    "Modified: / 28-09-2012 / 18:00:13 / cg"
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2839
! !
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2840
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2841
!ObjectFileLoader class methodsFor:'lowlevel object loading'!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2842
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2843
initializeLoader
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2844
    "initialize dynamic loader if required"
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  2845
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2846
    |stxName stxPathName|
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2847
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2848
    stxPathName := OperatingSystem pathOfSTXExecutable.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2849
%{
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2850
#ifdef GNU_DL
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2851
  {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2852
    static alreadyInitialized = 0;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2853
    extern dld_ignore_redefinitions;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2854
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2855
    if (! alreadyInitialized) {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2856
	alreadyInitialized = 1;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2857
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2858
	if (@global(Verbose) == true) {
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  2859
	    console_printf ("dld_init(%s)\n", __stringVal(stxPathName));
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2860
	}
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2861
	/*
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2862
	 * dld requires the running executables name,
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2863
	 * to resolve symbols.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2864
	 */
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2865
	(void) dld_init (__stringVal(stxPathName));
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2866
	dld_ignore_redefinitions = 1;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2867
    }
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2868
  }
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2869
#endif
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2870
%}.
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
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  2873
loadDynamicObject:pathNameOrFilename
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2874
    "load an object-file (load/map into my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2875
     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
  2876
     No bindings or automatic initializations are done
472
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2877
     - only a pure (low-level) load is performed.
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2878
     For class-files or C-objects to be loaded with this method,
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2879
     it is your responsibility to fetch any init-functions and
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2880
     call them as appropriate.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2881
     This function is not supported on all architectures.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2882
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2883
2989
db2cf648131c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2982
diff changeset
  2884
    |fn handle buffer pathName tempFile encodedPathName|
2982
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
  2885
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
  2886
    fn := pathNameOrFilename asFilename.
e8da03e62efb class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 2935
diff changeset
  2887
    fn exists ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2888
	pathName := fn pathName.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2889
	self copyLibrariesWhenLoading ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2890
	    fn copyTo:(tempFile := ParserFlags stcModulePath asFilename construct:fn baseName).
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2891
	    pathName := tempFile pathName.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2892
	].
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  2893
    ] ifFalse:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2894
	"/ something like "kernel32.dll"; must be along the PATH setting
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2895
	pathName := pathNameOrFilename asString.
2746
9980d2b9b42c fixes to load kernel32.dll under vc-compiled
Claus Gittinger <cg@exept.de>
parents: 2745
diff changeset
  2896
    ].
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2897
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2898
    Verbose ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2899
	('loadDynamic: ',pathNameOrFilename asString,' (',pathName asString,')...') errorPrintCR
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2900
    ].
2989
db2cf648131c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2982
diff changeset
  2901
    encodedPathName := OperatingSystem encodePath:pathName.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2902
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2903
    "/ already loaded ?
2989
db2cf648131c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2982
diff changeset
  2904
    handle := self handleForDynamicObject:encodedPathName.
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
  2905
    handle notNil ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2906
	Verbose ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2907
	    ('... ' , pathName , ' already loaded.') errorPrintCR.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2908
	].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2909
	^ handle
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2910
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2911
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2912
    Verbose ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2913
	('initializeLoader...') errorPrintCR
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2914
    ].
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
  2915
    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
  2916
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2917
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2918
    "/ the 1st two entries are system dependent;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2919
    "/ entry 3 is the pathName
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2920
    "/ entry 4 is a unique ID
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2921
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2922
    buffer := Array new:4.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2923
    buffer at:3 put:pathName.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2924
    buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2925
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2926
    Verbose ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2927
	('primLoadDynamicObject...') errorPrintCR
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2928
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2929
2989
db2cf648131c class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2982
diff changeset
  2930
    buffer := self primLoadDynamicObject:encodedPathName into:buffer.
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2931
    Verbose ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2932
	('done') errorPrintCR
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2933
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2934
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2935
    buffer isNil ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2936
	LastError == #notImplemented ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2937
	    'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2938
	] ifFalse:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2939
	    LastError == #linkError ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2940
		LinkErrorMessage notNil ifTrue:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2941
		    ('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2942
		] ifFalse:[
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2943
		    ('ObjectFileLoader [warning]: load error') infoPrintCR.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2944
		].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2945
	    ].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2946
	].
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2947
	('ObjectFileLoader [warning]: failed to load: ' , pathName) infoPrintCR.
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2948
	Transcript showCR:('ObjectFileLoader [warning]: failed to load: ' , pathName).
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2949
	^ nil
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2950
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2951
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2952
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2953
     remember loaded object for later unloading
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2954
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2955
    handle := ObjectFileHandle new.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2956
    handle sysHandle1:(buffer at:1).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2957
    handle sysHandle2:(buffer at:2).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2958
    handle pathName:(buffer at:3).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2959
    handle moduleID:(buffer at:4).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2960
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2961
    LoadedObjects isNil ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2962
	LoadedObjects := Dictionary new.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2963
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2964
    LoadedObjects at:pathName put:handle.
1904
71c41110a83a flush cache when init function was called (not when the dll was loaded)
Michael Beyl <mb@exept.de>
parents: 1903
diff changeset
  2965
    "/ Smalltalk flushCachedClasses.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2966
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2967
    Verbose ifTrue:[
2993
823a9a40f04c changes for mingw
Claus Gittinger <cg@exept.de>
parents: 2992
diff changeset
  2968
	('loadDynamic ok; handle is: ' , handle printString) errorPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2969
    ].
2767
12da7f27dcce changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents: 2746
diff changeset
  2970
    "/ ObjectMemory garbageCollect.
470
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
    ^ handle
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
    "sys5.4:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2975
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2976
     handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2977
     ObjectFileLoader getFunction:'module1' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2978
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2979
    "next:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2980
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2981
     handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2982
     ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2983
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2984
    "GLD:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2985
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2986
     handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2987
     ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2988
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2989
2767
12da7f27dcce changed: #loadDynamicObject:
Claus Gittinger <cg@exept.de>
parents: 2746
diff changeset
  2990
    "Modified: / 06-12-2011 / 15:42:16 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2991
!
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
loadModulesFromListOfUndefined:list
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2994
    "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
  2995
     return a list of handles of loaded objects
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2996
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2997
    |inits classNames|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2998
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2999
    inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3000
    inits notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3001
	classNames := inits collect:[:symbol |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3002
	    (symbol startsWith:'___') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3003
		symbol copyFrom:4 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3004
	    ] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3005
		(symbol startsWith:'__') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3006
		    symbol copyFrom:3 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3007
		] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3008
		    (symbol startsWith:'_') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3009
			symbol copyFrom:2 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3010
		    ] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3011
			symbol
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3012
		    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3013
		]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3014
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3015
	].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3016
	"
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3017
	 autoload those classes
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3018
	"
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3019
	classNames do:[:aClassName |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3020
	    |cls|
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3021
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3022
	    (cls := Smalltalk classNamed:aClassName) notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3023
		'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3024
		cls autoload
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3025
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3026
	]
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3027
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3028
    ^ nil
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3029
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3030
    "Modified: 10.1.1997 / 17:58:23 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3031
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3032
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3033
primLoadDynamicObject:pathName into:anInfoBuffer
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3034
    "load an object-file (map into my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3035
     Return an OS-handle (whatever that is) - where some space
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3036
     (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
  3037
     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
  3038
     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
  3039
     (instead, only pass around handles transparently).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3040
     This function is not supported on all architectures."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3041
1760
09a5b2b97f29 WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents: 1759
diff changeset
  3042
%{  /* CALLSUNLIMITEDSTACK(noWIN32) */
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3043
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3044
    if (! __isArray(anInfoBuffer)
646
02b5ea95f888 eliminated some single-underscore macro refs (stringSize, arraySize ...)
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
  3045
     || (__arraySize(anInfoBuffer) < 3)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3046
        RETURN(nil);
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
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3049
#ifdef GNU_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3050
  {
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3051
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3052
        if (dld_link(__stringVal(pathName))) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3053
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3054
                console_printf ("link file %s failed\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3055
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3056
            if (@global(ErrorPrinting) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3057
                dld_perror("ObjectFileLoader - DLD error cant link");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3058
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3059
            @global(LastError) = @symbol(linkError);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3060
            @global(LinkErrorMessage) = __MKSTRING("DLD error");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3061
            RETURN ( nil );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3062
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3063
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3064
        __STORE(anInfoBuffer, pathName);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3065
        RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3066
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3067
    RETURN ( nil );
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
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3070
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3071
#ifdef WIN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3072
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3073
    HINSTANCE handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3074
    int err;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3075
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3076
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3077
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3078
            console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3079
            console_fflush(stderr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3080
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3081
        //
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3082
        // LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3083
        // in the directory of the loaded library, if an absolute path to
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3084
        // the library has been provided.
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3085
        // Note: this does not work for redirected library symbols, since they are
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3086
        //       resolved ad symbol lookup time and not at library load time
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3087
        //
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3088
        handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3089
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3090
            console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3091
            console_fflush(stderr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3092
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3093
        if (handle == NULL) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3094
            char *msg;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3095
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3096
            err = GetLastError();
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3097
            if ((@global(ErrorPrinting) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3098
             || (@global(Verbose) == true)) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3099
                console_fprintf (stderr,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3100
                                 "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3101
                                 __stringVal(pathName), err);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3102
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3103
            @global(LastError) = @symbol(loadError);;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3104
            @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3105
            switch (err) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3106
                case ERROR_BAD_FORMAT:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3107
                    msg = "LoadLibrary error - bad format";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3108
                default:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3109
                    msg = "LoadLibrary error";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3110
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3111
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3112
            @global(LinkErrorMessage) = __MKSTRING(msg);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3113
            RETURN ( nil );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3114
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3115
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3116
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3117
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3118
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3119
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3120
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3121
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3122
        RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3123
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3124
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3125
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3126
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3127
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3128
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3129
  {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3130
    void *handle;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3131
    int err;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3132
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3133
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3134
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3135
            console_fprintf(stderr, "ObjectFileLoader [info]: loading : %s...\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3136
            console_fflush(stderr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3137
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3138
        handle = load_add_on(__stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3139
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3140
            console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3141
            console_fflush(stderr);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3142
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3143
        if (handle == NULL) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3144
            char *msg;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3145
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3146
            @global(LastError) = @symbol(linkError);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3147
            @global(LinkErrorMessage) = __MKSTRING("unknown error");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3148
            RETURN ( nil );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3149
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3150
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3151
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3152
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3153
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3154
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3155
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3156
        RETURN ( anInfoBuffer );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3157
# endif
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3158
    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3159
    RETURN ( nil );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3160
  }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3161
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3162
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3163
#ifdef DL1_6
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3164
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3165
    extern char *__myName__;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3166
    char *ldname;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3167
    OBJ tmpName;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3168
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3169
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3170
        if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3171
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3172
                console_printf ("link file %s failed\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3173
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3174
            @global(LinkErrorMessage) = __MKSTRING("dl_load error");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3175
            RETURN ( nil );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3176
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3177
        /*
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3178
         * returns the name of the temporary ld-file
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3179
         * use that as handle ...
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3180
         */
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3181
        tmpName = __MKSTRING(ldname);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3182
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3183
        __STORE(anInfoBuffer, tmpName);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3184
        RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3185
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3186
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3187
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3188
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3189
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3190
#ifdef AIX_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3191
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3192
    char *objName, *libPath;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3193
    int *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3194
    extern errno;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3195
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3196
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3197
        objName = __stringVal(pathName);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3198
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3199
        if (__isStringLike(@global(LibPath))) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3200
            libPath = __stringVal(@global(LibPath));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3201
        } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3202
            libPath = (char *)0;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3203
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3204
        if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3205
            if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3206
                char *messages[64];
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3207
                int i;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3208
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3209
                console_fprintf (stderr,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3210
                         "ObjectFileLoader [info]: load file %s failed errno=%d\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3211
                         objName, errno);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3212
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3213
                switch (errno) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3214
                    case ENOEXEC:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3215
                        console_fprintf(stderr, "   load messages:\n");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3216
                        loadquery(L_GETMESSAGES, messages, sizeof(messages));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3217
                        for (i=0; messages[i]; i++) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3218
                            console_fprintf(stderr, "      %s\n", messages[i]);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3219
                        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3220
                        break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3221
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3222
            } else {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3223
                if (@global(ErrorPrinting) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3224
                    console_fprintf (stderr,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3225
                             "ObjectFileLoader [warning]: load file %s failed errno=%d\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3226
                             objName, errno);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3227
                }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3228
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3229
            @global(LinkErrorMessage) = __MKSTRING("load error");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3230
            RETURN ( nil );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3231
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3232
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3233
            console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3234
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3235
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3236
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3237
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3238
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3239
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3240
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3241
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3242
# endif
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3243
        RETURN (anInfoBuffer);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3244
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3245
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3246
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3247
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3248
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3249
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3250
#ifdef SYSV4_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3251
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3252
    void *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3253
    char *nm;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3254
    char *errMsg;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3255
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3256
    if ((pathName == nil) || __isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3257
        INT lowHandle, hiHandle;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3258
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3259
        handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3260
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3261
        if (! handle) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3262
            errMsg = (char *) dlerror();
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3263
            if (@global(ErrorPrinting) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3264
                console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3265
                console_fprintf(stderr, "    <%s>\n", errMsg);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3266
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3267
            @global(LastError) = @symbol(linkError);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3268
            @global(LinkErrorMessage) = __MKSTRING(errMsg);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3269
            RETURN (nil);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3270
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3271
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3272
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3273
            console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3274
        }
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3275
1607
074a99bb9a50 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 1602
diff changeset
  3276
#if __POINTER_SIZE__ == 8
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3277
        lowHandle = (INT)handle & 0xFFFFFFFFL;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3278
        hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3279
#else
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3280
        lowHandle = (INT)handle & 0xFFFF;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3281
        hiHandle = ((INT)handle >> 16) & 0xFFFF;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3282
#endif
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3283
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3284
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3285
        RETURN (anInfoBuffer);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3286
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3287
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3288
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3289
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3290
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3291
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3292
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3293
    void *handle;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3294
    char *nm;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3295
    char *errMsg;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3296
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3297
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3298
        handle = (void *)shl_load(__stringVal(pathName),
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3299
                                  BIND_IMMEDIATE, 0L /* address */);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3300
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3301
        if (! handle) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3302
            if (@global(ErrorPrinting) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3303
                console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3304
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3305
            @global(LastError) = @symbol(linkError);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3306
            switch (errno) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3307
                case ENOEXEC:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3308
                    errMsg = "not a shared library";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3309
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3310
                case ENOSYM:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3311
                    errMsg = "undefined symbols";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3312
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3313
                case ENOMEM:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3314
                    errMsg = "out of memory";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3315
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3316
                case ENOENT:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3317
                    errMsg = "non existing library";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3318
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3319
                case EACCES:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3320
                    errMsg = "permission denied";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3321
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3322
                default:
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3323
                    errMsg = "unspecified error";
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3324
                    break;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3325
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3326
            @global(LinkErrorMessage) = __MKSTRING(errMsg);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3327
            RETURN (nil);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3328
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3329
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3330
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3331
            console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3332
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3333
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3334
# if __POINTER_SIZE__ == 8
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3335
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3336
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3337
# else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3338
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3339
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3340
        RETURN (anInfoBuffer);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3341
# endif
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3342
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3343
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3344
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3345
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3346
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3347
#ifdef SUN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3348
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3349
    void *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3350
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3351
    if ((pathName == nil) || __isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3352
        if (pathName == nil)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3353
            handle = dlopen((char *)0, 1);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3354
        else
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3355
            handle = dlopen(__stringVal(pathName), 1);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3356
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3357
        if (! handle) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3358
            if (@global(ErrorPrinting) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3359
                console_fprintf(stderr, "dlopen %s error: <%s>\n",
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3360
                                __stringVal(pathName), dlerror());
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3361
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3362
            @global(LastError) = @symbol(linkError);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3363
            @global(LinkErrorMessage) = __MKSTRING("dlopen error");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3364
            RETURN (nil);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3365
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3366
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3367
        if (@global(Verbose) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3368
            console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3369
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3370
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3371
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3372
        __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3373
        RETURN (anInfoBuffer);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3374
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3375
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3376
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3377
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3378
#ifdef NEXT_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3379
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3380
    long result;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3381
    char *files[2];
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3382
    NXStream *errOut;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3383
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3384
    if (__isStringLike(pathName)) {
3001
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3385
        files[0] = (char *) __stringVal(pathName);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3386
        files[1] = (char *) 0;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3387
        errOut = NXOpenFile(2, 2);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3388
        result = rld_load(errOut,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3389
                          (struct mach_header **)0,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3390
                          files,
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3391
                          (char *)0);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3392
        NXClose(errOut);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3393
        if (! result) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3394
            @global(LinkErrorMessage) = __MKSTRING("rld_load error");
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3395
            @global(LastError) = @symbol(linkError);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3396
            if (@global(ErrorPrinting) == true) {
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3397
                console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3398
            }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3399
            RETURN (nil);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3400
        }
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3401
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3402
        if (@global(Verbose) == true)
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3403
            console_printf("rld_load %s ok\n", __stringVal(pathName));
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3404
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3405
        __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3406
        __STORE(anInfoBuffer, pathName);
765cab3138d9 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3000
diff changeset
  3407
        RETURN ( anInfoBuffer );
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3408
    }
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
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3411
%}.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3412
    LastError := #notImplemented.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3413
    ^ nil
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3414
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3415
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3416
primUnloadDynamicObject:aHandle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3417
    "unload an object-file (unmap from my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3418
     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
  3419
     still any code references (from blocks or methods) to this
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3420
     module. Calling it for still living classes will definitely
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3421
     lead to some fatal conditions to occur later."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3422
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3423
    |sysHandle1 sysHandle2|
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
    sysHandle1 := aHandle sysHandle1.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3426
    sysHandle2 := aHandle sysHandle2.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3427
1760
09a5b2b97f29 WindCVS: ----------------------------------------------------------------------
Stefan Vogel <sv@exept.de>
parents: 1759
diff changeset
  3428
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3429
#ifdef GNU_DL
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  3430
    if (__isStringLike(sysHandle1)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3431
	if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3432
	    if (@global(Verbose) == true) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3433
		console_printf ("unlink file %s failed\n", __stringVal(sysHandle1));
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3434
		dld_perror("cant unlink");
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3435
	    }
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3436
	    RETURN (false);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3437
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3438
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3439
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3440
    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3441
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3442
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3443
#ifdef WIN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3444
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3445
    HINSTANCE handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3446
    int err;
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3447
    jmp_buf exitJmpBuf;
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3448
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3449
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3450
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3451
	handle = (HINSTANCE)(val);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3452
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3453
       if (setjmp(exitJmpBuf)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3454
	   __setAtExitLongJmp(exitJmpBuf);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3455
	    if (FreeLibrary(handle) != TRUE) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3456
	       __setAtExitLongJmp(0);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3457
		err = GetLastError();
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3458
		if (@global(Verbose) == true) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3459
		    console_fprintf (stderr,
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3460
				     "ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n",
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3461
				     __stringVal(sysHandle1), err);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3462
		}
2923
10853691e2f2 oops - missing MKINT (may lead to crash in GC after unloading objects)
Claus Gittinger <cg@exept.de>
parents: 2920
diff changeset
  3463
		@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3464
		RETURN (false);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3465
	    }
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3466
       } else {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3467
	   __setAtExitLongJmp(0);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3468
	   console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3469
       }
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3470
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3471
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3472
    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3473
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3474
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3475
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3476
    int val;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3477
    void *handle;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3478
    int ok, err;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3479
    jmp_buf exitJmpBuf;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3480
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3481
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3482
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3483
	handle = (HINSTANCE)(val);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3484
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3485
	if (setjmp(exitJmpBuf)) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3486
	    __setAtExitLongJmp(exitJmpBuf);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3487
	    ok = unload_add_on((image_id) handle);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3488
	    __setAtExitLongJmp(0);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3489
	    if (ok != 0) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3490
		@global(LastErrorNumber) = __MKSMALLINT(ok);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3491
		RETURN (false);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3492
	    }
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3493
	} else {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3494
	    __setAtExitLongJmp(0);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3495
	    console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3496
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3497
	RETURN (true);
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3498
    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3499
    RETURN (false);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3500
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3501
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3502
#ifdef SYSV4_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3503
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3504
    void *h;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3505
    INT val;
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3506
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3507
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3508
    if (__bothSmallInteger(low, hi)) {
1607
074a99bb9a50 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 1602
diff changeset
  3509
#if __POINTER_SIZE__ == 8
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3510
	val = (__intVal(hi) << 32) + __intVal(low);
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3511
#else
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3512
	val = (_intVal(hi) << 16) + _intVal(low);
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3513
#endif
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3514
	h = (void *)(val);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3515
	if (@global(Verbose) == true)
2998
77b656fda010 osx/64bit fixes
Claus Gittinger <cg@exept.de>
parents: 2993
diff changeset
  3516
	    console_printf("close handle = %"_lx_"\n", (INT)h);
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3517
	if (dlclose(h) != 0) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3518
	    console_fprintf(stderr, "dlclose failed with:<%s>\n", dlerror());
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3519
	    RETURN (false);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3520
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3521
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3522
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3523
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3524
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3525
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3526
#ifdef SUN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3527
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3528
    void *h;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3529
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3530
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3531
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3532
    if (__bothSmallInteger(low, hi)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3533
	val = (_intVal(hi) << 16) + _intVal(low);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3534
	h = (void *)(val);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3535
	if (@global(Verbose) == true) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3536
	    console_printf("close handle = %x\n", h);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3537
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3538
	dlclose(h);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3539
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3540
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3541
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3542
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3543
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3544
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3545
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3546
    int *h;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3547
    int val;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3548
    OBJ low = sysHandle1, hi = sysHandle2;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3549
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3550
    if (__bothSmallInteger(low, hi)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3551
	val = (_intVal(hi) << 16) + _intVal(low);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3552
	h = (void *)(val);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3553
	if (@global(Verbose) == true) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3554
	    console_printf("unload handle = %x\n", h);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3555
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3556
	shl_unload(h);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3557
	RETURN (true);
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3558
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3559
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3560
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3561
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3562
#ifdef AIX_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3563
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3564
    int *h;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3565
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3566
    OBJ low = sysHandle1, hi = sysHandle2;
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
    if (__bothSmallInteger(low, hi)) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3569
	val = (_intVal(hi) << 16) + _intVal(low);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3570
	h = (int *)(val);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3571
	if (@global(Verbose) == true) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3572
	    console_printf("unload handle = %x\n", h);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3573
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3574
	if ( unload(h) != 0) {
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3575
	    console_fprintf(stderr, "unload failed\n");
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3576
	    RETURN (false);
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3577
	}
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3578
	RETURN (true);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3579
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3580
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3581
#endif
529
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3582
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3583
#ifdef NEXT_DL
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3584
  {
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  3585
    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
  3586
  }
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3587
#endif
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3588
%}.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3589
    ^ false
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3590
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3591
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3592
unloadDynamicObject:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3593
    "close an object-file (unmap from my address space)
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3594
     and remove the entry from the remembered object file set.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3595
     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
  3596
     still any code references (from blocks or methods) to this
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3597
     module. Calling it for still living classes will definitely
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3598
     lead to some fatal conditions to occur later."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3599
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3600
    |key fileName functionName deInitAddr m|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3601
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3602
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3603
	'unload module name=' errorPrint. handle pathName errorPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3604
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3605
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3606
    handle isUnknownHandle ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3607
	Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3608
	    'module type is not known - assume uninitialized classLib' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3609
	].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3610
	self unregisterModule:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3611
	handle makeClassLibHandle.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3612
    ] ifFalse:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3613
	handle isClassLibHandle ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3614
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3615
		'a classLib - deinit classes' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3616
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3617
	    self deinitializeClassesFromModule:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3618
	    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3619
		'unregister' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3620
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3621
	    self unregisterModule:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3622
	] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3623
	    handle isMethodHandle ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3624
		Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3625
		    'a methodHandle - unregister' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3626
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3627
		self unregisterModule:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3628
	    ] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3629
		handle isFunctionObjectHandle ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3630
		    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3631
			'a functionObject - fixup functionRefs' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3632
		    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3633
		    handle functions do:[:f |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3634
				    f notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3635
					f invalidate
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3636
				    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3637
				].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3638
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3639
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3640
		"/
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3641
		"/ call its deInit function (if present)
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3642
		"/
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3643
		Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3644
		    'search for deInit function...' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3645
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3646
		fileName := handle pathName asFilename baseName.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3647
		functionName := self initFunctionBasenameForFile:fileName.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3648
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3649
		deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3650
		deInitAddr notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3651
		    Verbose ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3652
			'invoke deInit function...' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3653
		    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3654
		    self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3655
			saveCallInitFunctionAt:deInitAddr
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3656
			in:fileName
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3657
			specialInit:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3658
			forceOld:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3659
			interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3660
			argument:0
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3661
			identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3662
			returnsObject:false.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3663
		]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3664
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3665
	].
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3666
    ].
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3667
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3668
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3669
	'cleanup done - now unload...' errorPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3670
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3671
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3672
^ self.
470
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
    "/ now, really unload
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3675
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3676
    (self primUnloadDynamicObject:handle) ifFalse:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3677
	^ self error:'unloadDynamic failed' mayProceed:true
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3678
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3679
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3680
    Verbose ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3681
	'unload done ...' errorPrintCR.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3682
    ].
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3683
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3684
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3685
    "/ remove from loaded objects
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3686
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3687
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3688
	key := LoadedObjects keyAtEqualValue:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3689
	key notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3690
	    LoadedObjects removeKey:key
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3691
	]
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3692
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3693
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3694
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3695
     for individual methods, we keep the methodObject,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3696
     but make it unexecutable. Its still visible in the browser.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3697
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3698
    handle isMethodHandle ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3699
	((m := handle method) notNil
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3700
	and:[m ~~ 0]) ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3701
	    m makeUnloaded.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3702
	]
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3703
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3704
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3705
    handle isClassLibHandle ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3706
	Smalltalk flushCachedClasses.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3707
	Class flushSubclassInfo.
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3708
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3709
    handle isMethodHandle ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3710
	ObjectMemory flushCaches.
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3711
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3712
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3713
    handle moduleID:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3714
    handle sysHandle1:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3715
    handle sysHandle2:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3716
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  3717
    "Modified: / 15-11-2010 / 13:20:20 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3718
! !
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3719
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  3720
!ObjectFileLoader class methodsFor:'queries'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3721
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3722
canLoadObjectFiles
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  3723
    "return true, if dynamic loading is possible.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3724
     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
  3725
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3726
    self primCanLoadObjectFiles ifTrue:[^true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3727
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3728
    "/ 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
  3729
    "/ for some specific machine
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3730
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  3731
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3732
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3733
     ObjectFileLoader canLoadObjectFiles
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3734
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3735
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3736
    "Modified: 8.1.1997 / 18:13:01 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3737
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3738
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3739
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
  3740
    "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
  3741
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3742
    |pathName|
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3743
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
  3744
    LoadedObjects isNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3745
	^ 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
  3746
    ].
2407
8fb1437d983a Use #libPath for Unix and Windows
Stefan Vogel <sv@exept.de>
parents: 2405
diff changeset
  3747
    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
  3748
    ^ 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
  3749
!
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3750
2393
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3751
handleFromID:id
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3752
    "given an id, return the pathName, or nil for static modules"
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3753
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3754
    LoadedObjects notNil ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3755
	LoadedObjects keysAndValuesDo:[:name :handle |
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3756
	    handle moduleID == id ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3757
		^ handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3758
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  3759
	].
2393
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3760
    ].
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3761
    ^ nil
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3762
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3763
    "
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3764
     ObjectFileLoader handleFromID:1
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3765
    "
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3766
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3767
    "Modified: 28.8.1995 / 18:08:28 / claus"
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3768
!
a6a136601357 Fix dll unloading
Stefan Vogel <sv@exept.de>
parents: 2352
diff changeset
  3769
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3770
loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3771
    "return a collection containing the names of all
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3772
     dynamically loaded objects."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3773
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3774
    LoadedObjects isNil ifTrue:[^ #()].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3775
    ^ LoadedObjects keys copy
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3776
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3777
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3778
     ObjectFileLoader loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3779
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3780
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3781
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3782
loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3783
    "return a collection of all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3784
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3785
    LoadedObjects isNil ifTrue:[^ #()].
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  3786
    ^ LoadedObjects
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3787
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3788
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3789
     ObjectFileLoader loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3790
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3791
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3792
    "Created: 17.9.1995 / 14:28:55 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3793
    "Modified: 17.9.1995 / 16:13:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3794
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3795
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3796
loadedObjectHandlesDo:aBlock
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3797
    "enumerate all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3798
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3799
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3800
	LoadedObjects copy do:aBlock.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3801
    ].
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
     ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3805
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3806
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3807
    "Created: 14.9.1995 / 22:03:13 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3808
    "Modified: 14.9.1995 / 22:32:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3809
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3810
1602
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3811
moduleNamed:aNameString
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3812
    "return the module named aNameString"
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3813
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3814
    |moduleDescriptor|
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3815
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3816
    moduleDescriptor :=
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3817
	ObjectMemory binaryModuleInfo
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3818
	    detect:[:eachModuleDescriptor | eachModuleDescriptor libraryName = aNameString]
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3819
	    ifNone:[^ nil].
1742
2a2f0bf6342d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  3820
2a2f0bf6342d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  3821
    ^ LoadedObjects at:(moduleDescriptor pathName) ifAbsent:[].
1602
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3822
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3823
    "
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3824
     ObjectFileLoader moduleNamed:'ctypes'
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3825
    "
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3826
!
dd778e6d381e New: #moduleNamed:
Stefan Vogel <sv@exept.de>
parents: 1555
diff changeset
  3827
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3828
pathNameFromID:id
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3829
    "given an id, return the pathName, or nil for static modules"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3830
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3831
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3832
	LoadedObjects keysAndValuesDo:[:name :handle |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3833
	    handle moduleID == id ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3834
		^ handle pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3835
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3836
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3837
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3838
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3839
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3840
    "
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  3841
     ObjectFileLoader pathNameFromID:1
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3842
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3843
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3844
    "Modified: 28.8.1995 / 18:08:28 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3845
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3846
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3847
primCanLoadObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3848
    "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
  3849
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3850
%{  /* NOCONTEXT */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3851
#ifdef HAS_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3852
# if !defined(OS_DEFINE) || defined(unknownOS)
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  3853
    console_fprintf(stderr, "*** OS_DEFINE not correct\n");
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3854
# else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3855
#  if !defined(CPU_DEFINE) || defined(unknownCPU)
1975
ef4a78faca4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  3856
    console_fprintf(stderr, "*** CPU_DEFINE not correct\n");
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3857
#  else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3858
    RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3859
#  endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3860
# endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3861
#endif
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
    ^ false
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3864
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3865
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3866
     ObjectFileLoader primCanLoadObjectFiles
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3867
    "
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  3868
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  3869
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  3870
!ObjectFileLoader class methodsFor:'st object file handling'!
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3871
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3872
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
  3873
    "call a function at address - a very dangerous operation.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3874
     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
  3875
     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
  3876
     ForceOld (if true) will have the memory manager
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3877
     allocate things in oldSpace instead of newSpace.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3878
     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
  3879
     otherwise, its called without arguments.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3880
     If its a smalltalk-moduleInit, it may be either for a classPackage (which should
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3881
     install all of its classes) or for a single incrementally compiled methdod
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3882
     (it should then NOT install it, but return the method object instead).
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3883
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3884
     DANGER: Internal & highly specialized. Dont use in your programs.
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3885
	     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
  3886
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3887
    |moduleID retVal oldSpaceReserve|
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3888
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3889
    handle notNil ifTrue:[
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3890
	moduleID := handle moduleID
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3891
    ].
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3892
    "/
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3893
    "/ 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
  3894
    "/ 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
  3895
    "/ 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
  3896
    "/ 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
  3897
    "/ 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
  3898
    "/ (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
  3899
    "/
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3900
    oldSpaceReserve := OldSpaceReserve ? (1024*1024).
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3901
1033
f5bad5027056 More Stack when calling init function.
Stefan Vogel <sv@exept.de>
parents: 1024
diff changeset
  3902
%{  /* CALLSSTACK: 128000 */
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3903
    OBJ (*addr)();
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3904
    int prevSpace, force;
591
9c48953d9fab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 590
diff changeset
  3905
    INT arg = 0, ret = 0;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3906
    int wasBlocked = 1;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3907
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3908
    if (__isInteger(address)) {
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3909
	if (_isSmallInteger(argument)) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3910
	    arg = __intVal(argument);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3911
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3912
	    addr = (OBJFUNC)(__longIntVal(address));
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3913
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3914
	    /*
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3915
	     * allow function to be interrupted
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3916
	     */
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3917
	    if (interruptable != true) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3918
		wasBlocked = (__BLOCKINTERRUPTS() == true);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3919
	    }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3920
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3921
	    force = (forceOld == true);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3922
	    if (force) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3923
		int reserve = __intVal(oldSpaceReserve);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3924
		if ((__oldSpaceSize() - __oldSpaceUsed()) < reserve) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3925
		    __moreOldSpace(__thisContext, reserve);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3926
		}
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3927
		prevSpace = __allocForceSpace(OLDSPACE);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3928
	    }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3929
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3930
	    if (@global(Verbose) == true) {
2339
e08285b13360 Eliminate _USE_L_MODIFIER_IN_PRINTF
Stefan Vogel <sv@exept.de>
parents: 2334
diff changeset
  3931
		console_printf("calling initfunc %lx(%lx) ...\n", (long)addr, (long)arg);
1906
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3932
	    }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3933
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3934
	    if (special == true) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3935
		if (__isSmallInteger(moduleID)) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3936
		    __SET_MODULE_ID(__intVal(moduleID));
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3937
		}
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3938
		retVal = (*addr)(arg, __pRT__);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3939
		__SET_MODULE_ID(0);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3940
		if (returnsObject != true) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3941
		    retVal = nil;
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3942
		}
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3943
	    } else {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3944
		if (returnsObject == true) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3945
		    retVal = (*addr)(arg);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3946
		} else {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3947
		    ret = (INT) ((*addr)(arg));
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3948
		    retVal = __mkSmallInteger(ret);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3949
	       }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3950
	    }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3951
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3952
	    if (force) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3953
		__allocForceSpace(prevSpace);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3954
	    }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3955
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3956
	    if (! wasBlocked) {
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3957
		__UNBLOCKINTERRUPTS();
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3958
	    }
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3959
	    RETURN (retVal);
c52f389751db *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1904
diff changeset
  3960
	}
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3961
    }
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3962
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3963
    self primitiveFailed
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3964
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3965
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
  3966
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
  3967
    "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
  3968
     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
  3969
     (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
  3970
    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
  3971
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3972
    |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
  3973
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3974
    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
  3975
	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
  3976
	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
  3977
    ] 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
  3978
	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
  3979
	    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
  3980
	    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
  3981
	] 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
  3982
	    '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
  3983
	    ^ 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
  3984
	]
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3985
    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3986
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3987
    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
  3988
	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
  3989
	    ('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
  3990
	].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3991
	"/ 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
  3992
	^ 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
  3993
    ].
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3994
6d075e94c774 Do not initialize an object file, if it has already been loaded&initialized before
Stefan Vogel <sv@exept.de>
parents: 1975
diff changeset
  3995
    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
  3996
	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
  3997
	    ('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
  3998
	].
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
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
	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
  4001
	(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
  4002
	    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
  4003
		('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
  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
	    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
  4006
	    ^ 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
  4007
	].
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
    ].
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
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
    ('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
  4011
    ^ 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
  4012
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
    "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
  4014
!
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
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4016
deinitializeClassesFromModule:handle
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  4017
    "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
  4018
     to all classes of a module."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4019
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4020
    |classes|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4021
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4022
    classes := handle classes.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4023
    classes notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4024
	classes do:[:aClass |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4025
	    aClass notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4026
		aClass isMeta ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4027
		    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4028
			'send #deinitialize to:' errorPrint. aClass name errorPrintCR.
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4029
		    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4030
		    aClass deinitialize.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4031
		    aClass update:#aboutToUnload with:nil from:self
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4032
		]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4033
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4034
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4035
    ]
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  4036
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4037
    "Modified: 10.1.1997 / 17:56:50 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4038
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4039
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4040
invalidateModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4041
    "invalidate all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4042
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4043
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4044
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4045
    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4046
	'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
  4047
	' id=' errorPrint. handle moduleID errorPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4048
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4049
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4050
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4051
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4052
    __INVALIDATE_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4053
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4054
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4055
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4056
loadStatusFor:className
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4057
    "ask VM if class-hierarchy has been completely loaded, and return the status.
2705
82da3252db2a changed: #loadStatusFor:
Stefan Vogel <sv@exept.de>
parents: 2661
diff changeset
  4058
     If className ist non-nil, check the load status of this class only,
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4059
     otherwise check the status of all known classes.
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4060
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4061
     Answer an array with the status symbol and optionally the name of
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4062
     a class with a bad status."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4063
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4064
    |checker checkSymbol statusCode status badClassName|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4065
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4066
    checker := self.
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4067
    checkSymbol := #classPresentCheck:.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4068
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4069
%{  /* NOREGISTER */
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4070
    char *badName;
2705
82da3252db2a changed: #loadStatusFor:
Stefan Vogel <sv@exept.de>
parents: 2661
diff changeset
  4071
    char interestingClassName[512], *classNameP = 0;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4072
1759
a49b7066594c UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents: 1745
diff changeset
  4073
    if (__isStringLike(className)) {
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4074
	strncpy(interestingClassName, __stringVal(className), sizeof(interestingClassName));
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4075
	classNameP = interestingClassName;
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4076
    }
2705
82da3252db2a changed: #loadStatusFor:
Stefan Vogel <sv@exept.de>
parents: 2661
diff changeset
  4077
    statusCode = __MKSMALLINT(__check_registration__(classNameP,
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4078
						     &checker, &checkSymbol,
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4079
						     &badName));
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4080
    if (badName) {
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4081
	badClassName = __MKSTRING(badName);
303
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
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4084
    statusCode == 0 ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4085
	status := #ok
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4086
    ] ifFalse:[ statusCode == -1 ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4087
	status := #missingClass
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4088
    ] ifFalse:[ statusCode == -2 ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4089
	status := #versionMismatch
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4090
    ] ifFalse:[ statusCode == -3 ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4091
	status := #unregisteredSuperclass
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4092
    ] ifFalse:[ statusCode == -4 ifTrue:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4093
	status := #tryAgain
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4094
    ] ifFalse:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4095
	status := #loadFailed
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4096
    ] ] ] ] ].
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4097
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4098
    ^ Array with:status with:badClassName.
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
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4101
moduleInit:phase forceOld:forceOld interruptable:interruptable
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4102
    "initialization phases after registration.
1759
a49b7066594c UNLIMITEDSTACK for windows, too
Stefan Vogel <sv@exept.de>
parents: 1745
diff changeset
  4103
     DANGER: Pure magic; internal only -> don't use in your programs."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4104
1959
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4105
    self primModuleInit:phase forceOld:forceOld interruptable:interruptable
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4106
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4107
    "Modified: / 06-12-2006 / 13:09:43 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4108
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4109
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4110
performModuleInitAt:initAddr for:className identifyAs:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4111
    "Initialize a loaded smalltalk module."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4112
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4113
    ^ self
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4114
	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
  4115
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4116
!
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4117
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4118
performModuleInitAt:initAddr invokeInitializeMethods:invokeInitializeMethods for:className identifyAs:handle
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4119
    "Initialize a loaded smalltalk module."
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4120
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4121
    |status badClassName infoCollection info classNames classes
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  4122
     stillTrying|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4123
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4124
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4125
     need 4 passes to init: 0: let module register itself & create its pools/globals
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4126
                            0b check if modules superclasses are all loaded
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4127
                            1: let it get var-refs to other pools/globals
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4128
                            2: let it install install class, methods and literals
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4129
                            3: let it send #initialize to its class object
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4130
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4131
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4132
    Verbose ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4133
        'start' errorPrintCR
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4134
    ].
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4135
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4136
    [
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4137
        stillTrying := false.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4138
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4139
        "/
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4140
        "/ let it register itself
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4141
        "/ and define its globals
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4142
        "/
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4143
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4144
            'phase 0 (module registration) ...' errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4145
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4146
        self
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4147
            saveCallInitFunctionAt:initAddr
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4148
            in:nil
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4149
            specialInit:true
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4150
            forceOld:true
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4151
            interruptable:false
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4152
            argument:0
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4153
            identifyAs:handle
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4154
            returnsObject:false.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4155
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4156
        "/
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4157
        "/ check if superclasses are present
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4158
        "/
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4159
        info := self loadStatusFor:className.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4160
        status := info at:1.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4161
        badClassName := info at:2.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4162
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4163
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4164
            '... info is ' errorPrint. info errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4165
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4166
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4167
        (status ~~ #ok) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4168
            (status == #missingClass) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4169
                ('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4170
                ^ info
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4171
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4172
            (status == #versionMismatch) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4173
                ('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4174
                ^ info
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4175
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4176
            (status == #unregisteredSuperclass) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4177
                ('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4178
                ^ info
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4179
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4180
            (status == #tryAgain) ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4181
                "/ tryAgain:
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4182
                "/   must retry after initialization, to initialize
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4183
                "/   sub-subclasses of autoloaded classes
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4184
                "/   (sigh - class objects are created in phase 3,
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4185
                "/    so we must first complete the initialization cycle,
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4186
                "/    then do all again, for remaining modules)
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4187
                stillTrying := true.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4188
                'ObjectFileLoader [info]: retry registration of: ' infoPrint.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4189
                (className ? 'a classLib') infoPrint. ' after init' infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4190
            ] ifFalse:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4191
                'ObjectFileLoader [error]: load failed: ' infoPrint. className infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4192
                ^ Array with:#loadFailed with:nil
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4193
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4194
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4195
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4196
        Smalltalk flushCachedClasses.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4197
        Class flushSubclassInfo.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4198
        "/
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4199
        "/ remaining initialization
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4200
        "/
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4201
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4202
        "/ module exports: declare module-globals & symbols ...
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4203
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4204
            'phase 1 (resolve globals) ...' errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4205
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4206
        self moduleInit:1 forceOld:true interruptable:false.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4207
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4208
        "/ module-imports: resolve globals ...
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4209
        "/ create methods & install ...
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4210
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4211
            'phase 2 (create objects) ...' errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4212
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4213
        self moduleInit:2 forceOld:true interruptable:false.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4214
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4215
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4216
            'stillTrying is ' errorPrint. stillTrying errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4217
        ].
2456
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4218
    ] doWhile:[stillTrying].
a58382d69bea changed:
Stefan Vogel <sv@exept.de>
parents: 2419
diff changeset
  4219
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4220
    Verbose ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4221
        'end' errorPrintCR
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4222
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4223
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4224
    ObjectMemory flushCaches.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4225
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4226
    invokeInitializeMethods ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4227
        Verbose ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4228
            'phase 3 (send #initialize) ...' errorPrintCR
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4229
        ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4230
        "/ initialize ...
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4231
        self moduleInit:3 forceOld:false interruptable:true.
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4232
    ].
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4233
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4234
    "/ ask objectMemory for the classes we have just loaded
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4235
    "/ and register them in the handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4236
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4237
    infoCollection := ObjectMemory binaryModuleInfo.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4238
    info := infoCollection at:handle moduleID ifAbsent:nil.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4239
    info isNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4240
        "/ mhmh registration failed -
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4241
        'ObjectFileLoader [error]: registration failed: ' infoPrint.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4242
        (className ? 'some classLib') infoPrintCR.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4243
        ^ Array with:#registrationFailed with:nil
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4244
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4245
405
92cb91b82cf7 changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4246
    classNames := info classNames.
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  4247
    classNames notEmptyOrNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4248
        classes := OrderedCollection new:classNames size.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4249
        classNames do:[:eachClassName | |class|
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4250
            class := Smalltalk classNamed:eachClassName.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4251
            class notNil ifTrue:[
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4252
                classes add:class.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4253
            ].
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4254
        ].
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4255
    ].
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  4256
    classes notEmptyOrNil ifTrue:[
3006
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4257
        classes := classes asArray.
754019e495a6 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3002
diff changeset
  4258
        classes := classes , (classes collect:[:aClass | aClass class]).
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4259
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4260
    handle classes:classes.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4261
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4262
"/    invokeinitializemethods iftrue:[
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4263
"/        verbose iftrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4264
"/            'phase 3 (send #initialize) ...' errorPrintCR
1958
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4265
"/        ].
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4266
"/        "/ INITIALIZE ...
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4267
"/        self moduleinit:3 forceold:false interruptable:true.
62e95d1c9501 initialize classes BEFORE asking for moduleInfo.
Claus Gittinger <cg@exept.de>
parents: 1942
diff changeset
  4268
"/    ].
881
ed4efb1b161e perform moduleInit3 AFTER registering the module.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
  4269
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4270
    ^ Array with:#ok with:nil
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4271
1540
72bdddf92706 Avoid error messages about nil classes
Stefan Vogel <sv@exept.de>
parents: 1448
diff changeset
  4272
    "Modified: / 29-07-2004 / 17:12:28 / stefan"
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4273
    "Modified: / 15-11-2010 / 13:20:11 / cg"
303
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
1959
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4276
primModuleInit:phase forceOld:forceOld interruptable:interruptable
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4277
    "initialization phases after registration.
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4278
     DANGER: Pure magic; internal only -> don't use in your programs."
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4279
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4280
%{
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4281
    int prevSpace, force;
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4282
    int wasBlocked = 1;
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4283
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4284
    if (__isSmallInteger(phase)) {
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4285
	if (interruptable != true) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4286
	    wasBlocked = (__BLOCKINTERRUPTS() == true);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4287
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4288
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4289
	force = (forceOld == true);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4290
	if (force) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4291
	    prevSpace = __allocForceSpace(OLDSPACE);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4292
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4293
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4294
	__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
  4295
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4296
	if (force) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4297
	    __allocForceSpace(prevSpace);
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4298
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4299
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4300
	if (! wasBlocked) {
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4301
	    __UNBLOCKINTERRUPTS();
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4302
	}
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4303
	RETURN (self);
1959
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4304
    }
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4305
%}.
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4306
    self primitiveFailed
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4307
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4308
    "Created: / 06-12-2006 / 13:09:24 / cg"
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4309
!
5220b337a955 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1958
diff changeset
  4310
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4311
revalidateModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4312
    "revalidate all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4313
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4314
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4315
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4316
    Verbose ifTrue:[
1964
f037d5288371 registration for extension modules changed (check for classes being present)
Claus Gittinger <cg@exept.de>
parents: 1961
diff changeset
  4317
	'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
  4318
	' id=' errorPrint. handle moduleID errorPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4319
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4320
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4321
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4322
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4323
    __REVALIDATE_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4324
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4325
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4326
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4327
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
  4328
    OSSignalInterrupt handle:[:ex |
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4329
	aFilenameOrNil notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4330
	    ('ObjectFileLoader [warning]: SignalInterrupt from initFunction in %1' bindWith:(aFilenameOrNil asFilename pathName)) errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4331
	] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4332
	    'ObjectFileLoader [warning]: SignalInterrupt from initFunction' errorPrintCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4333
	].
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4334
    ] do:[
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4335
	^ self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4336
	    callInitFunctionAt:address
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4337
	    specialInit:special
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4338
	    forceOld:forceOld
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4339
	    interruptable:interruptable
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4340
	    argument:argument
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4341
	    identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4342
	    returnsObject:returnsObject
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4343
    ].
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4344
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4345
    "Created: / 15-11-2010 / 13:21:59 / cg"
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4346
!
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4347
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4348
unregisterModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4349
    "unregister classes in the VM.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4350
     This invalidates 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
	'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
  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
    __UNREGISTER_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
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4365
!ObjectFileLoader class methodsFor:'under test - loading dlls'!
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4366
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4367
loadObjectFiles:aSeqOfFiles
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4368
    "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
  4369
     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
  4370
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4371
     *** UNDER TEST ...
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4372
	used by ExpeccoStartup under windows.
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4373
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4374
     not supported is C,...
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4375
    "
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4376
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4377
    |filename handle initAddr className infoCollection handles info|
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4378
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4379
    aSeqOfFiles isEmptyOrNil ifTrue:[^ self].
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4380
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4381
    handles := OrderedCollection new.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4382
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4383
    Smalltalk flushCachedClasses.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4384
    Class flushSubclassInfo.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4385
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4386
    aSeqOfFiles do:[:each|
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4387
	filename := each asFilename.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4388
	handle   := self handleForDynamicObject:filename.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4389
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4390
	handle isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4391
	    Smalltalk showSplashMessage:('loading ', filename baseName).
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4392
	    handle := self loadDynamicObject:filename.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4393
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4394
	    handle notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4395
		className := self initFunctionBasenameForFile:filename.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4396
		initAddr := self findInitFunction:className in:handle.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4397
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4398
		initAddr notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4399
		    [
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4400
			self
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4401
			    saveCallInitFunctionAt:initAddr
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4402
			    in:filename
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4403
			    specialInit:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4404
			    forceOld:true
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4405
			    interruptable:false
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4406
			    argument:0
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4407
			    identifyAs:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4408
			    returnsObject:false.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4409
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4410
			info := self loadStatusFor:nil.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4411
			(info first == #tryAgain)
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4412
		    ] whileTrue.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4413
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4414
		    info first == #ok ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4415
			handles add:handle
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4416
		    ] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4417
			( '%1: error during init: %2' bindWith:each with:info) printCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4418
		    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4419
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4420
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4421
	].
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4422
    ].
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4423
    Smalltalk showSplashMessage:('initializing modules-1...').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4424
    self moduleInit:1 forceOld:true interruptable:false.
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4425
    Smalltalk showSplashMessage:('initializing modules-2...').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4426
    self moduleInit:2 forceOld:true interruptable:false.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4427
    ObjectMemory flushCaches.
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4428
    Smalltalk showSplashMessage:('initializing modules-3...').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4429
    self moduleInit:3 forceOld:false interruptable:true.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4430
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4431
    infoCollection := ObjectMemory binaryModuleInfo.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4432
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4433
    handles do:[:each|
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4434
	|classNames classes|
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4435
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4436
	info := infoCollection at:(handle moduleID) ifAbsent:nil.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4437
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4438
	info isNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4439
	    ('error - nil info: %1' bindWith:handle ) printCR.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4440
	] ifFalse:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4441
	    classNames := info classNames.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4442
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4443
	    classNames notEmptyOrNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4444
		classes := OrderedCollection new:classNames size.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4445
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4446
		classNames do:[:eachClassName | |class|
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4447
		    class := Smalltalk classNamed:eachClassName.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4448
		    class notNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4449
			classes add:class.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4450
		    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4451
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4452
		classes notEmptyOrNil ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4453
		    classes := classes asArray.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4454
		    classes := classes , (classes collect:[:aClass | aClass class]).
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4455
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4456
		handle classes:classes.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4457
	    ].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4458
	].
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4459
    ].
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4460
    Smalltalk showSplashMessage:('done loading modules.').
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4461
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4462
"
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4463
    |directory filename dlls|
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4464
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4465
    directory := 'C:\Dokumente und Einstellungen\Steffen Jung\work\exept\expecco\application' asFilename.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4466
    filename := directory construct:'modules.stx'.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4467
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4468
    dlls := OrderedCollection new.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4469
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4470
    filename readingLinesDo:[:aLine|
2744
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4471
	|line dllFile|
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4472
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4473
	line := aLine withoutSeparators.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4474
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4475
	line size > 3 ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4476
	    line first ~~ $# ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4477
		dllFile := directory construct:(line, '.dll').
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4478
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4479
		dllFile exists ifTrue:[
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4480
		    dlls add:dllFile.
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4481
		].
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4482
	    ]
fb0de2fb6f3b changed: #reloadAllRememberedObjectFiles
Stefan Vogel <sv@exept.de>
parents: 2705
diff changeset
  4483
	]
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4484
    ].
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4485
    ObjectFileLoader loadObjectFiles:dlls.
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4486
"
2459
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  4487
2661
ee815dfc5bde changed: #loadObjectFiles:
Claus Gittinger <cg@exept.de>
parents: 2654
diff changeset
  4488
    "Modified: / 11-08-2011 / 17:25:52 / cg"
2408
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4489
! !
8afd8b650da9 added: #loadObjectFiles:
ca
parents: 2407
diff changeset
  4490
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  4491
!ObjectFileLoader class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4492
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4493
version
3034
1d1f847c0fc2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  4494
    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.340 2013-03-11 11:01:04 cg Exp $'
2256
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  4495
!
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  4496
dba660aa4c26 change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 2184
diff changeset
  4497
version_CVS
3034
1d1f847c0fc2 class: ObjectFileLoader
Claus Gittinger <cg@exept.de>
parents: 3032
diff changeset
  4498
    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.340 2013-03-11 11:01:04 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4499
! !
1358
d36c7e6c9e45 refactored
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4500
2992
428e437002b0 class: ObjectFileLoader
Stefan Vogel <sv@exept.de>
parents: 2989
diff changeset
  4501
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  4502
ObjectFileLoader initialize!