ObjectFileLoader.st
author Claus Gittinger <cg@exept.de>
Sat, 10 Nov 2001 01:52:40 +0100
changeset 1217 61cca5c6d4d1
parent 1175 4b6d058ffea4
child 1218 8e2f81f20c85
permissions -rw-r--r--
link flag setup (win32)
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
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
1116
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
    13
"{ Package: 'stx:libcomp' }"
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
    14
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    15
Object subclass:#ObjectFileLoader
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    16
	instanceVariableNames:''
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    17
	classVariableNames:'MySymbolTable Verbose LastError LinkErrorMessage NextHandleID
149
3dc42a5ab417 default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    18
		LoadedObjects PreviouslyLoadedObjects ActuallyLoadedObjects
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
    19
		SearchedLibraries LibPath LoadLibraryPath ErrorPrinting
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
    20
		LinkCommand LinkArgs LastErrorNumber OldSpaceReserve'
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    21
	poolDictionaries:''
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    22
	category:'System-Compiler'
47
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    23
!
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    24
53
c5dd7abf8431 *** empty log message ***
claus
parents: 51
diff changeset
    25
!ObjectFileLoader primitiveDefinitions!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    26
%{
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    27
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    28
/*
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    29
 * by default, use whatever the system provides
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    30
 */
95
claus
parents: 94
diff changeset
    31
#ifdef sunos    /* sunos (pre 5.4) dlopen interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    32
# define SUN_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    33
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    34
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    35
95
claus
parents: 94
diff changeset
    36
#ifdef NeXT     /* next rld interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    37
# define NEXT_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    38
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    39
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    40
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
    41
#if defined(SYSV4) || defined(HAS_DLOPEN)   /* sys5.4 dlopen interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    42
# define SYSV4_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    43
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    44
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    45
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
    46
#if defined(hpux10)
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
    47
# undef SYSV4_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
    48
# define HPUX10_DL
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    49
# define HAS_DL
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
    50
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
    51
587
5250b6d10925 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    52
#if defined(alpha) && defined(__osf__)
5250b6d10925 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    53
# define SYSV4_DL
5250b6d10925 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    54
# define HAS_DL
5250b6d10925 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    55
#endif
5250b6d10925 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
    56
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    57
#ifdef __VMS__
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    58
# undef __new
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    59
# define VMS_DL
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    60
#endif
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
    61
95
claus
parents: 94
diff changeset
    62
#ifdef DL1_6    /* dl1.6 COFF loader */
claus
parents: 94
diff changeset
    63
# define HAS_DL
claus
parents: 94
diff changeset
    64
#endif
claus
parents: 94
diff changeset
    65
98
claus
parents: 97
diff changeset
    66
#ifdef _AIX
97
claus
parents: 96
diff changeset
    67
# define AIX_DL
claus
parents: 96
diff changeset
    68
# define HAS_DL
claus
parents: 96
diff changeset
    69
#endif
claus
parents: 96
diff changeset
    70
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    71
/*
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    72
 * but GNU_DL overwrites this - its better
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    73
 */
95
claus
parents: 94
diff changeset
    74
#ifdef GNU_DL   /* dld2.3.x interface */
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    75
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    76
# undef SYSV4_DL
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    77
# undef NEXT_DL
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    78
# undef SUN_DL
95
claus
parents: 94
diff changeset
    79
# undef DL1_6
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    80
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    81
801
0ab2ba78b26e newest stdio uses __new
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    82
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    83
#include <stdio.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    84
801
0ab2ba78b26e newest stdio uses __new
Claus Gittinger <cg@exept.de>
parents: 791
diff changeset
    85
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    86
#if defined(WIN32)
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
# undef COFF
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
# undef ELF
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
# undef A_DOT_OUT
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    90
# define HAS_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    91
# define WIN_DL
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
#endif
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
    94
#if defined(BEOS)
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
    95
# undef COFF
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
    96
# undef ELF
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
    97
# undef A_DOT_OUT
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
    98
# define HAS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
    99
# define BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   100
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   101
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   102
/*
95
claus
parents: 94
diff changeset
   103
 * if no dynamic link facilities, try it the hard way ...
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   104
 */
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
#if !defined(HAS_DL)
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   106
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   107
# ifdef A_DOT_OUT
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   108
#  include <a.out.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   109
#  ifndef N_MAGIC
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   110
#   if defined(sinix) && defined(BSD)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   111
#    define N_MAGIC(hdr) (hdr.a_magic & 0xFFFF)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   112
#   else
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   113
#    define N_MAGIC(hdr) (hdr.a_magic)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   114
#   endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   115
#  endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   116
# endif /* a.out */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   117
 
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   118
# ifdef COFF
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   119
#  ifdef mips
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   120
#    include <sys/exec.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   121
#  else
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   122
#    include <a.out.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   123
#  endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   124
# endif /* coff */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   125
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   126
# ifdef ELF
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   127
#  include <elf.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   128
# endif /* elf */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   129
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   130
#endif /* not HAS_DL */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   131
95
claus
parents: 94
diff changeset
   132
#ifdef NEXT_DL
claus
parents: 94
diff changeset
   133
# ifndef _RLD_H_
claus
parents: 94
diff changeset
   134
#  define _RLD_H_
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   135
#  ifdef NEXT3
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   136
#   include <mach-o/rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   137
#  else
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   138
#   include <rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   139
#  endif
95
claus
parents: 94
diff changeset
   140
# endif
claus
parents: 94
diff changeset
   141
#endif /* NEXT_DL */
claus
parents: 94
diff changeset
   142
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   143
#ifdef SYSV4_DL
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   144
# include <dlfcn.h>
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   145
# define dlcfn_h
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   146
#endif
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   147
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   148
#ifdef GNU_DL
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   149
#  ifndef dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   150
#   include "dld.h"
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   151
#   define dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   152
#  endif
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   153
#endif
95
claus
parents: 94
diff changeset
   154
claus
parents: 94
diff changeset
   155
#ifdef DL1_6
claus
parents: 94
diff changeset
   156
#  ifndef dl_h
claus
parents: 94
diff changeset
   157
#   include "dl.h"
claus
parents: 94
diff changeset
   158
#   define dl_h
claus
parents: 94
diff changeset
   159
#  endif
claus
parents: 94
diff changeset
   160
#endif
claus
parents: 94
diff changeset
   161
97
claus
parents: 96
diff changeset
   162
#ifdef AIX_DL
claus
parents: 96
diff changeset
   163
# include <nlist.h>
100
claus
parents: 98
diff changeset
   164
# include <sys/ldr.h>
claus
parents: 98
diff changeset
   165
# include <errno.h>
97
claus
parents: 96
diff changeset
   166
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   167
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   168
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   169
# include <dl.h>
524
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
   170
# include <errno.h>
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   171
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   172
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   173
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   174
# include <be/kernel/image.h>
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   175
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   176
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   177
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   178
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   179
# ifdef WIN32
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   180
#  undef INT
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   181
#  undef Array
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   182
#  undef Number
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   183
#  undef Method
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   184
#  undef Block
857
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   185
#  undef Time
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   186
#  undef Date
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   187
#  undef Set
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   188
#  undef Delay
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   189
#  undef Signal
1175
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   190
#  undef Context
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   191
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   192
#  ifdef i386
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   193
#   ifndef _X86_
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   194
#    define _X86_
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   195
#   endif
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   196
#  endif
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   197
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   198
#  ifdef __BORLANDC__
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   199
#   define NOATOM
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   200
#   define NOUSER
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   201
#   define NOGDI
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   202
#   define NOGDICAPMASKS
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   203
#   define NOMETAFILE
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   204
#   define NOMINMAX
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   205
#   define NOMSG
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   206
#   define NOOPENFILE
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   207
#   define NORASTEROPS
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   208
#   define NOSCROLL
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   209
#   define NOSOUND
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   210
#   define NOSYSMETRICS
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   211
#   define NOTEXTMETRIC
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   212
#   define NOWH
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   213
#   define NOCOMM
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   214
#   define NOKANJI
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   215
#   define NOCRYPT
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   216
#   define NOMCX
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   217
#   define WIN32_LEAN_AND_MEAN
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   218
#   include <windows.h> /* */
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   219
#  else
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   220
/* #  include <windows.h> /* */
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   221
#  endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   222
#  include <windef.h> /* */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   223
#  include <winbase.h> /* */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   224
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   225
#  ifdef __DEF_Array
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   226
#   define Array __DEF_Array
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   227
#  endif
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   228
#  ifdef __DEF_Number
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   229
#   define Number __DEF_Number
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   230
#  endif
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   231
#  ifdef __DEF_Method
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   232
#   define Method __DEF_Method
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   233
#  endif
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   234
#  ifdef __DEF_Block
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   235
#   define Block __DEF_Block
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   236
#  endif
857
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   237
#  ifdef __DEF_Time
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   238
#   define Time __DEF_Time
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   239
#  endif
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   240
#  ifdef __DEF_Date
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   241
#   define Date __DEF_Date
72baf41f3bc9 *** empty log message ***
ps
parents: 850
diff changeset
   242
#  endif
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   243
# ifdef __DEF_Set
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   244
#  define Set __DEF_Set
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   245
# endif
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   246
# ifdef __DEF_Signal
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   247
#  define Signal __DEF_Signal
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   248
# endif
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   249
# ifdef __DEF_Delay
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   250
#  define Delay __DEF_Delay
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   251
# endif
1175
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   252
# ifdef __DEF_Context
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   253
#  define Context __DEF_Context
4b6d058ffea4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   254
# endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   255
# endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   256
729
924ccc3434df borland-C support
Claus Gittinger <cg@exept.de>
parents: 724
diff changeset
   257
#endif /* WIN_DL */
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   258
%}
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   259
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   260
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   261
!ObjectFileLoader class methodsFor:'documentation'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   262
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   263
copyright
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
 COPYRIGHT (c) 1993 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   266
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   267
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   268
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   269
 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
   270
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   271
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   272
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   273
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   274
"
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   277
documentation
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   278
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   279
    This class knowns how to dynamically load in external object-modules.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   280
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   281
    WARNING:
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   282
      As to date, this is still experimental and WITHOUT ANY WARRANTY.
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   283
      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
   284
      robustness.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   285
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   286
    There are basically two totally different mechanisms to do this:
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   287
	a) if there exists some dynamic-link facility such as:
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   288
	   GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   289
	   or LoadLibrary (Win32), this is used
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   290
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   291
	b) if no such facility exists, the normal linker is used to
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   292
	   link the module to text/data address as previously malloced,
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   293
	   and the object file loaded into that space.
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   294
           
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   295
    Currently, not all mechanisms work fully satisfying.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   296
    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
   297
    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
   298
    allow for selective unloading (only all or the last loaded module).
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   299
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   300
    The only really useful packages are the GNU-dl package, 
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   301
    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
   302
    The GNU-dl package is only available for a.out file formats
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   303
    (which is more or less obsolete); 
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   304
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   305
    For the above reasons, dynamic object loading is currently only
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
   306
    officially released for SYS5.4-based, LINUX and win32 systems.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   307
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   308
    Once stable, the functionality contained herein will be moved into
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   309
    the VM. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   310
    (It is needed there, to allow reloading of objectfiles upon
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   311
     image restart; i.e. before any class is reinitialilized).
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   312
809
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   313
    Right now, reloading of object files is done by smalltalk code,
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   314
    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
   315
    load takes place, or which is used by the loader itself.
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   316
    (i.e. for now, many primitives from libbasic cannot be dynamically
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   317
    loaded at image restart time).
09213d35c1cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
   318
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   319
    [author:]
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   320
	Claus Gittinger
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   321
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   322
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   323
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   324
!ObjectFileLoader class methodsFor:'initialization'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   325
7ad01559b262 Initial revision
claus
parents:
diff changeset
   326
initialize
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   327
    |systemType libDir|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   328
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   329
    OperatingSystem isMSDOSlike ifTrue:[
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   330
        "/ default setup for msc
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   331
        OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   332
            libDir := '..\libbc'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   333
            libDir asFilename exists ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   334
                libDir := '..\lib\libbc'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   335
                libDir asFilename exists ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   336
                    libDir := '..\lib'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   337
                ]
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   338
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   339
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   340
            LinkCommand isNil ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   341
                LinkCommand := 'tlink32'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   342
                LinkCommand := 'ilink32'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   343
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   344
            LinkArgs isNil ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   345
                LinkArgs := '-L',libDir,' -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ',libDir,'\librun.lib'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   346
                LinkArgs := '-L',libDir,' -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   347
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   348
            SearchedLibraries := #(
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   349
                                    'import32.lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   350
                                  ).
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   351
        ] ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   352
            LinkCommand isNil ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   353
                LinkCommand := 'link'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   354
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   355
            LinkArgs isNil ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   356
                LinkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   357
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
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:[
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   362
        Verbose := false.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   363
        NextHandleID := 1.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   364
        ObjectMemory addDependent:self.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   365
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   366
        OperatingSystem isMSDOSlike ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   367
            SearchedLibraries := #(
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   368
                                    'import32.lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   369
                                  ).
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   370
        ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   371
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   372
        OperatingSystem isUNIXlike ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   373
            systemType := OperatingSystem getOSType.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   374
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   375
            "/ name of object file, where initial symbol table is found
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   376
            "/ not req'd for all architectures.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   377
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   378
            MySymbolTable := 'stx'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   379
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   380
            "/ default set of libraries to be considered when
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   381
            "/ unresolved symbols are encountered during the load.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   382
            "/ Only req'd for linux and sunos non-ELF systems.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   383
            "/ Can (should) be set in the smalltalk.rc file.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   384
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   385
            SearchedLibraries := #().
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   386
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   387
            (systemType = 'linux' 
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   388
            or:[systemType = 'sunos']) ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   389
                '/usr/lib/libc.a' asFilename isReadable ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   390
                    SearchedLibraries := #('/usr/lib/libc.a')
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   391
                ] ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   392
                    '/lib/libc.a' asFilename isReadable ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   393
                        SearchedLibraries := #('/lib/libc.a')
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   394
                    ]
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   395
                ]
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   396
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   397
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   398
            "/ default libraryPath where shared objects are searched for
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   399
            "/ when a dynamic library is loaded without an explicit path.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   400
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   401
            LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   402
            LoadLibraryPath isNil ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   403
                LoadLibraryPath := #('.'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   404
                                     'lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   405
                                     '/usr/local/smalltalk/lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   406
                                     '/usr/local/lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   407
                                     '/usr/lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   408
                                     '/lib'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   409
                                    ) asOrderedCollection.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   410
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   411
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   412
            "/ default libraryPath where shared objects are expected
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   413
            "/ when a sharedObject load requires other objects to be loaded.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   414
            "/ Only req'd for aix.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   415
            "/ For more compatibility with ELF systems, look for a shell variable
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   416
            "/ named LD_LIBRARY_PATH, and - if present - take that instead if a default.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   417
            "/ Can (should) be set in the smalltalk.rc file.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   418
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   419
            systemType = 'aix' ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   420
                LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   421
                LibPath isNil ifTrue:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   422
                    LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   423
                ]
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   424
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   425
        ]
201
66bd5f9c781c only init once
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
   426
    ]
107
claus
parents: 106
diff changeset
   427
claus
parents: 106
diff changeset
   428
    "
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   429
     LinkArgs := LinkCommand := nil.   
107
claus
parents: 106
diff changeset
   430
     ObjectFileLoader initialize
claus
parents: 106
diff changeset
   431
    "
316
ee3426730cfc on sunos: link dynamic objects against libc.a for unresolved symbols.
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
   432
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
   433
    "Modified: / 10.11.2001 / 01:45:01 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   434
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   435
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   436
lastError
780
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   437
    ^ LastError ? 'unknown error'
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   438
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
   439
    "Modified: / 30.9.1998 / 17:21:23 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   440
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   441
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   442
libPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   443
    "see comment in #libPath:"
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   444
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   445
    ^ LibPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   446
!
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   447
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   448
libPath:aSharedLibraryPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   449
    "set the pathnames of directories, where other shared objects
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   450
     are searched, in case a loaded module requires another module shared
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   451
     library object to be loaded.
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   452
     Currently, this is only required to be set for AIX systems;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   453
     ELF based linux and solaris systems specify the libPath in the 
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   454
     LD_LIBRARY_PATH environment variable."
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   455
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   456
    LibPath := aSharedLibraryPath
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   457
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   458
    "
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   459
     ObjectFileLoader libPath:'.:/usr/lib:/usr/local/lib'
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   460
    "
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   461
!
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   462
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   463
linkErrorMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   464
    ^ LinkErrorMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   465
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   466
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   467
searchedLibraries
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   468
    "see comment in #searchedLibraries:"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   469
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   470
    ^ SearchedLibraries
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   471
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   472
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   473
searchedLibraries:aCollectionOfArchivePathNames
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   474
    "set the pathnames of archives which are to be searched
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   475
     when unresolved references occur while loading in an object
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   476
     file. On systems which support shared libraries (all SYS5.4 based
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   477
     systems), this is usually not required. Instead, modules which are to
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   478
     be filed in (.so files) are to be prelinked with the appropriate
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   479
     shared libraries. The dynamic loader then cares about loading those
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   480
     modules (keeping track of which modules are already loaded).
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   481
     Only systems in which the dynamic load is done 'manually' by st/x
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   482
     (i.e. currently only linux and a.out-sunos) need to set this."
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   483
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   484
    SearchedLibraries := aCollectionOfArchivePathNames
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   485
!
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   486
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   487
verbose
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   488
    "return true, if debug traces are turned on"
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   489
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   490
    ^ Verbose
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   491
!
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   492
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   493
verbose:aBoolean
7ad01559b262 Initial revision
claus
parents:
diff changeset
   494
    "turn on/off debug traces"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   495
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
   496
    Verbose := aBoolean
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   497
7ad01559b262 Initial revision
claus
parents:
diff changeset
   498
    "ObjectFileLoader verbose:true"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   499
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   500
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   501
!ObjectFileLoader class methodsFor:'change & update'!
291
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   502
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   503
update:something with:aParameter from:changedObject
107
claus
parents: 106
diff changeset
   504
    "sent, when image is saved or restarted"
