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