claus
parents: 106
diff changeset
   505
claus
parents: 106
diff changeset
   506
    (something == #aboutToSnapshot) ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   507
	self invalidateAndRememberAllObjectFiles
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   508
    ].
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   509
    (something == #finishedSnapshot) ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   510
	self revalidateAllObjectFiles
107
claus
parents: 106
diff changeset
   511
    ].
226
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   512
"/    (something == #restarted) ifTrue:[
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   513
"/        self reloadAllRememberedObjectFiles
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   514
"/    ].
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   515
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   516
    "Modified: 5.10.1995 / 15:49:14 / claus"
226
f0771f42256d reloadAllObjectFiles now called explicit (its too late via ObjMem changed)
Claus Gittinger <cg@exept.de>
parents: 225
diff changeset
   517
    "Modified: 8.3.1996 / 23:34:29 / cg"
291
c0d5159014be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   518
    "Created: 21.6.1996 / 19:50:01 / cg"
107
claus
parents: 106
diff changeset
   519
! !
claus
parents: 106
diff changeset
   520
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   521
!ObjectFileLoader class methodsFor:'defaults'!
115
claus
parents: 114
diff changeset
   522
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   523
hasValidBinaryExtension:aFilename
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   524
    "return true, if aFilename looks ok for binary loading.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   525
     This checks only the extension - not its contents. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   526
     (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
   527
     This is very machine specific."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   528
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   529
    |fn|
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   530
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   531
    fn := aFilename asFilename.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   532
    self validBinaryExtensions do:[:ext |
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   533
	(fn hasSuffix:ext) ifTrue:[^ true].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   534
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   535
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   536
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   537
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   538
     ObjectFileLoader hasValidBinaryExtension:'foo.st'
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   539
     ObjectFileLoader hasValidBinaryExtension:'foo.o' 
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   540
     ObjectFileLoader hasValidBinaryExtension:'foo.so'
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   541
     ObjectFileLoader hasValidBinaryExtension:'foo.dll'
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   542
     ObjectFileLoader hasValidBinaryExtension:'foo.DLL' 
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   543
     ObjectFileLoader hasValidBinaryExtension:'foo.obj'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   544
     ObjectFileLoader hasValidBinaryExtension:'foo.sl'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   545
    "
516
a8de1f7bb496 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   546
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   547
    "Modified: / 1.10.1998 / 12:47:01 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   548
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   549
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   550
linkArgs
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   551
    ^ LinkArgs ? ''   "/ that default is ok for Unix
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   552
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   553
    "Created: / 12.8.1998 / 21:41:16 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   554
    "Modified: / 12.8.1998 / 21:42:50 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   555
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   556
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   557
linkArgs:anArgString
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   558
    LinkArgs := anArgString
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   559
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   560
    "
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   561
     MSC:
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   562
	LinkCommand := 'link32'.
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   563
	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
   564
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   565
     Borland:
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   566
	LinkCommand := 'ilink32'.
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   567
	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
   568
'
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   569
'/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
   570
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   571
     Unix:
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   572
	LinkCommand := 'ld'
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   573
	LinkArgs := '-shared'
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
    "Created: / 12.8.1998 / 21:43:16 / cg"
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   577
    "Modified: / 4.9.1998 / 00:33:46 / cg"
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   578
!
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   579
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   580
linkCommand
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   581
    ^ LinkCommand ? 'ld'   "/ that default is ok for Unix
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   582
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   583
    "Created: / 12.8.1998 / 21:41:16 / cg"
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   584
!
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
linkCommand:aCommand
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   587
    LinkCommand := aCommand
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   588
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
   589
    "Created: / 12.8.1998 / 21:40:44 / cg"
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
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   592
loadableBinaryObjectFormat
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   593
    "return a symbol describing the expected binary format
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   594
     for object files to be loadable.
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   595
     This is very machine specific."
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   596
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   597
%{  /* NOCONTEXT */
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   598
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   599
#ifdef HAS_DL
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   600
# if defined(SYSV4) || defined(ELF)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   601
    RETURN ( @symbol(elf));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   602
# endif
590
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   603
# if defined(alpha) && defined(__osf__)
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   604
    RETURN ( @symbol(coff));
7c158fe9b754 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
   605
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   606
# if defined(GNU_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   607
    RETURN ( @symbol(aout));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   608
# endif
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   609
# if defined(AIX_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   610
    RETURN ( @symbol(xcoff));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   611
# endif
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   612
# if defined(HPUX10_DL)
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   613
    RETURN ( @symbol(hpcoff));
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
   614
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   615
# if defined(DL1_6)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   616
    RETURN ( @symbol(coff));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   617
# endif
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   618
# if defined(WIN_DL)
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   619
    RETURN ( @symbol(dll));
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   620
# endif
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   621
# if defined(BEOS_DL)
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   622
    RETURN ( @symbol(beobj));
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
   623
# endif
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   624
# if defined(__VMS__)
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   625
    RETURN ( @symbol(exe));
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   626
# endif
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   627
#endif
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   628
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   629
%}.
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   630
    ^ nil
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   631
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   632
    "
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   633
     ObjectFileLoader loadableBinaryObjectFormat
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   634
    "
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   635
!
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
   636
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   637
nm:file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   638
   "this should return a string to list the namelist of file.
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   639
    The output of the command should be one line for each symbol,
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   640
    formatted as:
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   641
	addr  segment  name
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   642
    This is parsed and read by #namesMatching:segment:in:.
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   643
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   644
    If your default nm command cannot produce this, write a little
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   645
    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
   646
    below.
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   647
    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
   648
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   649
    |os|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   650
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   651
    os := OperatingSystem getOSType.
702
80f90a274837 more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   652
    (os = 'irix' or:[os = 'osf']) ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   653
	^ 'nm -B ' , file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   654
    ].
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   655
    (os = 'solaris') ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   656
	^ 'nm -p ' , file
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   657
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   658
    ^ 'nm ' , file
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   659
702
80f90a274837 more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   660
    "Modified: / 4.5.1998 / 12:18:47 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   661
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   662
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   663
objectFileExtension
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   664
    "return the fileName extension used for objects,
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   665
     as generated by myself (output of cc).
115
claus
parents: 114
diff changeset
   666
     This is very machine specific."
claus
parents: 114
diff changeset
   667
claus
parents: 114
diff changeset
   668
    |os|
claus
parents: 114
diff changeset
   669
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   670
    OperatingSystem isMSDOSlike ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   671
	"/ includes all of win32s, win95, winNT & os/2
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   672
	^ '.obj'
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   673
    ].
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   674
    OperatingSystem isVMSlike ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   675
	^ '.obj'
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   676
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   677
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   678
    ^ '.o'
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   679
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   680
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   681
     ObjectFileLoader objectFileExtension
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   682
    "
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   683
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   684
    "Modified: / 4.5.1998 / 12:17:34 / cg"
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   685
!
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   686
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   687
sharedLibraryExtension
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   688
    "return the fileName extension used for dynamic loadable objects,
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   689
     as generated by myself (output of linker).
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   690
     This is very machine specific."
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   691
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   692
    |suff|
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   693
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   694
    suff := self sharedLibrarySuffix.
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   695
    suff notNil ifTrue:[^ '.' , suff].
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   696
    ^ suff
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   697
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   698
    "
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   699
     ObjectFileLoader sharedLibraryExtension
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   700
    "
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   701
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   702
    "Modified: / 4.5.1998 / 12:17:34 / cg"
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   703
!
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   704
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   705
sharedLibrarySuffix
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   706
    "return the fileName suffix used for dynamic loadable objects,
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   707
     as generated by myself (output of linker).
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   708
     This is very machine specific."
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   709
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   710
    |os|
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
    OperatingSystem isMSDOSlike ifTrue:[
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   713
        "/ includes all of win32s, win95, winNT & os/2
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   714
        ^ 'dll'
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   715
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   716
    OperatingSystem isVMSlike ifTrue:[
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   717
        ^ 'exe'
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   718
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   719
115
claus
parents: 114
diff changeset
   720
    os := OperatingSystem getSystemType.
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   721
    (os = 'sys5_4') ifTrue:[^ 'so'].
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   722
    (os = 'iris') ifTrue:[^ 'so'].
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   723
    (os = 'linux') ifTrue:[
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   724
        self loadableBinaryObjectFormat == #aout ifTrue:[
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   725
            "/ not really shared, but loadable
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   726
            ^ 'o'
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
        ^ 'so'
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   729
    ].
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   730
    (os = 'solaris') ifTrue:[^ 'so' ].
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   731
    (os = 'osf') ifTrue:[^ 'so' ].
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   732
    (os = 'aix') ifTrue:[^ 'so'].
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   733
    (os = 'hpux') ifTrue:[^ 'sl'].
119
claus
parents: 118
diff changeset
   734
claus
parents: 118
diff changeset
   735
    "/ mhmh what is a useful default ?
claus
parents: 118
diff changeset
   736
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   737
    ^ 'o'
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
   738
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   739
    "
1019
f1098d024b00 added #sharedLibrarySuffix:
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   740
     ObjectFileLoader sharedLibrarySuffix
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
702
80f90a274837 more for alpha-dynamic loading
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   743
    "Modified: / 4.5.1998 / 12:17:34 / cg"
115
claus
parents: 114
diff changeset
   744
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   745
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   746
validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   747
    "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
   748
     This is very machine specific."
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   749
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   750
    |os|
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   751
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   752
    OperatingSystem isMSDOSlike ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   753
	"/ includes all of win32s, win95, winNT & os/2
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   754
	^ #('dll')
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   755
    ].
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   756
    OperatingSystem isVMSlike ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   757
	^ #('exe')
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   758
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
   759
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   760
    os := OperatingSystem getSystemType.
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   761
    (os = 'sys5_4') ifTrue:[^ #('so') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   762
    (os = 'iris') ifTrue:[^ #('so') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   763
    (os = 'osf') ifTrue:[^ #('so') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   764
    (os = 'solaris') ifTrue:[^ #('so') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   765
    (os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   766
    (os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ].
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
   767
    (os = 'linux') ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   768
	self loadableBinaryObjectFormat == #aout ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   769
	    ^ #('o' 'obj' 'a')
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   770
	].
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
   771
	^ #('so' 'o' 'obj' ) 
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
   772
    ].
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   773
    (os = 'aix') ifTrue:[^ #('o' 'so') ].
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   774
    (os = 'hpux') ifTrue:[^ #(" 'o' " 'sl') ].
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   775
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   776
    "/ mhmh what is a useful default ?
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   777
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   778
    ^ #('o')
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   779
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   780
    "
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   781
     ObjectFileLoader validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   782
    "
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   783
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   784
    "Modified: / 1.10.1998 / 12:46:03 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   785
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   786
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   787
!ObjectFileLoader class methodsFor:'dynamic object loading'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   788
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   789
loadCPlusPlusObjectFile:aFileName
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   790
    "load a c++ object file (.o-file) into the image.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   791
     This method is not maintained (name mangling and static
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   792
     initialization is so different among systems ...)"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   793
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   794
    |handle initAddr list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   795
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   796
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   797
    handle isNil ifTrue:[
1161
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   798
        Transcript showCR:('failed to load: ' , aFileName).
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   799
        ('ObjectFileLoader [warning]: '
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   800
         , aFileName
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   801
         , ' failed. ('
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   802
         , LinkErrorMessage
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   803
         , ')') errorPrintCR.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   804
        ^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   805
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   806
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
   807
    list := self namesMatching:'__GLOBAL_$I*' segment:'[tT?]' in:aFileName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   808
list size == 1 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   809
"/    (self isCPlusPlusObject:handle) ifTrue:[
1161
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   810
        Verbose ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   811
            'a c++ object file' infoPrintCR.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   812
        ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   813
        "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   814
         what I would like to get is the CTOR_LIST,
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   815
         and call each function.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   816
         But dld cannot (currently) handle SET-type symbols, therefore
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   817
         we search (using nm) for all __GLOBAL_$I* syms, get their values
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   818
         and call them each
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   822
"/        initAddr := self getFunction:'__CTOR_LIST__' from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   823
"/        Verbose ifTrue:[
478
b0d558152d80 *PrintNL eliminated
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   824
"/            ('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintCR
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   825
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   826
1161
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   827
        initAddr := self getFunction:list first from:handle.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   828
        initAddr isNil ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   829
            "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   830
             try with added underscore
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   831
            "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   832
            initAddr := self getFunction:('_' , list first) from:handle.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   833
        ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   834
        (initAddr isNil and:[list first startsWith:'_']) ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   835
            "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   836
             try with removed underscore
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   837
            "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   838
            initAddr := self getFunction:(list first copyFrom:2) from:handle.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   839
        ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   840
        initAddr isNil ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   841
            Verbose ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   842
                ('no CTOR-func found (' , list first , ')') infoPrintCR.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   843
            ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   844
            self unloadDynamicObject:aFileName.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   845
            ^ nil
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   846
        ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   847
        Verbose ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   848
            ('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintCR
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   849
        ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   850
        self callInitFunctionAt:initAddr 
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   851
             specialInit:false 
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   852
             forceOld:false 
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   853
             interruptable:false
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   854
             argument:0
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   855
             identifyAs:nil
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   856
             returnsObject:false.
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   857
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   858
        Verbose ifTrue:[
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   859
            'done with CTORs.' infoPrintCR
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   860
        ].
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   861
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   862
        "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   863
         cannot create a CPlusPlus class automatically (there could be more than
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   864
         one classes in it too ...)
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   865
        "
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   866
        ^ handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   867
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   868
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   869
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   870
    Verbose ifTrue:[
1161
f1129628b9c6 printNL --> printCR
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
   871
        'unknown object file' infoPrintCR
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   872
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   873
    self unloadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   874
    ^ nil
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
   875
478
b0d558152d80 *PrintNL eliminated
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   876
    "Modified: 10.1.1997 / 19:11:57 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   877
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   878
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   879
loadClass:aClassName fromObjectFile:aFileName
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   880
    "load a compiled class (.o-file) into the image.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
   881
     Returns the class or nil."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   882
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
   883
    |handle initAddr symName newClass moreHandles info status 
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   884
     otherClass knownToBeOk|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   885
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   886
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   887
    handle isNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   888
	Transcript showCR:('failed to load: ' , aFileName).
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   889
	('ObjectFileLoader [warning]: '
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   890
	 , aFileName
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   891
	 , ' failed. ('
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   892
	 , LinkErrorMessage
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   893
	 , ')') errorPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   894
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   895
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   896
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   897
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   898
     get the Init-function; let the class install itself
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   899
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   900
    symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   901
    initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   902
    initAddr isNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   903
	"try with added underscore"
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   904
	symName := '__' , aClassName , '_Init'.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   905
	initAddr := self getFunction:symName from:handle.
141
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   908
    knownToBeOk := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   909
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   910
"/    knownToBeOk ifFalse:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   911
"/        |list|
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
   912
"/
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   913
"/        Verbose ifTrue:[
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   914
"/            'looking for undefs ...' infoPrintCR.
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
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   918
"/         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
   919
"/         files (libs, other modules)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   920
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   921
"/        list := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   922
"/        list notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   923
"/            moreHandles := self loadModulesFromListOfUndefined:list.
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
"/             now, try again
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   927
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   928
"/            symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   929
"/            initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   930
"/            initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   931
"/                "try with added underscore"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   932
"/                symName := '__' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   933
"/                initAddr := self getFunction:symName from:handle.
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
"/        ]
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   938
    initAddr notNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   939
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   940
	    ('calling init at: ' , (initAddr printStringRadix:16)) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   941
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   942
	info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   943
	status := info at:1.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   944
	"
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   945
	 if any classes are missing ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   946
	"
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   947
	(status == #missingClass) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   948
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   949
	     ... and we are loading a module ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   950
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   951
	    Transcript showCR:'try for missing class in same object ...'.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   952
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   953
		'try for missing class:' infoPrint. (info at:2) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   954
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   955
	    otherClass := self loadClass:(info at:2) fromObjectFile:aFileName.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   956
	    otherClass notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   957
		"
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   958
		 try again ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   959
		"
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   960
		Transcript showCR:'missing class is here; try again ...'.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   961
		info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   962
		status := info at:1.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   963
	    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   964
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   965
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   966
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   967
	    'done init status=' infoPrint. info infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   968
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   969
	(status == #unregisteredSuperclass) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   970
	    Transcript showCR:'superclass is not registered'.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   971
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   972
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   973
	(Symbol hasInterned:aClassName) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   974
	    newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   975
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   976
		'newClass is: ' infoPrint. newClass infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   977
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   978
	    newClass notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   979
		Smalltalk at:aClassName asSymbol put:newClass.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   980
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   981
		(newClass implements:#initialize) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   982
		    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   983
			'initialize newClass ...' infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   984
		    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   985
		    newClass initialize.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   986
		].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   987
		"force cache flush"
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   988
		Smalltalk isInitialized ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   989
		    Smalltalk changed.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   990
		]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   991
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   992
	] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   993
	    'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   994
	    ' did not define itself' errorPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   995
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   996
	     do not unload - could have installed other classes/methods ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   997
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   998
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
   999
	Smalltalk flushCachedClasses.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1000
	^ newClass
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1001
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1002
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1003
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1004
	('no symbol: ', symName,' in ',aFileName) infoPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1005
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1006
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1007
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1008
     unload
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
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1011
	'unloading due to init failure:' infoPrint. handle pathName infoPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1012
    ].
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
    moreHandles notNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1015
	moreHandles do:[:aHandle |
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1016
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1017
		('unloading: ', aHandle printString) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1018
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1019
	    self unloadDynamicObject:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1020
	]
141
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1023
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1024
	('unloading: ', handle printString) infoPrintCR.
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1025
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1026
    self unloadDynamicObject:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1027
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1028
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1029
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1030
     ObjectFileLoader loadClass:'Tetris'      fromObjectFile:'../clients/Tetris/Tetris.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1031
     ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1032
     ObjectFileLoader loadClass:'Foo'         fromObjectFile:'classList.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1033
    "
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  1034
582
9a00e2dbdc97 must flush cached classes after loading (in case of private classes)
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
  1035
    "Modified: 6.7.1997 / 12:34:48 / cg"
141
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
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1038
loadLibrary:aLibraryFileName
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1039
    "load a library; search in some standard places and using
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1040
     standard suffixes (i.e. no suffix should be given in the arg).
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1041
     Returns a handle or nil.
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1042
     Use this to attach C-libraries."
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1043
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1044
    |s suffixes handle libFilename|
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1045
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1046
    libFilename := aLibraryFileName asFilename.
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1047
    (s := libFilename suffix) isEmpty ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1048
	suffixes := self validBinaryExtensions
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1049
    ] ifFalse:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1050
	suffixes := #('')
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1051
    ].
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1052
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1053
    "/ try each suffix ...
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1054
    suffixes do:[:aSuffix | 
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1055
	|fn f|
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1056
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1057
	fn := aLibraryFileName , '.' , aSuffix.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1058
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1059
	(libFilename isAbsolute 
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1060
	or:[(aLibraryFileName startsWith:'./')
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1061
	or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1062
	    f := fn asFilename.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1063
	    f exists ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1064
		handle := self loadObjectFile:fn.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1065
		handle notNil ifTrue:[^ handle].
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1066
	    ]
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1067
	] ifFalse:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1068
	    "/ try each directory    
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1069
	    LoadLibraryPath size > 0 ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1070
		(LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) 
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1071
		do:[:aDir |
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1072
		    f := aDir asFilename construct:fn.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1073
		    f exists ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1074
			handle := self loadObjectFile:f pathName.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1075
			handle notNil ifTrue:[^ handle].
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1076
		    ]
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1077
		]
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1078
	    ].
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1079
	    "/ try to load it by name - maybe someone else knows
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1080
	    "/ how to find it (the system itself)
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1081
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1082
	    handle := self loadObjectFile:fn.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1083
	    handle notNil ifTrue:[^ handle].
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1084
	]
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1085
    ].
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1086
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1087
    ^ nil
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1088
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1089
    "
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1090
     ObjectFileLoader loadLibrary:'libjpeg'
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
  1091
     ObjectFileLoader loadLibrary:'odbc32'
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1092
    "
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1093
845
e9da9bd2bc27 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 841
diff changeset
  1094
    "Modified: / 4.5.1999 / 17:01:47 / cg"
504
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1095
!
850e5886b68e added #loadLibrary.
Claus Gittinger <cg@exept.de>
parents: 478
diff changeset
  1096
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1097
loadMethodObjectFile:aFileName
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1098
    "load an object file (.o-file) for a single method into the image; 
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1099
     This does a slightly different initialization.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1100
     Return an object handle; nil on error"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1101
346
29fe74c22e1e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1102
    |handle initAddr initName m|
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1103
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1104
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1105
    "/ load the objectfile
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1106
    "/
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1107
    handle := self loadDynamicObject:aFileName.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1108
    handle isNil ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1109
	^ nil
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1110
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1111
300
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1112
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1113
    "/ find the entry function
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1114
    "/
e351220115f5 added support to reload function object modules
Claus Gittinger <cg@exept.de>
parents: 291
diff changeset
  1115
    initName := aFileName asFilename withoutSuffix baseName.
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1116
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1117
    initAddr := self getFunction:'__' , initName , '_Init' from:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1118
    initAddr isNil ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1119
	initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1120
	initAddr isNil ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1121
	    (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1122
		self listUndefinedSymbolsIn:handle.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1123
		'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1124
	    ] ifFalse:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1125
		('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1126
	    ].
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1127
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1128
	    "/
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1129
	    "/ not found - unload
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1130
	    "/
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1131
	    self unloadDynamicObject:handle.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1132
	    ^ nil
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1133
	]
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1134
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1135
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1136
    Object osSignalInterruptSignal handle:[:ex |
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1137
	('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1138
	self unloadDynamicObject:handle.
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1139
	^ nil
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1140
    ] do:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1141
	"/
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1142
	"/ call it - it returns the new method object
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1143
	"/
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1144
	m := self
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1145
	    callInitFunctionAt:initAddr 
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1146
	    specialInit:true
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1147
	    forceOld:true 
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1148
	    interruptable:false
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1149
	    argument:2
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1150
	    identifyAs:handle
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1151
	    returnsObject:true.
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1152
    ].
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1153
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1154
    handle method:m.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1155
    ^ handle
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1156
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1157
    "Created: / 5.12.1995 / 20:59:46 / cg"
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1158
    "Modified: / 21.10.1998 / 15:17:31 / cg"
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1159
!
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1160
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1161
loadObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1162
    "load an object file (.o-file) into the image; 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1163
     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
  1164
     This may be either a smalltalk object or a C-object file.
472
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1165
     The object files init function (if any) is called, and the module
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1166
     is unloaded if it returns failure (use lowLevel load, to load a file
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  1167
     without automatic initialization).
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1168
     Return nil on error, an objectFile handle if ok."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1169
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1170
    ^ self
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1171
	loadObjectFile:aFileName 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1172
	invokeInitializeMethods:true
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1173
!
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1174
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1175
loadObjectFile:aFileName invokeInitializeMethods:invokeInitializeMethods
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1176
    "load an object file (.o-file) into the image; 
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1177
     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
  1178
     This may be either a smalltalk object or a C-object file.
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1179
     The object files init function (if any) is called, and the module
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1180
     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
  1181
     without automatic initialization).
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1182
     Return nil on error, an objectFile handle if ok."
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  1183
346
29fe74c22e1e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1184
    |handle initAddr className initNames didInit info status
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1185
     dummyHandle msg isCModule|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1186
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1187
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1188
    handle isNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1189
	Transcript showCR:('failed to load: ' , aFileName).
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1190
	('ObjectFileLoader [warning]: '
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1191
	 , aFileName
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1192
	 , ' failed. ('
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1193
	 , LinkErrorMessage
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1194
	 , ')') errorPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1195
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1196
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1197
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1198
    didInit := false.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1199
    isCModule := false.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1200
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1201
    "/ with dld, load may have worked, even if undefined symbols
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1202
    "/ are to be resolved. If thats the case, load all libraries ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1203
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1204
    SearchedLibraries notNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1205
	(self hasUndefinedSymbolsIn:handle) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1206
	    self initializeLoader.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1207
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1208
	    SearchedLibraries do:[:libName |
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1209
		(self hasUndefinedSymbolsIn:handle) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1210
		    Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1211
		    dummyHandle := Array new:4.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1212
		    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
228
be9939d96cfe removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
  1213
"/                    dummyHandle isNil ifTrue:[
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  1214
"/                        Transcript showCR:'   ... load of library ' , libName , ' failed.'.
228
be9939d96cfe removed a wrong debug message
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
  1215
"/                    ]
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1216
		]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1217
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1218
	    (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1219
		Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.').
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1220
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1221
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1222
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1223
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1224
    "
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1225
     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
  1226
     (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
  1227
      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
  1228
      scheme as well)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1229
    "
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1230
    className := self initFunctionBasenameForFile:aFileName.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1231
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1232
    "/
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1233
    "/ look for explicit init (xxx_Init) function
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1234
    "/ This is used in ST object files
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1235
    "/
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1236
    initAddr := self findInitFunction:className in:handle.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1237
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1238
    initAddr notNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1239
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1240
	    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1241
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1242
	info := self 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1243
		    performModuleInitAt:initAddr 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1244
		    invokeInitializeMethods:invokeInitializeMethods
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1245
		    for:nil
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1246
		    identifyAs:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1247
	status := info at:1.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1248
	status == #ok ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1249
	    didInit := true.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1250
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1251
    ] ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1252
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1253
	"/ look for explicit C-init (xxx__Init) function
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1254
	"/ This is used in C object files
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1255
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1256
	initAddr := self findFunction:className suffix:'__Init' in:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1257
	initAddr notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1258
	    isCModule := true.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1259
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1260
	    Object osSignalInterruptSignal handle:[:ex |
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1261
		('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , aFileName) errorPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1262
		status := #initFailed.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1263
	    ] do:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1264
		(self callInitFunctionAt:initAddr 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1265
		     specialInit:false 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1266
		     forceOld:true 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1267
		     interruptable:false
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1268
		     argument:0
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1269
		     identifyAs:handle
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1270
		     returnsObject:false) < 0 ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1271
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1272
		    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1273
			'init function return failure ... unload' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1274
		    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1275
		    status := #initFailed.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1276
		] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1277
		    didInit := true.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1278
		]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1279
	    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1280
	] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1281
	    status := #noInitFunction.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1282
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1283
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1284
	     look for any init-function(s); call them all
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1285
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1286
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1287
		'no good init functions found; looking for candidates ...' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1288
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1289
	    initNames := self namesMatching:'*_Init' segment:'[tT?]' in:aFileName.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1290
	    initNames notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1291
		initNames do:[:aName |
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1292
		    initAddr := self getFunction:aName from:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1293
		    initAddr isNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1294
			(aName startsWith:'_') ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1295
			    initAddr := self getFunction:(aName copyFrom:2) from:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1296
			].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1297
		    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1298
		    initAddr isNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1299
			Transcript showCR:('no symbol: ',aName,' in ',aFileName).
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1300
		    ] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1301
			Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1302
			    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1303
			].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1304
			self 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1305
			    performModuleInitAt:initAddr 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1306
			    invokeInitializeMethods:invokeInitializeMethods
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1307
			    for:nil 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1308
			    identifyAs:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1309
			didInit := true.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1310
		    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1311
		].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1312
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1313
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1314
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1315
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1316
    didInit ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1317
	status == #noInitFunction ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1318
	    msg := 'LOADER: no init function; assume load ok'
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1319
	] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1320
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1321
	    (status ~~ #registrationFailed 
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1322
	    and:[status ~~ #initFailed 
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1323
	    and:[status ~~ #missingClass 
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1324
	    and:[status ~~ #versionMismatch]]])
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1325
	    ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1326
		self listUndefinedSymbolsIn:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1327
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1328
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1329
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1330
		'unloading, since init failed ...' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1331
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1332
	    self unloadDynamicObject:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1333
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1334
		'unloaded.' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1335
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1336
	    handle := nil.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1337
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1338
	    status == #initFailed ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1339
		msg := 'LOADER: module not loaded (init function signalled failure).'
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1340
	    ] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1341
		status == #missingClass ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1342
		    msg := 'LOADER: module not loaded (superclass missing: ' , (info at:2) , ').'
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1343
		] ifFalse:[
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1344
		    status == #registrationFailed ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1345
			msg :=  'LOADER: module registration failed (incompatible object or missing superclass)'
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1346
		    ] ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1347
			status == #versionMismatch ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1348
			    msg :=  'LOADER: module registration failed (class version mismatch ' , (info at:2) printString , ')'
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1349
			] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1350
			    (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:aFileName) notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1351
				msg := 'LOADER: module not loaded (unknown error reason).'
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1352
			    ] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1353
				msg := 'LOADER: module not loaded (no _Init entry in object file ?).'
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1354
			    ]
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  1355
			]
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1356
		    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1357
		].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1358
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1359
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1360
	Transcript showCR:msg
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1361
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1362
471
508fa84cb122 no init function: assume load ok.
Claus Gittinger <cg@exept.de>
parents: 470
diff changeset
  1363
    isCModule ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1364
	Smalltalk isInitialized ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1365
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1366
	     really dont know, if it has changed ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1367
	     ... but assume, that new classes have been installed.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1368
	    "
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1369
	    Smalltalk changed.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1370
	]
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
  1371
    ].
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1372
    ^ handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1373
790
5ee8cd853bbb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 784
diff changeset
  1374
    "Modified: / 21.10.1998 / 15:19:10 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1375
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1376
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1377
unloadAllObsoleteObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1378
    "unload all dynamically loaded object files for which the classes/method
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1379
     has been already garbage collected."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1380
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1381
    LoadedObjects notNil ifTrue:[
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1382
	LoadedObjects keys copy do:[:name |
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1383
	    |handle|
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1384
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1385
	    handle := LoadedObjects at:name ifAbsent:nil.
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1386
	    (handle notNil and:[handle isObsolete]) ifTrue:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1387
		self unloadObjectFile:name 
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1388
	    ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1389
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1390
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1391
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
     ObjectFileLoader unloadAllObsoleteObjectFiles
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1394
    "
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1395
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1396
    "Modified: 5.12.1995 / 18:16:52 / cg"
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1397
!
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1398
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1399
unloadObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1400
    "unload an object file (.o-file) from the image.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1401
     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
  1402
     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
  1403
     track of these. For now, use at your own risk.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1404
     (especially critical are blocks-functions)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1405
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1406
    |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1407
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1408
    LoadedObjects notNil ifTrue:[
153
90df8e05815c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 151
diff changeset
  1409
	handle := LoadedObjects at:aFileName ifAbsent:nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1410
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1411
    handle isNil ifTrue:[
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  1412
	('OBJFLOADER: oops file to be unloaded was not loaded dynamically (', aFileName , ')') infoPrintCR.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1413
	^ self
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1414
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1415
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1416
    "/ call the modules deInit-function ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1417
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1418
    "/ unload ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1419
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1420
    self unloadDynamicObject:handle
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1421
!
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1422
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1423
unloadObjectFileAndRemoveClasses:aFileName
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1424
    "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
  1425
     corresponding classes from the system.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1426
     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
  1427
     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
  1428
     track of these. For now, use at your own risk.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1429
     (especially critical are blocks-functions)."
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1430
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1431
    |handle|
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1432
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1433
    LoadedObjects notNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1434
	handle := LoadedObjects at:aFileName ifAbsent:nil
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1435
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1436
    handle isNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1437
	('OBJFLOADER: oops file to be unloaded was not loaded dynamically (', (aFileName ? 'unknown-file') , ')') infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1438
	^ self
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1439
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1440
    handle isClassLibHandle ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1441
	self warn:'module is not a classLib module'.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1442
	^ self
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1443
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1444
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1445
    "/ remove the classes ...
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1446
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1447
    Class withoutUpdatingChangesDo:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1448
	handle classes do:[:aClass |
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1449
	    aClass notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1450
		aClass isMeta ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1451
		    aClass removeFromSystem
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1452
		]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1453
	    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  1454
	]
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1455
    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1456
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1457
    "/ call the modules deInit-function ...
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1458
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1459
    "/ unload ...
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1460
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1461
    self unloadDynamicObject:handle
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1462
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1463
    "Modified: / 12.12.1997 / 22:12:28 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1464
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1465
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  1466
!ObjectFileLoader class methodsFor:'dynamic object queries'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1467
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1468
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
  1469
    "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
  1470
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1471
    |initAddr className nm|
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1472
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1473
    "/ care for colons, as found in nameSpace classes ...
747
cd749767d808 use #copyReplaceAll:with:
Claus Gittinger <cg@exept.de>
parents: 741
diff changeset
  1474
    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
  1475
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1476
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1477
     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
  1478
    "
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1479
    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
  1480
    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
  1481
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1482
    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
  1483
    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
  1484
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1485
    "/
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1486
    "/ special for broken ultrix nlist 
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1487
    "/ (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
  1488
    "/ 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
  1489
    "/
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  1490
    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
  1491
    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
  1492
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1493
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1494
     look for reverse abbreviation
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1495
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1496
    className := Smalltalk classNameForFile:functionName.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1497
    className notNil ifTrue:[
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1498
	initAddr := self getFunction:(className , suffix) from:handle.
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1499
	initAddr notNil ifTrue:[^ initAddr].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1500
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1501
	initAddr := self getFunction:('_' , className , suffix) from:handle.
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1502
	initAddr isNil ifTrue:[
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1503
	    "/
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1504
	    "/ special for broken ultrix nlist 
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1505
	    "/ (will not find symbol with single underscore)
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1506
	    "/ workaround: add another underscore and retry
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1507
	    "/
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1508
	    initAddr := self getFunction:('__' , className , suffix) from:handle.
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  1509
	].
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1510
    ].
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1511
    ^ initAddr
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1512
747
cd749767d808 use #copyReplaceAll:with:
Claus Gittinger <cg@exept.de>
parents: 741
diff changeset
  1513
    "Created: / 13.7.1996 / 00:38:01 / cg"
cd749767d808 use #copyReplaceAll:with:
Claus Gittinger <cg@exept.de>
parents: 741
diff changeset
  1514
    "Modified: / 18.7.1998 / 22:59:12 / cg"
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1515
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1516
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1517
findInitFunction:functionName in:handle
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1518
    "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
  1519
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1520
    ^ 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
  1521
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1522
    "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
  1523
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1524
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1525
getFunction:aString from:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1526
    "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
  1527
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1528
     Return the address of the function, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1529
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1530
    ^ self getSymbol:aString function:true from:handle
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1531
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1532
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1533
getListOfUndefinedSymbolsFrom:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1534
    "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
  1535
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1536
     Not all systems allow an object with undefined symbols to be
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1537
     loaded (actually, only dld does)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1538
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1539
    |list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1540
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1541
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1542
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1543
    void (*func)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1544
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1545
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1546
    int nMax;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1547
    char **undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1548
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1549
    undefNames = dld_list_undefined_sym();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1550
    if (dld_undefined_sym_count > 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1551
	char **nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1552
	int index;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1553
	int count = dld_undefined_sym_count;
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
	if (count > 100) count = 100;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1556
	list = __ARRAY_NEW_INT(count);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1557
	if (list) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1558
	    nm = undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1559
	    for (index = 0; index < count; index++) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1560
		OBJ s;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1561
238
4d80cc4b86dd underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 228
diff changeset
  1562
		s = __MKSTRING(*nm);
4d80cc4b86dd underscore cleanup
Claus Gittinger <cg@exept.de>
parents: 228
diff changeset
  1563
		__ArrayInstPtr(list)->a_element[index] = s;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1564
		__STORE(list, s);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1565
		nm++;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1566
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1567
	    free(undefNames);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1568
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1569
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1570
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1571
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1572
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1573
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1574
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1575
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1576
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1577
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1578
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1579
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1580
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1581
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1582
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1583
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1584
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1585
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1586
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1587
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1588
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1589
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1590
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1591
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1592
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1593
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1594
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1595
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1596
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1597
    /*
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1598
     * dont know how to do it
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1599
     */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1600
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1601
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1602
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1603
    /*
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1604
     * dont know how to do it
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1605
     */
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1606
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1607
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1608
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1609
    ^ list
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1610
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1611
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1612
getSymbol:aString function:isFunction from:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1613
    "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
  1614
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1615
     Return the address of the symbol, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1616
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1617
    |sysHandle1 sysHandle2 pathName address|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1618
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1619
    sysHandle1 := aHandle sysHandle1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1620
    sysHandle2 := aHandle sysHandle2.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1621
    pathName := aHandle pathName.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1622
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1623
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1624
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1625
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1626
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1627
    void (*func)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1628
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1629
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1630
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1631
    if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1632
	name = (char *) __stringVal(aString);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1633
	if (isFunction == false) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1634
	    addr = dld_get_symbol(name);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1635
	    if (addr) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1636
		if (@global(Verbose) == true) {
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1637
		    printf("addr of %s = %x\n", name, addr);
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1638
		}
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1639
		address = __MKUINT( addr );
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1640
	    }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1641
	} else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1642
	    func = (void (*) ()) dld_get_func(name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1643
	    if (func) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1644
		if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1645
		    printf("addr of %s = %x\n", name, (INT)func);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1646
		}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1647
		if (dld_function_executable_p(name)) {
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1648
		    address = __MKUINT( (INT)func );
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1649
		} else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1650
		    char **undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1651
		    char **nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1652
		    int i;
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1653
        
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1654
		    if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1655
			printf ("function %s not executable\n", name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1656
			dld_perror("not executable");
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1657
                    
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1658
			printf("undefined:\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1659
			nm = undefNames = dld_list_undefined_sym();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1660
			for (i=dld_undefined_sym_count; i; i--) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1661
			    printf("    %s\n", *nm++);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1662
			}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1663
			free(undefNames);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1664
		    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1665
		}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1666
	    } else {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1667
		if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1668
		    printf ("function %s not found\n", name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1669
		    dld_perror("get_func");
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
	}
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
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1675
#endif /* GNU_DL */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1676
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1677
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1678
  {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1679
    void *h;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1680
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1681
    INT val;
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1682
    FARPROC entry;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1683
    HMODULE handle;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1684
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1685
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1686
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1687
	handle = (HMODULE)(val);
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1688
	if (__isString(aString)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1689
	    if (@global(Verbose) == true)
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1690
		printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle);
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1691
	    entry = GetProcAddress(handle, (char *) __stringVal(aString));
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1692
	    if (entry != NULL) {
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1693
		addr = (void *)entry;
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1694
		if (@global(Verbose) == true) {
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1695
		    printf("GetProcAddr %s ok; addr = %x\n", __stringVal(aString), addr);
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1696
		}
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1697
		address = __MKUINT( (int)addr );
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1698
	    } else {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1699
		if (@global(Verbose) == true) {
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1700
		    printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1701
		}
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1702
	    }
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  1703
	}
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1704
    }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1705
  }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1706
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1707
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1708
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1709
  {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1710
    void *h;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1711
    void *addr;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1712
    INT val;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1713
    void *handle;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1714
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1715
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1716
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1717
	handle = (void *)(val);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1718
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1719
	if (__isString(aString)) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1720
	    if (@global(Verbose) == true)
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1721
		printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1722
	    entry = NULL;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1723
	    get_image_symbol((image_id) handle, (char *) __stringVal(aString), B_SYMBOL_TYPE_TEXT, &entry);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1724
	    if (entry != NULL) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1725
		addr = (void *)entry;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1726
		if (@global(Verbose) == true) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1727
		    printf("get_image_symbol %s ok; addr = %x\n", __stringVal(aString), addr);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1728
		}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1729
		address = __MKUINT( (int)addr );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1730
	    } else {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1731
		if (@global(Verbose) == true) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1732
		    printf("get_image_symbol %s error\n", __stringVal(aString));
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1733
		}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1734
	    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1735
	}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1736
    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1737
  }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1738
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1739
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1740
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1741
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1742
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1743
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1744
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1745
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1746
    if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1747
	if (__isString(sysHandle1)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1748
	    if (@global(Verbose) == true)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1749
		printf("get sym <%s> handle = %x\n",
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1750
			__stringVal(aString), __stringVal(sysHandle1));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1751
	    addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1752
	    if (addr) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1753
		if (@global(Verbose) == true)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1754
		    printf("addr = %x\n", addr);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1755
		address = __MKUINT( (int)addr );
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1756
	    } else {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1757
		if (@global(Verbose) == true)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1758
		    printf("dl_getsymbol %s failed\n", __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1759
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1760
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1761
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1762
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1763
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1764
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1765
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1766
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1767
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1768
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1769
    INT val;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1770
    OBJ low = sysHandle1, hi = sysHandle2;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1771
    extern void *dlsym();
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1772
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1773
    if (__bothSmallInteger(low, hi)) {
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1774
#ifdef alpha64
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1775
	val = (__intVal(hi) << 32) + __intVal(low);
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1776
#else
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1777
	val = (__intVal(hi) << 16) + __intVal(low);
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1778
#endif
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1779
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1780
	if (__isString(aString)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1781
	    if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1782
		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1783
	    }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1784
	    addr = dlsym(h, (char *) __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1785
	    if (addr) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1786
		if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1787
		    printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1788
		}
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1789
		address = __MKUINT( (INT)addr );
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1790
	    } else {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1791
		if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1792
		    printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1793
		}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1794
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1795
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1796
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1797
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1798
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1799
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1800
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1801
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1802
    void *h;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1803
    void *addr;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1804
    INT val, ret;
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1805
    OBJ low = sysHandle1, hi = sysHandle2;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1806
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1807
    if (__bothSmallInteger(low, hi)) {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1808
	val = (_intVal(hi) << 16) + _intVal(low);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1809
	h = (void *)(val);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1810
	if (__isString(aString)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1811
	    if (@global(Verbose) == true) {
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1812
		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1813
	    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1814
	    ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1815
	    if (ret != 0) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1816
		if (@global(Verbose) == true) {
804
0fe603902669 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 801
diff changeset
  1817
		    printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno);
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1818
		}
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1819
	    } else {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1820
		if (@global(Verbose) == true) {
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1821
		    printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1822
		}
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  1823
		address = __MKUINT( (INT)addr );
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1824
	    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1825
	}
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1826
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1827
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1828
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1829
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1830
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1831
#ifdef AIX_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1832
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1833
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1834
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1835
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1836
    struct nlist nl[2];
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1837
    OBJ low = sysHandle1, hi = sysHandle2;
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1838
    char nameBuffer[256];
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1839
    static struct funcDescriptor {
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1840
	unsigned vaddr;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1841
	unsigned long2;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1842
	unsigned long3;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1843
    } descriptor;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1844
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1845
    if (__bothSmallInteger(low, hi)
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1846
     && __isString(aString) && __isString(pathName)) {
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1847
	val = (__intVal(hi) << 16) + __intVal(low);
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1848
	h = (void *)(val);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1849
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1850
	if (@global(Verbose) == true) {
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1851
	    printf("get sym <%s> handle = %x path= %s\n", 
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1852
			__stringVal(aString), h, __stringVal(pathName));
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1853
	}
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1854
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1855
#define USE_ENTRY
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1856
#ifdef USE_ENTRY
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1857
	/*
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1858
	 * only works, if the entry-function is the Init function
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1859
	 * (i.e. linked with -e _xxx_Init)
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1860
	 */
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1861
	if (@global(Verbose) == true) {
858
2697c8300306 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  1862
	    printf("returned handle as addr = %x\n", h);
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1863
	}
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1864
	address = __MKUINT( (int)(h) );
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1865
#else
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1866
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1867
# ifdef USE_DESCRIPTOR
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1868
	if (isFunction == true) {
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1869
# else
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1870
	if (0) {
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1871
# endif
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1872
	    nameBuffer[0] = '.';
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1873
	    strcpy(nameBuffer+1, aString);
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1874
	    nl[0].n_name = nameBuffer;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1875
	} else {
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1876
	    nl[0].n_name = __stringVal(aString);
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1877
	}
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1878
	nl[1].n_name = "";
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1879
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1880
	if (nlist(__stringVal(pathName), &nl) == -1) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1881
	    if (@global(Verbose) == true) {
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1882
		printf("nlist error\n");
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1883
	    }
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1884
	} else {
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1885
	    addr = (void *)((unsigned)nl[0].n_value + (unsigned)h);
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1886
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1887
	    if (isFunction == true) {
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1888
# ifdef USE_DESCRIPTOR
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1889
		printf("daddr = %x\n", addr);
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1890
		printf("daddr[0] = %x\n", ((long *)addr)[0]);
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1891
		printf("daddr[1] = %x\n", ((long *)addr)[1]);
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1892
		printf("daddr[2] = %x\n", ((long *)addr)[2]);
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1893
# endif
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1894
	    }
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1895
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1896
	    if (@global(Verbose) == true) {
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1897
		printf("value=%x section=%d type=%x sclass=%d\n", 
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1898
			nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1899
		printf("vaddr = %x\n", addr);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1900
	    }
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1901
# ifdef DOES_NOT_WORK
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1902
	    address = __MKUINT( (int)addr );
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1903
# else
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1904
	    descriptor.vaddr = (unsigned) addr;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1905
	    descriptor.long2 = 0;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1906
	    descriptor.long3 = 0;
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1907
	    address = __MKUINT( (int)(&descriptor) );
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1908
# endif
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1909
	}
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1910
#endif /* dont USE_ENTRY */
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1911
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1912
  }
321
9428bae4c62e dynamic loading for aix fixed
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
  1913
#endif /* AIX_DL */
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1914
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1915
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1916
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1917
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1918
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1919
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1920
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1921
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1922
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1923
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1924
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1925
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1926
	if (__isString(aString)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1927
	    if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1928
		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1929
	    }
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1930
	    addr = dlsym(h, __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1931
	    if (addr) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1932
		if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1933
		    printf("addr = %x\n", addr);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1934
		}
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1935
		address = __MKUINT( (int)addr );
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1936
	    } else {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1937
		if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1938
		    printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1939
		}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1940
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1941
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1942
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1943
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1944
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1945
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  1946
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1947
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1948
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1949
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1950
    long result;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1951
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1952
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1953
    if (__isString(aString)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1954
	if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1955
	    printf("get sym <%s>\n", __stringVal(aString));
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  1956
	}
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1957
	errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1958
	result = rld_lookup(errOut,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1959
			    (char *) __stringVal(aString),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1960
			    &addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1961
	NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1962
	if (result) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  1963
	    if (@global(Verbose) == true) {
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1964
		printf("addr = %x\n", addr);
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1965
	    }
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1966
	    address = __MKUINT( (int)addr );
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1967
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1968
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1969
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1970
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1971
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1972
%}.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  1973
    ^ address
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1974
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1975
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1976
hasUndefinedSymbolsIn:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  1977
    "return true, if a module has undefined symbols in it.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  1978
     This is only possible if the system supports loading
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  1979
     modules with undefined things in it - most do not"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  1980
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1981
    ^ (self getListOfUndefinedSymbolsFrom:handle) size > 0
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  1982
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  1983
    "Modified: 25.4.1996 / 09:47:27 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1984
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1985
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1986
initFunctionBasenameForFile:aFileName
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1987
    "return the expected initFunctions name, given a fileName"
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1988
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1989
    |name suffixLen|
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1990
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1991
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1992
     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
  1993
    "
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  1994
    name := aFileName asFilename.
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1995
    suffixLen := 0.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  1996
    self validBinaryExtensions do:[:suffix |
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1997
	suffixLen == 0 ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1998
	    (name hasSuffix:suffix) ifTrue:[
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  1999
		suffixLen := suffix size + 1
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2000
	    ]
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2001
	]
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2002
    ].
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  2003
    name := name baseName.
403
43ad163ca9bf solaris changes
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
  2004
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2005
    suffixLen ~~ 0 ifTrue:[
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2006
	name := name copyWithoutLast:suffixLen
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2007
    ].
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2008
    ^ name.
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2009
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2010
    "
514
383c96ae011a More Ultrix changes.
Stefan Vogel <sv@exept.de>
parents: 513
diff changeset
  2011
     ObjectFileLoader initFunctionBasenameForFile:'libbasic.so' 
383c96ae011a More Ultrix changes.
Stefan Vogel <sv@exept.de>
parents: 513
diff changeset
  2012
     ObjectFileLoader initFunctionBasenameForFile:'demo.so' 
383c96ae011a More Ultrix changes.
Stefan Vogel <sv@exept.de>
parents: 513
diff changeset
  2013
     ObjectFileLoader initFunctionBasenameForFile:'demo.o' 
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2014
    "
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2015
784
c8742d9efcb6 suffix fix for systems with caseless filenames
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
  2016
    "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
  2017
    "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
  2018
!
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  2019
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2020
isCPlusPlusObject:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2021
    "return true, if the loaded object is a c++ object module.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2022
     This is not yet fully implemented/supported."
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2023
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2024
    (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
  2025
    (self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2026
    (self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2027
    (self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2028
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2029
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2030
    "Modified: 25.4.1996 / 09:48:19 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2031
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2032
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2033
isObjectiveCObject:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2034
    "return true, if the loaded object is an objective-C object module.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2035
     This is not yet implemented/supported"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2036
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2037
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2038
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2039
    "Modified: 25.4.1996 / 09:47:59 / cg"
141
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2042
isSmalltalkObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2043
    "return true, if the loaded object is a smalltalk object module"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2044
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2045
    "not yet implemented - stc_compiled_smalltalk is a static symbol,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2046
     not found in list - need nm-interface, or nlist-walker
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2047
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2048
    ^ true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2049
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
  2050
"/    (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
  2051
"/    (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
  2052
"/    ^ false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2053
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2054
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2055
listUndefinedSymbolsIn:handle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2056
    "list undefined objects in a module on the transcript"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2057
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2058
    |undefinedNames|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2059
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2060
    undefinedNames := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2061
    undefinedNames size > 0 ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2062
	Transcript showCR:'undefined:'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2063
	undefinedNames do:[:aName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2064
	    Transcript showCR:'    ' , aName
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2065
	]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2066
    ].
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2067
272
04bf9e0c89da showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
  2068
    "Modified: 18.5.1996 / 15:43:45 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2069
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2070
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2071
namesMatching:aPattern segment:segmentPattern in:aFileName
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2072
    "search for entries which match a pattern.
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2073
     This is obsolete & rubbish - it will vanish soon"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2074
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2075
    |p l s addr segment name entry|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2076
766
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2077
    OperatingSystem isVMSlike ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2078
	"/ no nm command
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2079
	^ nil
766
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2080
    ].
d820cda8eee0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
  2081
    OperatingSystem isMSDOSlike ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2082
	"/ no nm command
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2083
	^ nil
609
dfae7c6eea05 vms changes
Claus Gittinger <cg@exept.de>
parents: 592
diff changeset
  2084
    ].
521
3470756b9490 changes for windows
Claus Gittinger <cg@exept.de>
parents: 516
diff changeset
  2085
    OperatingSystem getOSType = 'aix' ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2086
	"/ no useful nm info
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2087
	^ nil
749
86cf38f5a961 win32 change.
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  2088
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2089
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2090
    l := OrderedCollection new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2091
    p := PipeStream readingFrom:(self nm:aFileName).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2092
    p isNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2093
	('ObjectFileLoader [info]: cannot read names from ' , aFileName) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2094
	^ nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2095
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2096
    [p atEnd] whileFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2097
	entry := p nextLine.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2098
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2099
	    entry infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2100
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2101
	entry notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2102
	    s := ReadStream on:entry.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2103
	    addr := s nextAlphaNumericWord.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2104
	    s skipSeparators.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2105
	    segment := s upToSeparator.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2106
	    s skipSeparators.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2107
	    name := s upToEnd withoutSeparators.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2108
	    (addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2109
		(aPattern match:name) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2110
		    (segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2111
			l add:name.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2112
			Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2113
			    ('found name: ' , name) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2114
			]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2115
		    ] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2116
			Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2117
			    name infoPrint. ' segment mismatch ' infoPrint.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2118
			    segmentPattern infoPrint. ' ' infoPrint. segment infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2119
			]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2120
		    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2121
		]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2122
	    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  2123
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2124
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2125
    p close.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2126
    ^ l
225
122d8ff18aff nicer message
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
  2127
749
86cf38f5a961 win32 change.
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  2128
    "Modified: / 27.7.1998 / 20:10:57 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2129
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2130
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2131
releaseSymbolTable
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2132
    "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
  2133
     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
  2134
     On other architectures, this is not needed and therefore a noop."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2135
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2136
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2137
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2138
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2139
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2140
    errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2141
    rld_unload_all(errOut, (long)0);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2142
    rld_load_basefile(errOut, "smalltalk");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2143
    NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2144
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2145
%}
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2146
! !
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2147
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  2148
!ObjectFileLoader class methodsFor:'image save/restart'!
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2149
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2150
invalidateAndRememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2151
    "invalidate code refs into all dynamically loaded object files.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2152
     Required before writing a snapshot image."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2153
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2154
    LoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2155
	ActuallyLoadedObjects := LoadedObjects.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2156
	self rememberAllObjectFiles.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2157
	ActuallyLoadedObjects keys do:[:aFileName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2158
	    |handle|
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2159
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2160
	    handle := ActuallyLoadedObjects at:aFileName.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2161
	    handle isNil ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2162
		self error:'oops, no handle'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2163
	    ] ifFalse:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2164
		(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2165
		    self invalidateModule:handle
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2166
		]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2167
	    ]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2168
	].
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2169
	LoadedObjects := nil.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2170
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2171
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2172
    "Created: 5.10.1995 / 15:48:56 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2173
    "Modified: 5.10.1995 / 16:48:51 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2174
    "Modified: 12.7.1996 / 17:13:45 / cg"
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2175
!
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2176
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2177
reloadAllRememberedObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2178
    "reload all object modules as were loaded when the image was saved.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2179
     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
  2180
406
6a4f1e3800af use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 405
diff changeset
  2181
    |oldDummyMethod who m newHandle 
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2182
     savedOldClasses savedByteCodeMethods savedMethods
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2183
     functions newFunction
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  2184
     saveOldMethodsPerClass anyModulesToInitialize|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2185
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2186
    PreviouslyLoadedObjects notNil ifTrue:[
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2187
        anyModulesToInitialize := false.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2188
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2189
        PreviouslyLoadedObjects do:[:entry |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2190
            |fileName handle cls sel|
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2191
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2192
            fileName := entry key.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2193
            handle := entry value.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2194
            handle moduleID:nil.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2195
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2196
            handle isClassLibHandle ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2197
                ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2198
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2199
                "/
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2200
                "/ remember all byteCode methods (as added in the session)
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2201
                "/                
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2202
                savedByteCodeMethods := Dictionary new.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2203
                savedOldClasses := IdentitySet new.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2204
                saveOldMethodsPerClass := Dictionary new.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2205
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2206
                handle classes do:[:aClass |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2207
                    |clsName mthdDict|
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2208
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2209
                    (aClass notNil and:[aClass ~~ 0]) ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2210
                        clsName := aClass name.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2211
                        mthdDict := aClass methodDictionary.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2212
                        saveOldMethodsPerClass at:clsName put:mthdDict copy.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2213
                        savedMethods := IdentityDictionary new.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2214
                        savedOldClasses add:aClass.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2215
                        mthdDict keysAndValuesDo:[:sel :m |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2216
                            m byteCode notNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2217
                                "/ an interpreted method - must be preserved
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2218
                                savedMethods at:sel put:m
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2219
                            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2220
                        ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2221
                        savedMethods notEmpty ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2222
                            savedByteCodeMethods at:clsName put:savedMethods
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2223
                        ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2224
                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2225
                ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2226
                "/
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2227
                "/ load the class binary
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2228
                "/                
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2229
                handle := self loadObjectFile:fileName invokeInitializeMethods:false.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2230
                handle notNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2231
                    anyModulesToInitialize := true
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2232
                ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2233
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2234
                "/ after reloading of the objectFile,
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2235
                "/ some of the changes made in the previous life have to be
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2236
                "/ redone here - otherwise, we will be left with the
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2237
                "/ state contained in the loaded objectModule - instead of
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2238
                "/ what we had when saving the image ...
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2239
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2240
                "/
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2241
                "/ reinstall the byteCode methods
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2242
                "/                
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2243
                savedByteCodeMethods keysAndValuesDo:[:nm :savedMethods |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2244
                    |cls|
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2245
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2246
                    cls := Smalltalk classNamed:nm.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2247
                    savedMethods keysAndValuesDo:[:sel :m |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2248
                        cls primAddSelector:sel withMethod:m. 
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2249
"/ ('preserved ' , cls name , '>>' , sel) printCR.
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2250
                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2251
                ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2252
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2253
                "/
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2254
                "/ re-remove removed methods
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2255
                "/ and re-change method categories
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2256
                "/
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2257
                savedOldClasses do:[:oldClass |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2258
                    |newClass oldMethods newMethodDict oldMthd newMthd 
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2259
                     oldCat oldClassVarString oldClassCategory|
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2260
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2261
                    newClass := Smalltalk classNamed:(oldClass name).
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2262
                    newClass notNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2263
                        oldClassVarString := oldClass classVariableString.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2264
                        newClass classVariableString ~= oldClassVarString ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2265
                            "/ there is no need to recreate the variable
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2266
                            "/ (its in the smalltalk dictionary)
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2267
                            newClass setClassVariableString:oldClassVarString
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2268
                        ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2269
                        newClass isMeta ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2270
                            oldClassCategory := oldClass category.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2271
                            newClass category ~= oldClassCategory ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2272
                                newClass category:oldClassCategory
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2273
                            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2274
                        ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2275
                        oldMethods := saveOldMethodsPerClass at:oldClass name.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2276
                        newMethodDict := newClass methodDictionary.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2277
                        newMethodDict keys copy do:[:newSelector |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2278
                            (oldMethods includesKey:newSelector) ifFalse:[
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2279
"/                                ('ObjectFileLoader [info]: remove method #' , newSelector , ' from reloaded ' , oldClass name , '.') infoPrintCR.
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2280
                                newMethodDict removeKey:newSelector
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2281
                            ] ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2282
                                oldMthd := oldMethods at:newSelector.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2283
                                newMthd := newMethodDict at:newSelector.
1116
4cadfbecca99 methods send category-change notifications themself
Claus Gittinger <cg@exept.de>
parents: 1033
diff changeset
  2284
                                newMthd category:oldMthd category
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2285
                            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2286
                        ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2287
                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2288
                ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2289
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2290
                "/
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2291
                "/ validate old-classes vs. new classes.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2292
                "/ and if things look ok, get rid of old stuff
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2293
                "/ and make instances become instances of the new class
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2294
                "/
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2295
"/                ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR.
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2296
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2297
                savedOldClasses do:[:oldClass |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2298
                    |newClass oldCat oldCVars|
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2299
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2300
                    newClass := Smalltalk classNamed:(oldClass name).
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2301
                    newClass == oldClass ifTrue:[
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2302
"/                        ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR.
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2303
                    ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2304
                        (newClass isNil or:[newClass == oldClass]) ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2305
                            ('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2306
                        ] ifFalse:[
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2307
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2308
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2309
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2310
                            oldClass instSize ~~ newClass instSize ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2311
                                ('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2312
                            ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2313
                                oldClass class instSize ~~ newClass class instSize ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2314
                                    ('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2315
                                ] ifFalse:[
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2316
"/                                    ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR.
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2317
                                    (oldCat := oldClass category) ~= newClass category ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2318
                                        newClass category:oldCat.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2319
                                    ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2320
                                    (oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2321
                                        newClass setClassVariableString:oldCVars
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2322
                                    ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2323
                                    "/ copy over the oldClasses class-instVars
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2324
                                    (Class instSize + 1) to:(oldClass class instSize) do:[:idx |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2325
                                        newClass instVarAt:idx put:(oldClass instVarAt:idx)
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2326
                                    ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2327
                                    oldClass becomeSameAs:newClass
638
f0ae0eb10226 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
  2328
"/                                    oldClass become:newClass
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2329
                                ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2330
                            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2331
                        ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2332
                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2333
                ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2334
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2335
            ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2336
                handle isMethodHandle ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2337
                    oldDummyMethod := handle method.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2338
                    (oldDummyMethod isKindOf:Method) ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2339
                        ('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2340
                    ] ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2341
                        ('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2342
                        who := oldDummyMethod who.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2343
                        newHandle := self loadMethodObjectFile:fileName.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2344
                        newHandle isNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2345
                            ('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2346
                            handle moduleID:nil.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2347
                        ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2348
                            m := newHandle method.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2349
                            oldDummyMethod sourceFilename notNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2350
                                m sourceFilename:(oldDummyMethod sourceFilename)
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2351
                                  position:(oldDummyMethod sourcePosition).
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2352
                            ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2353
                                m source:(oldDummyMethod source).
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2354
                            ].
1118
01e9dcf336e5 method category: and package: now send change notifications.
Claus Gittinger <cg@exept.de>
parents: 1116
diff changeset
  2355
                            m setPackage:(oldDummyMethod package).
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2356
                            who notNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2357
                                cls := who methodClass.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2358
                                sel := who methodSelector.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2359
                                m == (cls compiledMethodAt:sel) ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2360
                                    'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2361
                                ] ifTrue:[
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2362
"/                                  cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod).
1024
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2363
                                ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2364
                            ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2365
                        ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2366
                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2367
                ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2368
                    handle isFunctionObjectHandle ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2369
                        functions := handle functions.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2370
                        functions isEmpty ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2371
                            ('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2372
                        ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2373
                            newHandle := self loadDynamicObject:fileName.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2374
                            newHandle isNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2375
                                ('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2376
                                handle moduleID:nil.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2377
                            ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2378
                                ('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2379
                                functions do:[:oldFunction |
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2380
                                    newFunction := newHandle getFunction:(oldFunction name).
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2381
                                    newFunction isNil ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2382
                                        ('ObjectFileLoader [info]: function: ''' , oldFunction name , ''' no longer present.') errorPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2383
                                        oldFunction code:nil.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2384
                                        oldFunction setName:oldFunction name moduleHandle:nil.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2385
                                    ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2386
                                        oldFunction code:(newFunction code).
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2387
                                        oldFunction setName:oldFunction name moduleHandle:newHandle.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2388
                                        ('ObjectFileLoader [info]: rebound function: ''' , oldFunction name , '''.') infoPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2389
                                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2390
                                ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2391
                                handle becomeSameAs:newHandle.      "/ the old handle is now void
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2392
                            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2393
                        ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2394
                    ] ifFalse:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2395
                        ('ObjectFileLoader [info]: ignored invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2396
                    ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2397
                ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2398
            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2399
        ].
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2400
        PreviouslyLoadedObjects := nil.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2401
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2402
        "/ now, as we hopefully have all loaded,
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2403
        "/ send #reinitializeAfterLoad to each of them
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2404
        anyModulesToInitialize ifTrue:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2405
            AbortSignal catch:[
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2406
                self moduleInit:4 forceOld:false interruptable:true.
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2407
            ]
10980e29792c do not loose classInstVars when reloading shared libs
tm
parents: 1019
diff changeset
  2408
        ]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2409
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2410
716
3c0668dceb1e dont try to set a metaclasses category when reloading obj-modules.
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
  2411
    "Modified: / 16.5.1998 / 14:23:12 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2412
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2413
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2414
rememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2415
    "remember all loaded objectModules in the
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2416
     PreviouslyLoadedObjects classVariable. 
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2417
     Called when an image is restarted to reload all modules which
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2418
     were loaded in the previous life"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2419
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2420
    LoadedObjects notNil ifTrue:[
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2421
	PreviouslyLoadedObjects := OrderedCollection new.
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2422
	LoadedObjects keysAndValuesDo:[:name :handle |
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2423
	    handle isForCollectedObject ifTrue:[
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2424
		('ObjectFileLoader [info]: ignore object for already collected objects in ' , name) infoPrintCR
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2425
	    ] ifFalse:[
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2426
		PreviouslyLoadedObjects add:(name -> handle)
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2427
	    ]
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2428
	].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2429
	PreviouslyLoadedObjects sort:[:a :b | 
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2430
		|h1 h2|
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2431
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2432
		h1 := a value moduleID.
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2433
		h2 := b value moduleID.
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2434
		h1 isNil 
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2435
		    ifTrue:[true]
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2436
		    ifFalse:[
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2437
			h2 isNil
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2438
			    ifTrue:[false]
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2439
			    ifFalse:[
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2440
				h1 < h2 
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2441
			    ]
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2442
		    ]
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2443
	].
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2444
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2445
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2446
    "Created: 5.12.1995 / 20:51:07 / cg"
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  2447
    "Modified: 10.1.1997 / 15:06:25 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2448
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2449
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2450
revalidateAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2451
    "revalidate code refs into all dynamically loaded object files.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2452
     Required after writing a snapshot image."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2453
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2454
    ActuallyLoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2455
	ActuallyLoadedObjects keys do:[:aFileName |
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2456
	    |handle|
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2457
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2458
	    handle := ActuallyLoadedObjects at:aFileName.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2459
	    handle isNil ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2460
		self error:'oops, no handle'.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2461
	    ] ifFalse:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2462
		(handle isClassLibHandle or:[handle isMethodHandle]) ifTrue:[
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2463
		    self revalidateModule:handle
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2464
		]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2465
	    ]
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2466
	].
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2467
	LoadedObjects := ActuallyLoadedObjects.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2468
	ActuallyLoadedObjects := PreviouslyLoadedObjects := nil.
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2469
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2470
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2471
    "Created: 5.10.1995 / 15:49:08 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2472
    "Modified: 5.10.1995 / 16:49:18 / claus"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2473
    "Modified: 12.7.1996 / 17:14:48 / cg"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2474
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2475
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2476
unloadAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2477
    "unload all dynamically loaded object files from the image.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2478
     see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2479
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2480
    LoadedObjects notNil ifTrue:[
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2481
	LoadedObjects keys copy do:[:aFileName |
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2482
	    self unloadObjectFile:aFileName
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2483
	]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2484
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2485
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2486
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2487
     ObjectFileLoader unloadAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2488
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2489
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2490
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2491
unloadAndRememberAllObjectFiles
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2492
    "remember all modules and unload them"
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2493
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2494
    LoadedObjects notNil ifTrue:[
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2495
	self rememberAllObjectFiles.
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  2496
	self unloadAllObjectFiles
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2497
    ]
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2498
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  2499
    "Modified: 25.4.1996 / 09:46:27 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2500
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2501
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  2502
!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
  2503
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2504
createLoadableObjectFor:baseFileName
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2505
    "given an oFile, arrange for it to be loadable.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2506
     On ELF systems, this means that it has to be linked with the
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2507
     -shared option into a .so file; 
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2508
     DLD based loaders (linux a.out) can directly load a .o file;
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2509
     Other systems may require more ..."
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  2510
513
445a382e8c65 Ultrix support.
Stefan Vogel <sv@exept.de>
parents: 504
diff changeset
  2511
    |osType oFileName soFileName expFileName librunExpFileName
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2512
     needSharedObject ld ldArg expFile ok outfile output libDir|
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2513
750
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2514
    osType := OperatingSystem getOSType.
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2515
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2516
    osType = 'win32' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2517
        self activityNotification:'create def file'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2518
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2519
        "/ create a .def file.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2520
        expFileName := '.\' , baseFileName , '.def'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2521
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2522
        expFile := expFileName asFilename writeStream.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2523
        expFile notNil ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2524
            OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2525
                expFile nextPutLine:'LIBRARY ' , baseFileName.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2526
                expFile nextPutLine:'SEGMENTS'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2527
                expFile nextPutLine:'    INITCODE PRELOAD SHARED'.
780
294b6775c8ab show linker error messages (win32)
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
  2528
"/                expFile nextPutLine:'    INITDATA READ WRITE'.
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2529
                expFile nextPutLine:'EXPORTS'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2530
                expFile nextPutLine:' __' , baseFileName , '_Init'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2531
            ] ifFalse:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2532
                expFile nextPutLine:'LIBRARY ' , baseFileName.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2533
                expFile nextPutLine:'CODE EXECUTE READ SHARED'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2534
                expFile nextPutLine:'DATA READ WRITE'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2535
                expFile nextPutLine:'SECTIONS'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2536
                expFile nextPutLine:' INITCODE READ EXECUTE SHARED'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2537
                expFile nextPutLine:' INITDATA READ WRITE'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2538
                expFile nextPutLine:' RODATA READ SHARED'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2539
                expFile nextPutLine:'EXPORTS'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2540
                expFile nextPutLine:' _' , baseFileName , '_Init'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2541
                expFile nextPutLine:'IMPORTS'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2542
            ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2543
            expFile close.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2544
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2545
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2546
        self activityNotification:'generating shared object'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2547
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2548
        LinkArgs isNil ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2549
            ld := LinkCommand , ' ' , baseFileName , '.obj'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2550
            ld := ld
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2551
               , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2552
               , ' /OUT:' , baseFileName , '.dll '
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2553
               , ' /DEF:' , baseFileName , '.def'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2554
        ] ifFalse:[
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2555
            libDir := '..\libbc'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2556
            libDir asFilename exists ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2557
                libDir := '..\lib\libbc'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2558
                libDir asFilename exists ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2559
                    libDir := '..\lib'.
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2560
                    libDir asFilename exists ifFalse:[
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2561
                        self halt:'oops - need dir where .lib files are'
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2562
                    ]
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2563
                ]
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2564
            ].
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2565
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2566
            OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2567
                ld := LinkCommand , ' ' , (LinkArgs bindWith:baseFileName).
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2568
                ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2569
                ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2570
                ld := ld , (SearchedLibraries asStringCollection asStringWith: $ ).
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2571
                ld := ld , ' ',libDir,'\cs32i.lib,,'.
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2572
            ] ifFalse:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2573
                LastError := 'currently only support borlandC'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2574
                self halt:'currently only support borlandC'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2575
                ^ nil
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2576
            ]
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2577
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2578
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2579
        outfile := (baseFileName , '.out').
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2580
        OperatingSystem isMSWINDOWSNTlike ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2581
            ok := OperatingSystem executeCommand:ld
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2582
        ] ifFalse:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2583
            ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2584
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2585
            ok ifFalse:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2586
                output := (baseFileName , '.out') asFilename contents asString.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2587
                Transcript showCR:output; endEntry.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2588
            ]
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2589
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2590
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2591
        (baseFileName , '.out') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2592
        (baseFileName , '.tds') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2593
        (baseFileName , '.ilc') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2594
        (baseFileName , '.ild') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2595
        (baseFileName , '.ilf') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2596
        (baseFileName , '.ils') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2597
        (baseFileName , '.lib') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2598
        (baseFileName , '.map') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2599
        (baseFileName , '.def') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2600
        (baseFileName , '.obj') asFilename delete.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2601
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2602
        ok ifFalse:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2603
            "/ self halt.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2604
            LastError := output.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2605
            ^ nil
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2606
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2607
        oFileName := (Filename currentDirectory construct:(baseFileName , self sharedLibraryExtension)) name.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2608
        ^ oFileName
750
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2609
    ].
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2610
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2611
    "/ UNIX systems
00bfa36237fb changes for WIN32 - create a .DLL from a .OBJ using LINK
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  2612
324
747e77ce9e57 Fix typo.
Stefan Vogel <sv@exept.de>
parents: 322
diff changeset
  2613
    ld := 'ld'.
188
fef1879d2fcf linux-a.out fixes
ca
parents: 183
diff changeset
  2614
    needSharedObject := false.
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2615
513
445a382e8c65 Ultrix support.
Stefan Vogel <sv@exept.de>
parents: 504
diff changeset
  2616
    osType = 'irix' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2617
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2618
         link it to a shared object with 'ld -shared'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2619
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2620
        needSharedObject := true.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2621
        ldArg := '-shared'.
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2622
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2623
513
445a382e8c65 Ultrix support.
Stefan Vogel <sv@exept.de>
parents: 504
diff changeset
  2624
    osType = 'sys5_4' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2625
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2626
         link it to a shared object with 'ld -G'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2627
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2628
        needSharedObject := true.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2629
        ldArg := '-G'.
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2630
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2631
698
fc359ff36687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  2632
    osType = 'osf' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2633
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2634
         link it to a shared object with 'ld -shared'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2635
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2636
        needSharedObject := true.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2637
        ldArg := '-shared'.
698
fc359ff36687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  2638
    ].
fc359ff36687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  2639
513
445a382e8c65 Ultrix support.
Stefan Vogel <sv@exept.de>
parents: 504
diff changeset
  2640
    osType = 'linux' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2641
        ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2642
            "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2643
             link it to a shared object with 'ld -shared'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2644
            "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2645
            needSharedObject := true.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2646
            ldArg := '-shared'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2647
        ]
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2648
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2649
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2650
    osType = 'solaris' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2651
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2652
         link it to a shared object with 'ld -G -B dynamic'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2653
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2654
        needSharedObject := true.
841
45f929ae2ca0 use 'ld -Bdynamic' instead of 'ld -B dynamic'
Claus Gittinger <cg@exept.de>
parents: 826
diff changeset
  2655
"/        ldArg := '-G -B dynamic'.
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2656
        ldArg := '-G -Bdynamic'.
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2657
    ].
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2658
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2659
    osType = 'hpux' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2660
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2661
         link it to a shared object with 'ld -b -B immediate'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2662
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2663
        needSharedObject := true.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2664
        ldArg := '-b -B immediate'.
722
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2665
    ].
add7cabbd2bb fixed shared-library loading for solaris.
Claus Gittinger <cg@exept.de>
parents: 716
diff changeset
  2666
513
445a382e8c65 Ultrix support.
Stefan Vogel <sv@exept.de>
parents: 504
diff changeset
  2667
    osType = 'aix' ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2668
        self activityNotification:'create export file'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2669
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2670
        "/ create an exports file.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2671
        expFileName := './' , baseFileName , '.exp'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2672
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2673
        expFile := expFileName asFilename writeStream.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2674
        expFile notNil ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2675
            expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2676
            expFile cr.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2677
            expFile nextPutAll:'_' , baseFileName , '_Init'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2678
            expFile close.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2679
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2680
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2681
        self activityNotification:'generating shared object'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2682
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2683
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2684
         link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE'
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2685
        "
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2686
        needSharedObject := true.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2687
        ld := 'cc'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2688
        librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2689
        librunExpFileName isNil ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2690
            LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2691
            ^ nil
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2692
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2693
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2694
        ldArg := '-bI:' , librunExpFileName ,
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2695
                ' -bE:' , baseFileName , '.exp' ,
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2696
                ' -bM:SRE -e _' , baseFileName , '_Init'.
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2697
    ].
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  2698
741
06128261cbf8 more hpux stuff
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  2699
    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
  2700
    needSharedObject ifTrue:[
1014
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2701
        self activityNotification:'generating shared object'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2702
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2703
        soFileName := './' , baseFileName , (self sharedLibraryExtension). 
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2704
        OperatingSystem removeFile:soFileName.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2705
        ld := ld , ' ' , ldArg , ' ', 
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2706
                 (SearchedLibraries asStringCollection asStringWith: $ ), 
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2707
                 ' -o ' , soFileName , ' ' , oFileName.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2708
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2709
        Verbose ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2710
            'linking with:' infoPrintCR.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2711
            '   ' infoPrint. ld infoPrintCR.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2712
        ].         
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2713
        ok := OperatingSystem 
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2714
                executeCommand:(ld , ' >errorOutput 2>&1').
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2715
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2716
        ok ifFalse:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2717
            output := 'errorOutput' asFilename contents asString.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2718
            Transcript showCR:'linker error message:'.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2719
            Transcript showCR:output; endEntry.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2720
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2721
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2722
        OperatingSystem removeFile:oFileName.
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2723
        expFileName notNil ifTrue:[
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2724
            OperatingSystem removeFile:expFileName
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2725
        ].
5a62d96fd129 new cs32i.lib
Claus Gittinger <cg@exept.de>
parents: 1010
diff changeset
  2726
        ^ soFileName. 
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2727
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2728
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2729
    "
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2730
     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
  2731
    "
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2732
    ^ oFileName
698
fc359ff36687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 652
diff changeset
  2733
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  2734
    "Modified: / 10.11.2001 / 01:49:06 / cg"
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2735
! !
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 180
diff changeset
  2736
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2737
!ObjectFileLoader class methodsFor:'lowlevel object loading'!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2738
633
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2739
initializeLoader
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2740
    "initialize dynamic loader if required"
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2741
 
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2742
    |stxName stxPathName|
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2743
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2744
    stxPathName := OperatingSystem pathOfSTXExecutable.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2745
%{
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2746
#ifdef GNU_DL
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2747
  {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2748
    static alreadyInitialized = 0;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2749
    extern dld_ignore_redefinitions;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2750
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2751
    if (! alreadyInitialized) {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2752
	alreadyInitialized = 1;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2753
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2754
	if (@global(Verbose) == true) {
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2755
	    printf ("dld_init(%s)\n", __stringVal(stxPathName));
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2756
	}
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2757
	/*
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2758
	 * dld requires the running executables name,
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2759
	 * to resolve symbols.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2760
	 */
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2761
	(void) dld_init (__stringVal(stxPathName));
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2762
	dld_ignore_redefinitions = 1;
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2763
    }
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2764
  }
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2765
#endif
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2766
%}.
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2767
!
26d6408e9d25 libraryPath handling
Claus Gittinger <cg@exept.de>
parents: 618
diff changeset
  2768
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2769
loadDynamicObject:pathName
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2770
    "load an object-file (load/map into my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2771
     Return a non-nil handle if ok, nil otherwise.
472
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2772
     No bindings or automatic initializations are done 
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2773
     - only a pure (low-level) load is performed.
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2774
     For class-files or C-objects to be loaded with this method,
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2775
     it is your responsibility to fetch any init-functions and
bc81318662b9 comment
Claus Gittinger <cg@exept.de>
parents: 471
diff changeset
  2776
     call them as appropriate.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2777
     This function is not supported on all architectures.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2778
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2779
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2780
    |handle buffer|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2781
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2782
    Verbose ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2783
	('loadDynamic: ' , pathName , ' ...') infoPrintCR
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2784
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2785
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2786
    "/ already loaded ?
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2787
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2788
    LoadedObjects notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2789
	handle := LoadedObjects at:pathName ifAbsent:nil.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2790
	handle notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2791
	    Verbose ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2792
		('... ' , pathName , ' already loaded.') infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2793
	    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2794
	    ^ handle
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2795
	].
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2796
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2797
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2798
    Verbose ifTrue:[
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2799
	('initializeLoader...') infoPrintCR
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2800
    ].
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
  2801
    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
  2802
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2803
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2804
    "/ the 1st two entries are system dependent;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2805
    "/ entry 3 is the pathName
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2806
    "/ entry 4 is a unique ID
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2807
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2808
    buffer := Array new:4.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2809
    buffer at:3 put:pathName.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2810
    buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2811
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2812
    Verbose ifTrue:[
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2813
	('primLoadDynamicObject...') infoPrintCR
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2814
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2815
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2816
    buffer := self primLoadDynamicObject:pathName into:buffer.
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2817
    Verbose ifTrue:[
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2818
	('done') infoPrintCR
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2819
    ].
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2820
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2821
    buffer isNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2822
	LastError == #notImplemented ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2823
	    'ObjectFileLoader [warning]: no dynamic load facility present.' infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2824
	] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2825
	    LastError == #linkError ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2826
		LinkErrorMessage notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2827
		    ('ObjectFileLoader [warning]: load error:' , LinkErrorMessage) infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2828
		] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2829
		    ('ObjectFileLoader [warning]: load error') infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2830
		].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2831
	    ].    
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2832
	    ^ nil
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2833
	]
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2834
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2835
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2836
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2837
     remember loaded object for later unloading
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2838
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2839
    handle := ObjectFileHandle new.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2840
    handle sysHandle1:(buffer at:1).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2841
    handle sysHandle2:(buffer at:2).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2842
    handle pathName:(buffer at:3).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2843
    handle moduleID:(buffer at:4).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2844
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2845
    LoadedObjects isNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2846
	LoadedObjects := Dictionary new.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2847
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2848
    LoadedObjects at:pathName put:handle.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2849
    Smalltalk flushCachedClasses.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2850
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2851
    Verbose ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2852
	('loadDynamic ok; handle is: ' , handle printString) infoPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2853
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2854
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2855
    ^ handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2856
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2857
    "sys5.4:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2858
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2859
     handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2860
     ObjectFileLoader getFunction:'module1' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2861
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2862
    "next:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2863
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2864
     handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2865
     ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2866
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2867
    "GLD:
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2868
     |handle|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2869
     handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2870
     ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2871
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2872
525
3af9e82358b6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 524
diff changeset
  2873
    "Modified: 16.5.1997 / 12:56:33 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2874
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2875
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2876
loadModulesFromListOfUndefined:list
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2877
    "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
  2878
     return a list of handles of loaded objects
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2879
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2880
    |inits classNames|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2881
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2882
    inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2883
    inits notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2884
	classNames := inits collect:[:symbol |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2885
	    (symbol startsWith:'___') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2886
		symbol copyFrom:4 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2887
	    ] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2888
		(symbol startsWith:'__') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2889
		    symbol copyFrom:3 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2890
		] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2891
		    (symbol startsWith:'_') ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2892
			symbol copyFrom:2 to:(symbol size - 5)
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2893
		    ] ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2894
			symbol
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2895
		    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2896
		]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2897
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2898
	].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2899
	"
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2900
	 autoload those classes
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2901
	"
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2902
	classNames do:[:aClassName |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2903
	    |cls|
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2904
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2905
	    (cls := Smalltalk classNamed:aClassName) notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2906
		'ObjectFileLoader [info]: autoloading ' infoPrint. aClassName infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2907
		cls autoload
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2908
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  2909
	]
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
    ^ nil
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2912
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2913
    "Modified: 10.1.1997 / 17:58:23 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2914
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2915
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2916
primLoadDynamicObject:pathName into:anInfoBuffer
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2917
    "load an object-file (map into my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2918
     Return an OS-handle (whatever that is) - where some space
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2919
     (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
  2920
     The first two entries are used in a machine dependent way,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2921
     and callers may not depend on what is found there 
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2922
     (instead, only pass around handles transparently).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2923
     This function is not supported on all architectures."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2924
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2925
%{  /* CALLSUNLIMITEDSTACK(noWIN32) */
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2926
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2927
    if (! __isArray(anInfoBuffer)
646
02b5ea95f888 eliminated some single-underscore macro refs (stringSize, arraySize ...)
Claus Gittinger <cg@exept.de>
parents: 645
diff changeset
  2928
     || (__arraySize(anInfoBuffer) < 3)) {
858
2697c8300306 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
  2929
	RETURN(nil);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2930
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2931
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2932
#ifdef GNU_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2933
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2934
    if (__isString(pathName)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2935
	if (dld_link(__stringVal(pathName))) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  2936
	    if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2937
		printf ("link file %s failed\n", __stringVal(pathName));
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  2938
	    }
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  2939
	    if (@global(ErrorPrinting) == true) {
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  2940
		dld_perror("ObjectFileLoader - DLD error cant link");
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2941
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  2942
	    @global(LastError) = @symbol(linkError);
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  2943
	    @global(LinkErrorMessage) = __MKSTRING("DLD error");
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2944
	    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2945
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2946
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2947
	__STORE(anInfoBuffer, pathName);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2948
	RETURN ( anInfoBuffer );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2949
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2950
    RETURN ( nil );
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
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2953
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2954
#ifdef WIN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2955
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2956
    HINSTANCE handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2957
    int err;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2958
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2959
    if (__isString(pathName)) {
760
c8dd27876bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  2960
	if (@global(Verbose) == true) {
850
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  2961
	    fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  2962
	    fflush(stderr);
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2963
	}
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2964
	handle = LoadLibrary(__stringVal(pathName));
760
c8dd27876bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
  2965
	if (@global(Verbose) == true) {
850
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  2966
	    fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  2967
	    fflush(stderr);
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2968
	}
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  2969
	if (handle == NULL) {
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2970
	    char *msg;
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2971
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2972
	    err = GetLastError();
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  2973
	    if ((@global(ErrorPrinting) == true) 
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  2974
	     || (@global(Verbose) == true)) {
850
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  2975
		fprintf (stderr, 
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  2976
				 "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n", 
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  2977
				 __stringVal(pathName), err);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2978
	    }
779
9301641eafbc set lastErrorNumber if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
  2979
	    @global(LastError) = @symbol(loadError);;
9301641eafbc set lastErrorNumber if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
  2980
	    @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2981
	    switch (err) {
850
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  2982
		case ERROR_BAD_FORMAT:
846
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2983
		    msg = "LoadLibrary error - bad format";
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2984
		default:
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2985
		    msg = "LoadLibrary error";
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2986
		    break;
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2987
	    }
8d1a4228c0e3 win32 error message if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 845
diff changeset
  2988
	    @global(LinkErrorMessage) = __MKSTRING(msg);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2989
	    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2990
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2991
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2992
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2993
	RETURN ( anInfoBuffer );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2994
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2995
    RETURN ( nil );
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
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  2998
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  2999
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3000
  {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3001
    void *handle;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3002
    int err;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3003
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3004
    if (__isString(pathName)) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3005
	if (@global(Verbose) == true) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3006
	    fprintf(stderr, "ObjectFileLoader [info]: loading : %s...\n", __stringVal(pathName));
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3007
	    fflush(stderr);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3008
	}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3009
	handle = load_add_on(__stringVal(pathName));
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3010
	if (@global(Verbose) == true) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3011
	    fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3012
	    fflush(stderr);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3013
	}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3014
	if (handle == NULL) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3015
	    char *msg;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3016
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3017
	    @global(LastError) = @symbol(linkError);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3018
	    @global(LinkErrorMessage) = __MKSTRING("unknown error");
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3019
	    RETURN ( nil );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3020
	}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3021
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3022
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3023
	RETURN ( anInfoBuffer );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3024
    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3025
    RETURN ( nil );
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3026
  }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3027
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3028
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3029
#ifdef DL1_6
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3030
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3031
    extern char *__myName__;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3032
    char *ldname;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3033
    OBJ tmpName;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3034
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3035
    if (__isString(pathName)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3036
	if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3037
	    if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3038
		printf ("link file %s failed\n", __stringVal(pathName));
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3039
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3040
	    @global(LinkErrorMessage) = __MKSTRING("dl_load error");
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3041
	    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3042
	}
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
	 * returns the name of the temporary ld-file
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3045
	 * use that as handle ...
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3046
	 */
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3047
	tmpName = __MKSTRING(ldname);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3048
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3049
	__STORE(anInfoBuffer, tmpName);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3050
	RETURN ( anInfoBuffer );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3051
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3052
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3053
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3054
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3055
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3056
#ifdef AIX_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3057
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3058
    char *objName, *libPath;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3059
    int *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3060
    extern errno;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3061
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3062
    if (__isString(pathName)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3063
	objName = __stringVal(pathName);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3064
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3065
	if (__isString(@global(LibPath))) {
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3066
	    libPath = __stringVal(@global(LibPath));
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3067
	} else {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3068
	    libPath = (char *)0;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3069
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3070
	if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3071
	    if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3072
		char *messages[64];
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3073
		int i;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3074
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3075
		fprintf (stderr, 
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3076
			 "ObjectFileLoader [info]: load file %s failed errno=%d\n", 
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3077
			 objName, errno);
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3078
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3079
		switch (errno) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3080
		    case ENOEXEC:
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3081
			fprintf(stderr, "   load messages:\n");
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3082
			loadquery(L_GETMESSAGES, messages, sizeof(messages));
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3083
			for (i=0; messages[i]; i++) {
782
Claus Gittinger <cg@exept.de>
parents: 780
diff changeset
  3084
			    fprintf(stderr, "      %s\n", messages[i]);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3085
			}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3086
			break;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3087
		}
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3088
	    } else {
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3089
		if (@global(ErrorPrinting) == true) {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3090
		    fprintf (stderr, 
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3091
			     "ObjectFileLoader [warning]: load file %s failed errno=%d\n", 
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3092
			     objName, errno);
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3093
		}
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3094
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3095
	    @global(LinkErrorMessage) = __MKSTRING("load error");
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3096
	    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3097
	}
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3098
	if (@global(Verbose) == true) {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3099
	    fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3100
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3101
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3102
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3103
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3104
	RETURN (anInfoBuffer);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3105
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3106
    RETURN ( nil );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3107
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3108
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3109
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3110
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3111
#ifdef SYSV4_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3112
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3113
    void *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3114
    char *nm;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3115
    char *errMsg;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3116
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3117
    if ((pathName == nil) || __isString(pathName)) {
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3118
	INT lowHandle, hiHandle;
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3119
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3120
	handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3121
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3122
	if (! handle) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3123
	    errMsg = (char *) dlerror();
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3124
	    if (@global(ErrorPrinting) == true) {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3125
		fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3126
		fprintf(stderr, "    <%s>\n", errMsg);
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3127
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3128
	    @global(LastError) = @symbol(linkError);
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3129
	    @global(LinkErrorMessage) = __MKSTRING(errMsg);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3130
	    RETURN (nil);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3131
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3132
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3133
	if (@global(Verbose) == true) {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3134
	    fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %x\n", __stringVal(pathName), handle);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3135
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3136
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3137
#ifdef alpha64
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3138
	lowHandle = (INT)handle & 0xFFFFFFFFL;
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3139
	hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3140
#else
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3141
	lowHandle = (INT)handle & 0xFFFF;
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3142
	hiHandle = ((INT)handle >> 16) & 0xFFFF;
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3143
#endif
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3144
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3145
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3146
	RETURN (anInfoBuffer);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3147
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3148
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3149
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3150
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3151
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3152
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3153
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3154
    void *handle;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3155
    char *nm;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3156
    char *errMsg;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3157
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3158
    if (__isString(pathName)) {
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3159
	handle = (void *)shl_load(__stringVal(pathName), 
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3160
				  BIND_IMMEDIATE, 0L /* address */);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3161
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3162
	if (! handle) {
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3163
	    if (@global(ErrorPrinting) == true) {
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3164
		fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName));
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3165
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3166
	    @global(LastError) = @symbol(linkError);
524
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3167
	    switch (errno) {
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3168
		case ENOEXEC:
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3169
		    errMsg = "not a shared library";
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3170
		    break;
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3171
		case ENOSYM:
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3172
		    errMsg = "undefined symbols";
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3173
		    break;
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3174
		case ENOMEM:
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3175
		    errMsg = "out of memory";
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3176
		    break;
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3177
		case ENOENT:
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3178
		    errMsg = "non existing library";
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3179
		    break;
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3180
		case EACCES:
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3181
		    errMsg = "permission denied";
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3182
		    break;
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3183
		default:
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3184
		    errMsg = "unspecified error";
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3185
		    break;
c92ef4983038 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
  3186
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3187
	    @global(LinkErrorMessage) = __MKSTRING(errMsg);
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3188
	    RETURN (nil);
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3189
	}
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3190
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3191
	if (@global(Verbose) == true) {
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3192
	    printf("open %s handle = %x\n", __stringVal(pathName), handle);
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3193
	}
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3194
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3195
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3196
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3197
	RETURN (anInfoBuffer);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3198
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3199
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3200
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3201
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3202
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3203
#ifdef SUN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3204
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3205
    void *handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3206
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3207
    if ((pathName == nil) || __isString(pathName)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3208
	if (pathName == nil)
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3209
	    handle = dlopen((char *)0, 1);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3210
	else
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3211
	    handle = dlopen(__stringVal(pathName), 1);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3212
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3213
	if (! handle) {
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3214
	    if (@global(ErrorPrinting) == true) {
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3215
		fprintf(stderr, "dlopen %s error: <%s>\n", 
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3216
				__stringVal(pathName), dlerror());
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3217
	    }
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3218
	    @global(LastError) = @symbol(linkError);
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3219
	    @global(LinkErrorMessage) = __MKSTRING("dlopen error");
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3220
	    RETURN (nil);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3221
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3222
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3223
	if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3224
	    printf("open %s handle = %x\n", __stringVal(pathName), handle);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3225
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3226
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3227
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3228
	__ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3229
	RETURN (anInfoBuffer);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3230
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3231
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3232
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3233
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3234
#ifdef NEXT_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3235
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3236
    long result;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3237
    char *files[2];
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3238
    NXStream *errOut;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3239
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3240
    if (__isString(pathName)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3241
	files[0] = (char *) __stringVal(pathName);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3242
	files[1] = (char *) 0;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3243
	errOut = NXOpenFile(2, 2);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3244
	result = rld_load(errOut,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3245
			  (struct mach_header **)0,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3246
			  files,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3247
			  (char *)0);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3248
	NXClose(errOut);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3249
	if (! result) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3250
	    @global(LinkErrorMessage) = __MKSTRING("rld_load error");
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3251
	    @global(LastError) = @symbol(linkError);
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3252
	    if (@global(ErrorPrinting) == true) {
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3253
		fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
515
cbc67d75d9ce make messages depend on global-ErrorPrinting
Claus Gittinger <cg@exept.de>
parents: 514
diff changeset
  3254
	    }
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3255
	    RETURN (nil);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3256
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3257
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3258
	if (@global(Verbose) == true)
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3259
	    printf("rld_load %s ok\n", __stringVal(pathName));
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3260
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3261
	__ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3262
	__STORE(anInfoBuffer, pathName);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3263
	RETURN ( anInfoBuffer );
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3264
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3265
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3266
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3267
%}.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3268
    LastError := #notImplemented.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3269
    ^ nil
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3270
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3271
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3272
primUnloadDynamicObject:aHandle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3273
    "unload an object-file (unmap from my address space).
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3274
     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
  3275
     still any code references (from blocks or methods) to this
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3276
     module. Calling it for still living classes will definitely
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3277
     lead to some fatal conditions to occur later."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3278
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3279
    |sysHandle1 sysHandle2|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3280
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3281
    sysHandle1 := aHandle sysHandle1.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3282
    sysHandle2 := aHandle sysHandle2.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3283
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3284
%{
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3285
#ifdef GNU_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3286
    if (__isString(sysHandle1)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3287
	if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) {
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3288
	    if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3289
		printf ("unlink file %s failed\n", __stringVal(sysHandle1));
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3290
		dld_perror("cant unlink");
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3291
	    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3292
	    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3293
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3294
	RETURN (true);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3295
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3296
    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3297
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3298
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3299
#ifdef WIN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3300
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3301
    HINSTANCE handle;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3302
    int err;
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3303
    jmp_buf exitJmpBuf;
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3304
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3305
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3306
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3307
	handle = (HINSTANCE)(val);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3308
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3309
       if (setjmp(exitJmpBuf)) {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3310
	   __setAtExitLongJmp(exitJmpBuf);
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3311
	    if (FreeLibrary(handle) != TRUE) {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3312
	       __setAtExitLongJmp(0);
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3313
		err = GetLastError();
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3314
		if (@global(Verbose) == true) {
850
316a2bfa5e82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 846
diff changeset
  3315
		    fprintf (stderr,
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3316
				     "ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n",
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3317
				     __stringVal(sysHandle1), err);
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3318
		}
779
9301641eafbc set lastErrorNumber if LoadLibrary fails
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
  3319
		@global(LastErrorNumber) = __WIN32_ERR(err);
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3320
		RETURN (false);
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3321
	    }
771
cd90f9bcefe3 cc & ld arsg for borland;
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  3322
       } else {
778
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3323
	   __setAtExitLongJmp(0);
91628946d932 send messages to stderr
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  3324
	   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
  3325
       }
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3326
	RETURN (true);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3327
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3328
    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3329
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3330
906
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3331
#ifdef BEOS_DL
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3332
    int val;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3333
    void *handle;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3334
    int ok, err;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3335
    jmp_buf exitJmpBuf;
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3336
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3337
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3338
	val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3339
	handle = (HINSTANCE)(val);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3340
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3341
	if (setjmp(exitJmpBuf)) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3342
	    __setAtExitLongJmp(exitJmpBuf);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3343
	    ok = unload_add_on((image_id) handle);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3344
	    __setAtExitLongJmp(0);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3345
	    if (ok != 0) {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3346
		@global(LastErrorNumber) = __MKSMALLINT(ok);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3347
		RETURN (false);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3348
	    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3349
	} else {
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3350
	    __setAtExitLongJmp(0);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3351
	    fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3352
	}
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3353
	RETURN (true);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3354
    }
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3355
    RETURN (false);
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3356
#endif
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  3357
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3358
#ifdef SYSV4_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3359
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3360
    void *h;
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3361
    INT val;
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3362
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3363
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3364
    if (__bothSmallInteger(low, hi)) {
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3365
#ifdef alpha64
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3366
	val = (__intVal(hi) << 32) + __intVal(low);
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3367
#else
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3368
	val = (_intVal(hi) << 16) + _intVal(low);
701
eed963977fee fixed loading for alpha64
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
  3369
#endif
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3370
	h = (void *)(val);
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3371
	if (@global(Verbose) == true)
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3372
	    printf("close handle = %x\n", h);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3373
	if (dlclose(h) != 0) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3374
	    fprintf(stderr, "dlclose failed with:<%s>\n", dlerror());
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3375
	    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3376
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3377
	RETURN (true);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3378
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3379
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3380
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3381
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3382
#ifdef SUN_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3383
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3384
    void *h;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3385
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3386
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3387
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3388
    if (__bothSmallInteger(low, hi)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3389
	val = (_intVal(hi) << 16) + _intVal(low);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3390
	h = (void *)(val);
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3391
	if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3392
	    printf("close handle = %x\n", h);
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3393
	}
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3394
	dlclose(h);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3395
	RETURN (true);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3396
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3397
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3398
#endif
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3399
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3400
#ifdef HPUX10_DL
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3401
  {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3402
    int *h;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3403
    int val;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3404
    OBJ low = sysHandle1, hi = sysHandle2;
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3405
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3406
    if (__bothSmallInteger(low, hi)) {
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3407
	val = (_intVal(hi) << 16) + _intVal(low);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3408
	h = (void *)(val);
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3409
	if (@global(Verbose) == true) {
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3410
	    printf("unload handle = %x\n", h);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3411
	}
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3412
	shl_unload(h);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3413
	RETURN (true);
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3414
    }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3415
  }
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3416
#endif
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3417
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3418
#ifdef AIX_DL
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3419
  {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3420
    int *h;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3421
    int val;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3422
    OBJ low = sysHandle1, hi = sysHandle2;
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3423
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3424
    if (__bothSmallInteger(low, hi)) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3425
	val = (_intVal(hi) << 16) + _intVal(low);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3426
	h = (int *)(val);
592
ac8f79d22665 Use @global.
Stefan Vogel <sv@exept.de>
parents: 591
diff changeset
  3427
	if (@global(Verbose) == true) {
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3428
	    printf("unload handle = %x\n", h);
523
0668c5b4fb94 hpux10 dynamic loading
Claus Gittinger <cg@exept.de>
parents: 521
diff changeset
  3429
	}
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3430
	if ( unload(h) != 0) {
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3431
	    fprintf(stderr, "unload failed\n");
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3432
	    RETURN (false);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3433
	}
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3434
	RETURN (true);
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3435
    }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3436
  }
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3437
#endif
529
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3438
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3439
#ifdef NEXT_DL
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3440
  {
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3441
    fprintf(stderr, "ObjectFileLoader [warning]: Sorry, NeXTStep does not support selective unloading\n");
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3442
  }
039322479f26 NeXTStep cannot unload; send a warning to stderr
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  3443
#endif
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3444
%}.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3445
    ^ false
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3446
!
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3447
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3448
unloadDynamicObject:handle
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3449
    "close an object-file (unmap from my address space)
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3450
     and remove the entry from the remembered object file set.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3451
     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
  3452
     still any code references (from blocks or methods) to this
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3453
     module. Calling it for still living classes will definitely
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3454
     lead to some fatal conditions to occur later."
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3455
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3456
    |key fileName functionName deInitAddr m|
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3457
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3458
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3459
	'unload module name=' infoPrint. handle pathName infoPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3460
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3461
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3462
    handle isUnknownHandle ifTrue:[
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3463
	Verbose ifTrue:[
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3464
	    'module type is not known - assume uninitialized classLib'
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3465
	].
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3466
	self unregisterModule:handle.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3467
	handle makeClassLibHandle.
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3468
    ] ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3469
	handle isClassLibHandle ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3470
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3471
		'a classLib - deinit classes' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3472
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3473
	    self deinitializeClassesFromModule:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3474
	    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3475
		'unregister' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3476
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3477
	    self unregisterModule:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3478
	] ifFalse:[    
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3479
	    handle isMethodHandle ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3480
		Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3481
		    'a methodHandle - unregister' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3482
		].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3483
		self unregisterModule:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3484
	    ] ifFalse:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3485
		handle isFunctionObjectHandle ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3486
		    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3487
			'a functionObject - fixup functionRefs' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3488
		    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3489
		    handle functions do:[:f |
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3490
				    f notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3491
					f code:0
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3492
				    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3493
				].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3494
		].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3495
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3496
		"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3497
		"/ call its deInit function (if present)
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3498
		"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3499
		Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3500
		    'search for deInit function...' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3501
		].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3502
		fileName := handle pathName asFilename baseName.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3503
		functionName := self initFunctionBasenameForFile:fileName.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3504
    
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3505
		deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3506
		deInitAddr notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3507
		    Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3508
			'invoke deInit function...' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3509
		    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3510
		    self callInitFunctionAt:deInitAddr 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3511
			 specialInit:false 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3512
			 forceOld:true 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3513
			 interruptable:false
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3514
			 argument:0
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3515
			 identifyAs:handle
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3516
			 returnsObject:false.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3517
		]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3518
	    ]
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3519
	].
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3520
    ].
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3521
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3522
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3523
	'cleanup done - now unload...' infoPrintCR.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3524
    ].
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
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3527
    "/ now, really unload
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3528
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3529
    (self primUnloadDynamicObject:handle) ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3530
	^ self error:'unloadDynamic failed' mayProceed:true
470
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
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3533
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3534
	'unload done ...' infoPrintCR.
966
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3535
    ].
0da15d671aef proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents: 962
diff changeset
  3536
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3537
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3538
    "/ remove from loaded objects
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3539
    "/
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3540
    LoadedObjects notNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3541
	key := LoadedObjects keyAtEqualValue:handle.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3542
	key notNil ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3543
	    LoadedObjects removeKey:key
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3544
	]
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3545
    ].
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3546
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3547
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3548
     for individual methods, we keep the methodObject,
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3549
     but make it unexecutable. Its still visible in the browser.
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3550
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3551
    handle isMethodHandle ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3552
	((m := handle method) notNil 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3553
	and:[m ~~ 0]) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3554
	    m makeUnloaded.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3555
	]
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3556
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3557
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3558
    handle isClassLibHandle ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3559
	Smalltalk flushCachedClasses.
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3560
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3561
    handle isMethodHandle ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3562
	ObjectMemory flushCaches.
791
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3563
    ].
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3564
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3565
    handle moduleID:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3566
    handle sysHandle1:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3567
    handle sysHandle2:nil.
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3568
655e20eb35d7 flush moduleID and sysHandle when unloading a dynamic object.
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
  3569
    "Modified: / 21.10.1998 / 21:31:48 / cg"
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3570
! !
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3571
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  3572
!ObjectFileLoader class methodsFor:'queries'!
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3573
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3574
canLoadObjectFiles
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  3575
    "return true, if dynamic loading is possible.
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3576
     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
  3577
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3578
    self primCanLoadObjectFiles ifTrue:[^true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3579
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3580
    "/ 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
  3581
    "/ for some specific machine
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3582
    ^ false
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 252
diff changeset
  3583
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3584
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3585
     ObjectFileLoader canLoadObjectFiles
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3586
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3587
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3588
    "Modified: 8.1.1997 / 18:13:01 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3589
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3590
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3591
loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3592
    "return a collection containing the names of all
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3593
     dynamically loaded objects."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3594
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3595
    LoadedObjects isNil ifTrue:[^ #()].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3596
    ^ LoadedObjects keys copy
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3597
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3598
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3599
     ObjectFileLoader loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3600
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3601
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3602
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3603
loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3604
    "return a collection of all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3605
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3606
    LoadedObjects isNil ifTrue:[^ #()].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3607
    ^ LoadedObjects 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3608
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3609
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3610
     ObjectFileLoader loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3611
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3612
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3613
    "Created: 17.9.1995 / 14:28:55 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3614
    "Modified: 17.9.1995 / 16:13:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3615
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3616
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3617
loadedObjectHandlesDo:aBlock
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3618
    "enumerate all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3619
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3620
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3621
	LoadedObjects copy do:aBlock.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3622
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3623
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3624
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3625
     ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3626
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3627
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3628
    "Created: 14.9.1995 / 22:03:13 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3629
    "Modified: 14.9.1995 / 22:32:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3630
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3631
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3632
pathNameFromID:id
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3633
    "given an id, return the pathName, or nil for static modules"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3634
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3635
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3636
	LoadedObjects keysAndValuesDo:[:name :handle |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3637
	    handle moduleID == id ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3638
		^ handle pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3639
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3640
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3641
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3642
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3643
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3644
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3645
     ObjectFileLoader pathNameFromID:1        
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3646
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3647
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3648
    "Modified: 28.8.1995 / 18:08:28 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3649
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3650
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3651
primCanLoadObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3652
    "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
  3653
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3654
%{  /* NOCONTEXT */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3655
#ifdef HAS_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3656
# if !defined(OS_DEFINE) || defined(unknownOS)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3657
    fprintf(stderr, "*** OS_DEFINE not correct\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3658
# else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3659
#  if !defined(CPU_DEFINE) || defined(unknownCPU)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3660
    fprintf(stderr, "*** CPU_DEFINE not correct\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3661
#  else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3662
    RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3663
#  endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3664
# endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3665
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3666
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  3667
    ^ false
470
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3668
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3669
    "
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3670
     ObjectFileLoader primCanLoadObjectFiles
2994a91156e0 category changes; added comments.
Claus Gittinger <cg@exept.de>
parents: 469
diff changeset
  3671
    "
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  3672
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  3673
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  3674
!ObjectFileLoader class methodsFor:'st object file handling'!
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3675
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3676
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
  3677
    "call a function at address - a very dangerous operation.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3678
     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
  3679
     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
  3680
     ForceOld (if true) will have the memory manager
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3681
     allocate things in oldSpace instead of newSpace.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3682
     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
  3683
     otherwise, its called without arguments.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3684
     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
  3685
     install all of its classes) or for a single incrementally compiled methdod
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3686
     (it should then NOT install it, but return the method object instead).
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3687
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3688
     DANGER: Internal & highly specialized. Dont use in your programs.
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3689
             This interface may change without notice."
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3690
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3691
    |moduleID retVal oldSpaceReserve|
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3692
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3693
    handle notNil ifTrue:[
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3694
        moduleID := handle moduleID
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3695
    ].
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3696
    "/
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3697
    "/ 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
  3698
    "/ must be allocated in oldSpace when coming from a compiled
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3699
    "/ classLibrary, and no compressing grabage collect is allowed during
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3700
    "/ 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
  3701
    "/ 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
  3702
    "/ (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
  3703
    "/
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3704
    oldSpaceReserve := OldSpaceReserve ? (1024*1024).
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3705
1033
f5bad5027056 More Stack when calling init function.
Stefan Vogel <sv@exept.de>
parents: 1024
diff changeset
  3706
%{  /* CALLSSTACK: 128000 */
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3707
    OBJ (*addr)();
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3708
    int savInt;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3709
    int prevSpace, force;
591
9c48953d9fab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 590
diff changeset
  3710
    INT arg = 0, ret = 0;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3711
    int wasBlocked = 1;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3712
    extern int __oldSpaceSize(), __oldSpaceUsed();
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3713
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  3714
    if (__isInteger(address)) {
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3715
        if (_isSmallInteger(argument)) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3716
            arg = __intVal(argument);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3717
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3718
            addr = (OBJFUNC)(__longIntVal(address));
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3719
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3720
            /*
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3721
             * allow function to be interrupted
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3722
             */
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3723
            if (interruptable != true) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3724
                wasBlocked = (__BLOCKINTERRUPTS() == true);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3725
            }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3726
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3727
            force = (forceOld == true);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3728
            if (force) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3729
                int reserve = __intVal(oldSpaceReserve);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3730
                if ((__oldSpaceSize() - __oldSpaceUsed()) < reserve) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3731
                    __moreOldSpace(__thisContext, reserve);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3732
                } 
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3733
                prevSpace = __allocForceSpace(OLDSPACE);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3734
            }
468
b56afb940e6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3735
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  3736
#ifdef alpha
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3737
            if (@global(Verbose) == true)
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3738
                printf("calling initfunc %lx ...\n", addr);
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  3739
#else
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3740
            if (@global(Verbose) == true)
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3741
                printf("calling initfunc %x ...\n", addr);
759
fd7e1e42a6a0 changes for WIN32
Claus Gittinger <cg@exept.de>
parents: 750
diff changeset
  3742
#endif
1018
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3743
            if (special == true) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3744
                if (__isSmallInteger(moduleID)) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3745
                    __SET_MODULE_ID(__intVal(moduleID));
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3746
                }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3747
                retVal = (*addr)(arg, __pRT__);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3748
                __SET_MODULE_ID(0);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3749
                if (returnsObject != true) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3750
                    retVal = nil;
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3751
                }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3752
            } else {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3753
                if (returnsObject == true) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3754
                    retVal = (*addr)(arg);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3755
                } else {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3756
                    ret = (int) ((*addr)(arg));
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3757
                    retVal = __MKSMALLINT(ret);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3758
               }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3759
            }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3760
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3761
            if (force) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3762
                __allocForceSpace(prevSpace);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3763
            }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3764
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3765
            if (! wasBlocked) {
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3766
                __UNBLOCKINTERRUPTS();
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3767
            }
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3768
            RETURN (retVal);
011f0c9fa19d more oldSpace reserve (also a classVar to allow for dynamic change)
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  3769
        }
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3770
    }
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3771
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3772
    self primitiveFailed
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3773
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3774
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3775
deinitializeClassesFromModule:handle
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  3776
    "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
  3777
     to all classes of a module."
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3778
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3779
    |classes|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3780
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3781
    classes := handle classes.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3782
    classes notNil ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3783
	classes do:[:aClass |
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3784
	    aClass notNil ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3785
		aClass isMeta ifFalse:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3786
		    Verbose ifTrue:[
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3787
			'send #deinitialize to:' infoPrint. aClass name infoPrintCR.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3788
		    ].
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3789
		    aClass deinitialize.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3790
		    aClass update:#aboutToUnload with:nil from:self
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3791
		]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3792
	    ]
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3793
	]
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3794
    ]
307
2552fd5e8592 give cModule a chance to signal failure (return -1 from __Init);
Claus Gittinger <cg@exept.de>
parents: 306
diff changeset
  3795
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3796
    "Modified: 10.1.1997 / 17:56:50 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3797
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3798
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3799
invalidateModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3800
    "invalidate all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3801
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3802
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3803
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3804
    Verbose ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3805
	'invalidate module; name=' infoPrint. handle pathName infoPrint.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  3806
	' id=' infoPrint. handle moduleID infoPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3807
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3808
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3809
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3810
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3811
    __INVALIDATE_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3812
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3813
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3814
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3815
loadStatusFor:className
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3816
    "ask VM if class-hierarchy has been completely loaded, and return the status."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3817
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3818
    |checker checkSymbol statusCode status badClassName|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3819
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3820
    checker := self.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3821
    checkSymbol := #'superClassCheck:'.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3822
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3823
%{  /* NOREGISTER */
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3824
    char *badName;
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
  3825
    char *interestingClassName;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3826
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3827
    if (__isString(className) || __isSymbol(className)) {
587
5250b6d10925 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
  3828
	interestingClassName = (char *)__stringVal(className);
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3829
    } else {
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
  3830
	interestingClassName = (char *)0;
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3831
    }
365
22c85186e799 Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 346
diff changeset
  3832
    statusCode = __MKSMALLINT(__check_registration__(interestingClassName,
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3833
						     &checker, &checkSymbol, &badName));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3834
    if (badName) {
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3835
	badClassName = __MKSTRING(badName);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3836
    }
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3837
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3838
    statusCode == 0 ifTrue:[
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3839
	status := #ok
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3840
    ] ifFalse:[ statusCode == -1 ifTrue:[
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3841
	status := #missingClass
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3842
    ] ifFalse:[ statusCode == -2 ifTrue:[
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3843
	status := #versionMismatch
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3844
    ] ifFalse:[ statusCode == -3 ifTrue:[
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3845
	status := #unregisteredSuperclass
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3846
    ] ifFalse:[ statusCode == -4 ifTrue:[
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3847
	status := #tryAgain
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3848
    ] ifFalse:[
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3849
	status := #loadFailed
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3850
    ] ] ] ] ].
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3851
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3852
    ^ Array with:status with:badClassName.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3853
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3854
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3855
moduleInit:phase forceOld:forceOld interruptable:interruptable
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3856
    "initialization phases after registration.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3857
     DANGER: Pure magic; internal only -> dont use in your programs."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3858
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3859
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3860
    int savInt;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3861
    int prevSpace, force;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3862
    int arg = 0;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3863
    int wasBlocked = 1;
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3864
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3865
    if (_isSmallInteger(phase)) {
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3866
	if (interruptable != true) {
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3867
	    wasBlocked = (__BLOCKINTERRUPTS() == true);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3868
	}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3869
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3870
	force = (forceOld == true);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3871
	if (force) {
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3872
	    prevSpace = __allocForceSpace(OLDSPACE);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3873
	}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3874
345
3727b0b6f62f removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  3875
	__init_registered_modules__(__intVal(phase));
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3876
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3877
	if (force) {
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3878
	    __allocForceSpace(prevSpace);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3879
	}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3880
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3881
	if (! wasBlocked) {
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3882
	    __UNBLOCKINTERRUPTS();
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
	RETURN (self);
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3885
    }
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3886
%}.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3887
    self primitiveFailed
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3888
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3889
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3890
performModuleInitAt:initAddr for:className identifyAs:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3891
    "Initialize a loaded smalltalk module."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3892
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  3893
    ^ self
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3894
	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
  3895
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  3896
!
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  3897
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  3898
performModuleInitAt:initAddr invokeInitializeMethods:invokeInitializeMethods for:className identifyAs:handle
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  3899
    "Initialize a loaded smalltalk module."
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  3900
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3901
    |status badClassName infoCollection info classNames classes
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3902
     stillTrying|
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3903
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3904
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3905
     need 4 passes to init: 0: let module register itself & create its pools/globals
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3906
			    0b check if modules superclasses are all loaded
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3907
			    1: let it get var-refs to other pools/globals
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3908
			    2: let it install install class, methods and literals
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3909
			    3: let it send #initialize to its class object
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3910
    "
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3911
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3912
    stillTrying := true.
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3913
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3914
    [stillTrying] whileTrue:[
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3915
	stillTrying := false.
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3916
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3917
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3918
	"/ let it register itself
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3919
	"/ and define its globals
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3920
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3921
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3922
	    'phase 0 (module registration) ...' infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3923
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3924
	self callInitFunctionAt:initAddr 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3925
	     specialInit:true 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3926
	     forceOld:true 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3927
	     interruptable:false
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3928
	     argument:0
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3929
	     identifyAs:handle
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3930
	     returnsObject:false.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3931
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3932
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3933
	"/ check if superclasses are present
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3934
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3935
	info := self loadStatusFor:className.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3936
	status := info at:1.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3937
	badClassName := info at:2.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3938
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3939
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3940
	    '... status is ' infoPrint. info infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3941
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3942
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3943
	(status ~~ #ok) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3944
	    (status == #missingClass) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3945
		('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3946
		^ info
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3947
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3948
	    (status == #versionMismatch) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3949
		('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3950
		^ info
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3951
	    ].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3952
	    (status == #unregisteredSuperclass) ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3953
		('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3954
		^ info
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3955
	    ].
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3956
	    (status ~~ #tryAgain) ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3957
		'ObjectFileLoader [error]: load failed' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3958
		^ Array with:#loadFailed with:nil
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3959
	    ].
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3960
	    (status == #tryAgain) ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3961
		"/ tryAgain:
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3962
		"/   must retry after initialization, to initialize
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3963
		"/   sub-subclasses of autoloaded classes
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3964
		"/   (sigh - class objects are created in phase 3,
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3965
		"/    so we must first complete the initialization cycle,
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3966
		"/    then do all again, for remaining modules)
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3967
		stillTrying := true.
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3968
		'ObjectFileLoader [info]: retry registration after init' infoPrintCR.
972
3ae444a1a816 better diagnostics / revalidate after autoload during classLib loading
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
  3969
	    ]
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3970
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3971
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3972
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3973
	"/ remaining initialization
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3974
	"/
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3975
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3976
	"/ module exports: declare module-globals & symbols ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3977
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3978
	    'phase 1 (resolve globals) ...' infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3979
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3980
	self moduleInit:1 forceOld:true interruptable:false.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3981
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3982
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3983
	"/ module-imports: resolve globals ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3984
	"/ create methods & install ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3985
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3986
	    'phase 2 (create objects) ...' infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3987
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3988
	self moduleInit:2 forceOld:true interruptable:false.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3989
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3990
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3991
    ObjectMemory flushCaches.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3992
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3993
    "/ ask objectMemory for the classes we have just loaded
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3994
    "/ and register them in the handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3995
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3996
    infoCollection := ObjectMemory binaryModuleInfo.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3997
    info := infoCollection at:handle moduleID ifAbsent:nil.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  3998
    info isNil ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  3999
	"/ mhmh registration failed -
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4000
	'ObjectFileLoader [error]: registration failed' infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4001
	^ Array with:#registrationFailed with:nil
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4002
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4003
405
92cb91b82cf7 changes for new moduleInfo reply
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
  4004
    classNames := info classNames.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4005
    classNames size > 0 ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4006
	classes := classNames collect:[:nm | Smalltalk classNamed:nm].
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4007
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4008
    classes size > 0 ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4009
	classes := classes asArray.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4010
	classes := classes , (classes collect:[:aClass | aClass class]).
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4011
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4012
    handle classes:classes.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4013
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4014
    invokeInitializeMethods ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4015
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4016
	    'phase 3 (send #initialize) ...' infoPrintCR
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4017
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4018
	"/ initialize ...
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4019
	self moduleInit:3 forceOld:false interruptable:true.
916
a04d8cad48d8 when reloading object modules after snapIn,
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
  4020
    ].
881
ed4efb1b161e perform moduleInit3 AFTER registering the module.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
  4021
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4022
    ^ Array with:#ok with:nil
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4023
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4024
    "Modified: 10.1.1997 / 17:58:41 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4025
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4026
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4027
revalidateModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4028
    "revalidate all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4029
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4030
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4031
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4032
    Verbose ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4033
	'revalidate module; name=' infoPrint. handle pathName infoPrint.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4034
	' id=' infoPrint. handle moduleID infoPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4035
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4036
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4037
    id := handle moduleID.
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
    __REVALIDATE_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4040
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4041
!
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
superClassCheck:aClass
320
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  4044
    "callBack from class registration code in VM: 
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  4045
     make certain, that aClass is loaded too ...
54bfd6fd28b9 removed old obsolete manual loader; aix fixes
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
  4046
     (req'd if a subclass of an autoloaded class has been loaded)"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4047
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4048
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4049
	'checkCall for:' infoPrint. aClass name infoPrint. ' -> ' infoPrint.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4050
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4051
    aClass isBehavior ifFalse:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4052
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4053
	    'false' infoPrintCR. 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4054
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4055
	'ObjectFileLoader [warning]: check failed - no behavior' errorPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4056
	^ false
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4057
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4058
    Verbose ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4059
	'true' infoPrintCR. 
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4060
	('ObjectFileLoader [info]: check for ' , aClass name , ' being loaded') infoPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4061
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4062
    aClass autoload.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4063
    (aClass isBehavior and:[aClass isLoaded]) ifTrue:[
1010
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4064
	Verbose ifTrue:[
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4065
	    ('ObjectFileLoader [info]: ok, loaded. continue registration of actual class') infoPrintCR.
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4066
	].
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4067
	aClass signature.       "/ req'd in VM for validation
46287addc332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1007
diff changeset
  4068
	^ true
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4069
    ].
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  4070
    ('ObjectFileLoader [warning]: superclass not loaded; registration of ' , aClass name , ' fails') errorPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4071
    ^ false
474
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
  4072
477
5208c65a2b3d newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4073
    "Modified: 10.1.1997 / 17:58:48 / cg"
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4074
!
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4075
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4076
unregisterModule:handle
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4077
    "unregister classes in the VM.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4078
     This invalidates all of the classes code objects ..."
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4079
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4080
    |id|
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4081
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4082
    Verbose ifTrue:[
634
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4083
	'unregister module; name=' infoPrint. handle pathName infoPrint.
91490b70007e added unload&removeClasses
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  4084
	' id=' infoPrint. handle moduleID infoPrintCR.
303
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4085
    ].
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4086
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4087
    id := handle moduleID.
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4088
%{
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4089
    __UNREGISTER_BY_ID(__intVal(id));
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4090
%}
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4091
! !
989a7899b0e7 category changes
Claus Gittinger <cg@exept.de>
parents: 300
diff changeset
  4092
369
65d9c12fa6b8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
  4093
!ObjectFileLoader class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4094
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4095
version
1217
61cca5c6d4d1 link flag setup (win32)
Claus Gittinger <cg@exept.de>
parents: 1175
diff changeset
  4096
    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.221 2001-11-10 00:52:40 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  4097
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  4098
ObjectFileLoader initialize!