ObjectFileLoader.st
author Claus Gittinger <cg@exept.de>
Tue, 26 Dec 1995 19:43:21 +0100
changeset 180 a38d34ef8bde
parent 178 7342b41b7fe7
child 182 b8316f207380
permissions -rw-r--r--
dynamic load works on NT !
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
3dc42a5ab417 default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    17
		SearchedLibraries'
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    18
	poolDictionaries:''
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
    19
	category:'System-Compiler'
47
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    20
!
f861ad42703e *** empty log message ***
claus
parents: 45
diff changeset
    21
53
c5dd7abf8431 *** empty log message ***
claus
parents: 51
diff changeset
    22
!ObjectFileLoader primitiveDefinitions!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    23
%{
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    24
/*
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    25
 * by default, use whatever the system provides
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    26
 */
95
claus
parents: 94
diff changeset
    27
#ifdef sunos    /* sunos (pre 5.4) dlopen interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    28
# define SUN_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    29
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    30
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    31
95
claus
parents: 94
diff changeset
    32
#ifdef NeXT     /* next rld interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    33
# define NEXT_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    34
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    35
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    36
95
claus
parents: 94
diff changeset
    37
#ifdef SYSV4    /* sys5.4 dlopen interface */
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    38
# define SYSV4_DL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    39
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    40
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    41
95
claus
parents: 94
diff changeset
    42
#ifdef DL1_6    /* dl1.6 COFF loader */
claus
parents: 94
diff changeset
    43
# define HAS_DL
claus
parents: 94
diff changeset
    44
#endif
claus
parents: 94
diff changeset
    45
98
claus
parents: 97
diff changeset
    46
#ifdef _AIX
97
claus
parents: 96
diff changeset
    47
# define AIX_DL
claus
parents: 96
diff changeset
    48
# define HAS_DL
claus
parents: 96
diff changeset
    49
#endif
claus
parents: 96
diff changeset
    50
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    51
/*
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    52
 * but GNU_DL overwrites this - its better
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    53
 */
95
claus
parents: 94
diff changeset
    54
#ifdef GNU_DL   /* dld2.3.x interface */
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    55
# define HAS_DL
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    56
# undef SYSV4_DL
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    57
# undef NEXT_DL
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    58
# undef SUN_DL
95
claus
parents: 94
diff changeset
    59
# undef DL1_6
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    60
#endif
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
    61
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    62
#include <stdio.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    63
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    64
#if defined(WIN32)
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    65
# undef COFF
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    66
# undef ELF
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    67
# undef A_DOT_OUT
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    68
# define HAS_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
    69
# define WIN_DL
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    70
#endif
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    71
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    72
/*
95
claus
parents: 94
diff changeset
    73
 * if no dynamic link facilities, try it the hard way ...
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    74
 */
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    75
#if !defined(HAS_DL)
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    76
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    77
# ifdef A_DOT_OUT
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    78
#  include <a.out.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    79
#  ifndef N_MAGIC
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    80
#   if defined(sinix) && defined(BSD)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    81
#    define N_MAGIC(hdr) (hdr.a_magic & 0xFFFF)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    82
#   else
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    83
#    define N_MAGIC(hdr) (hdr.a_magic)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    84
#   endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    85
#  endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    86
# endif /* a.out */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    87
 
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    88
# ifdef COFF
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    89
#  ifdef mips
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    90
#    include <sys/exec.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    91
#  else
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    92
#    include <a.out.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    93
#  endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    94
# endif /* coff */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    95
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    96
# ifdef ELF
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    97
#  include <elf.h>
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    98
# endif /* elf */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    99
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   100
#endif /* not HAS_DL */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   101
95
claus
parents: 94
diff changeset
   102
#ifdef NEXT_DL
claus
parents: 94
diff changeset
   103
# ifndef _RLD_H_
claus
parents: 94
diff changeset
   104
#  define _RLD_H_
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   105
#  ifdef NEXT3
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   106
#   include <mach-o/rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   107
#  else
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   108
#   include <rld.h>
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   109
#  endif
95
claus
parents: 94
diff changeset
   110
# endif
claus
parents: 94
diff changeset
   111
#endif /* NEXT_DL */
claus
parents: 94
diff changeset
   112
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   113
#ifdef SYSV4_DL
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   114
# include <dlfcn.h>
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   115
# define dlcfn_h
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   116
#endif
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
   117
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   118
#ifdef GNU_DL
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   119
#  ifndef dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   120
#   include "dld.h"
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   121
#   define dld_h
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   122
#  endif
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   123
#endif
95
claus
parents: 94
diff changeset
   124
claus
parents: 94
diff changeset
   125
#ifdef DL1_6
claus
parents: 94
diff changeset
   126
#  ifndef dl_h
claus
parents: 94
diff changeset
   127
#   include "dl.h"
claus
parents: 94
diff changeset
   128
#   define dl_h
claus
parents: 94
diff changeset
   129
#  endif
claus
parents: 94
diff changeset
   130
#endif
claus
parents: 94
diff changeset
   131
97
claus
parents: 96
diff changeset
   132
#ifdef AIX_DL
claus
parents: 96
diff changeset
   133
# include <nlist.h>
100
claus
parents: 98
diff changeset
   134
# include <sys/ldr.h>
claus
parents: 98
diff changeset
   135
# include <errno.h>
97
claus
parents: 96
diff changeset
   136
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   137
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   138
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   139
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   140
# ifdef WIN32
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   141
#   undef INT
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   142
#   undef Array
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   143
#   undef Number
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   144
#   undef Method
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   145
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   146
#   ifdef i386
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   147
#    define _X86_
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   148
#   endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   149
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   150
/* #  include <windows.h> /* */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   151
#  include <windef.h> /* */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   152
#  include <winbase.h> /* */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   153
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   154
#   ifdef DEF_Array
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   155
#    define Array DEF_Array
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   156
#   endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   157
#   ifdef DEF_Number
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   158
#    define Number DEF_Number
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   159
#   endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   160
#   ifdef DEF_Method
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   161
#    define Method DEF_Method
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   162
#   endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   163
# endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   164
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   165
#endif
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   166
%}
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   167
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   168
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   169
!ObjectFileLoader class methodsFor:'documentation'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   170
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   171
copyright
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   172
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   173
 COPYRIGHT (c) 1993 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   174
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   175
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   176
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   177
 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
   178
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   179
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   180
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   181
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   182
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   183
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   184
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   185
documentation
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   186
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   187
    This class knowns how to dynamically load in external object-modules.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   188
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   189
    WARNING:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   190
      As to date, this is completely experimental and WITHOUT ANY WARRANTY.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   191
      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
   192
      robustness.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   193
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   194
    There are basically two totally different mechanisms to do this:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   195
	a) if there exists some dynamic-link facility such as:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   196
	   GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   197
	   this is used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   198
	b) if no such facility exists, the normal linker is used to
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   199
	   link the module to text/data address as previously malloced,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   200
	   and the object file loaded into that space.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   201
           
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   202
    Currently, not all mechanisms work fully satisfying.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   203
    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
   204
    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
   205
    allow for selective unloading (only all or last).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   206
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   207
    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
   208
    sys5.4 libdl packages. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   209
    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
   210
    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
   211
    For the above reasons, dynamic object loading is currently only
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   212
    officially released for SYS5.4 and LINUX systems.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   213
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   214
    Once stable, the functionality contained herein will be moved into
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   215
    the VM. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   216
    (It is needed there, to allow reloading of objectfiles upon
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   217
     image restart; i.e. before any class is reinitialilized).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   218
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   219
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   220
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   221
!ObjectFileLoader class methodsFor:'initialization'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   222
7ad01559b262 Initial revision
claus
parents:
diff changeset
   223
initialize
7ad01559b262 Initial revision
claus
parents:
diff changeset
   224
    "name of object file, where initial symbol table is found"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   225
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
   226
    MySymbolTable := 'smalltalk'.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
   227
    Verbose := false.
106
claus
parents: 103
diff changeset
   228
    NextHandleID := 1.
107
claus
parents: 106
diff changeset
   229
    ObjectMemory addDependent:self.
149
3dc42a5ab417 default for SearchedLibraries
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   230
    SearchedLibraries := #().
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   231
    OperatingSystem getSystemType = 'linux' ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   232
	'/usr/lib/libc.a' asFilename isReadable ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   233
	    SearchedLibraries := #('/usr/lib/libc.a')
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   234
	]
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   235
    ].
107
claus
parents: 106
diff changeset
   236
claus
parents: 106
diff changeset
   237
    "
claus
parents: 106
diff changeset
   238
     ObjectFileLoader initialize
claus
parents: 106
diff changeset
   239
    "
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   240
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   241
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   242
lastError
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   243
    ^ LastError
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   244
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   245
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   246
linkErrorMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   247
    ^ LinkErrorMessage
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
searchedLibraries
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   251
    "see comment in #searchedLibraries:"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   252
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   253
    ^ SearchedLibraries
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   254
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   255
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   256
searchedLibraries:aCollectionOfArchivePathNames
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   257
    "set the pathnames of archives which are to be searched
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   258
     when unresolved references occur while loading in an object
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   259
     file. On systems which support shared libraries (all SYS5.4 based
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   260
     systems), this is usually not required. Instead, modules which are to
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   261
     be filed in (.so files) are to be prelinked with the appropriate
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   262
     shared libraries. The dynamic loader then cares about loading those
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   263
     modules (keeping track of which modules are already loaded).
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   264
     Only systems in which the dynamic load is done 'manually' by st/x
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   265
     (i.e. currently only linux) need to set this."
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   266
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   267
    SearchedLibraries := aCollectionOfArchivePathNames
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   268
!
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   269
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   270
verbose:aBoolean
7ad01559b262 Initial revision
claus
parents:
diff changeset
   271
    "turn on/off debug traces"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   272
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
   273
    Verbose := aBoolean
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   274
7ad01559b262 Initial revision
claus
parents:
diff changeset
   275
    "ObjectFileLoader verbose:true"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   276
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   277
107
claus
parents: 106
diff changeset
   278
!ObjectFileLoader class methodsFor:'change & update'!
claus
parents: 106
diff changeset
   279
claus
parents: 106
diff changeset
   280
update:something
claus
parents: 106
diff changeset
   281
    "sent, when image is saved or restarted"
claus
parents: 106
diff changeset
   282
claus
parents: 106
diff changeset
   283
    (something == #aboutToSnapshot) ifTrue:[
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   284
	self invalidateAndRememberAllObjectFiles
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   285
    ].
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   286
    (something == #finishedSnapshot) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   287
	self revalidateAllObjectFiles
107
claus
parents: 106
diff changeset
   288
    ].
claus
parents: 106
diff changeset
   289
    (something == #restarted) ifTrue:[
claus
parents: 106
diff changeset
   290
	self reloadAllRememberedObjectFiles
claus
parents: 106
diff changeset
   291
    ].
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   292
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   293
    "Modified: 5.10.1995 / 15:49:14 / claus"
107
claus
parents: 106
diff changeset
   294
! !
claus
parents: 106
diff changeset
   295
115
claus
parents: 114
diff changeset
   296
!ObjectFileLoader class methodsFor:'defaults'!
claus
parents: 114
diff changeset
   297
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   298
absLd:file text:textAddr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   299
   "this should return a string to link file.o to absolute address.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   300
    This is only needed if no dynamic-link facilitiy exists."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   301
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   302
    |os cpu|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   303
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   304
    os := OperatingSystem getSystemType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   305
    cpu := OperatingSystem getCPUType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   306
    (os = 'sunos') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   307
	(cpu = 'sparc') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   308
	    ^ ('ld -A ' , MySymbolTable , ' -T ',
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   309
			  (textAddr printStringRadix:16),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   310
			  ' -N -x ' , file)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   311
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   312
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   313
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   314
    self error:'do not know how to link absolute'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   315
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   316
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   317
absLd:file text:textAddr data:dataAddr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   318
   "this should return a string to link file.o to absolute address.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   319
    This is only needed if no dynamic-link facilitiy exists."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   320
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   321
    |os cpu|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   322
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   323
    os := OperatingSystem getSystemType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   324
    cpu := OperatingSystem getCPUType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   325
    (os = 'sunos') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   326
	(cpu = 'sparc') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   327
" "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   328
	    ^ ('ld -A ' , MySymbolTable , ' -x -Bstatic' ,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   329
	       ' -Ttext ' , (textAddr printStringRadix:16) , 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   330
	       ' -Tdata ' , (dataAddr printStringRadix:16) , ' ' , file)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   331
" "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   332
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   333
	    ^ ('ld -A ' , MySymbolTable , ' -T ',
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   334
			  (textAddr printStringRadix:16),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   335
			  ' -N -x ' , file)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   336
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   337
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   338
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   339
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   340
    (os = 'ultrix') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   341
	(cpu = 'mips') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   342
	    ^ ('ld -A ' , MySymbolTable , ' -x -N -T ' , (textAddr printStringRadix:16) , ' ' , file)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   343
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   344
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   345
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   346
    self error:'do not know how to link absolute'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   347
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   348
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   349
hasValidBinaryExtension:aFilename
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   350
    "return true, if aFilename looks ok for binary loading.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   351
     This checks only the extension - not its contents. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   352
     (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
   353
     This is very machine specific."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   354
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   355
    self validBinaryExtensions do:[:ext |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   356
	(aFilename endsWith:ext) ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   357
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   358
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   359
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   360
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   361
     ObjectFileLoader hasValidBinaryExtension:'foo.st'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   362
     ObjectFileLoader hasValidBinaryExtension:'foo.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   363
     ObjectFileLoader hasValidBinaryExtension:'foo.so'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   364
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   365
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   366
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   367
needSeparateIDSpaces
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   368
    "return true, if we need separate I and D spaces.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   369
     This is only needed if no dynamic-link facilitiy exists."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   370
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   371
    |os cpu|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   372
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   373
    os := OperatingSystem getSystemType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   374
    cpu := OperatingSystem getCPUType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   375
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   376
    (os = 'sunos') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   377
	(cpu = 'sparc') ifTrue:[ ^ true ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   378
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   379
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   380
    'OBJFLOADER: dont know if we need sepId - assume no' errorPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   381
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   382
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   383
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   384
nm:file
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   385
   "this should return a string to list the namelist of file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   386
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   387
    |os|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   388
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   389
    os := OperatingSystem getSystemType.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   390
    (os = 'iris') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   391
	^ 'nm -B ' , file
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   392
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   393
    ^ 'nm ' , file
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   394
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   395
115
claus
parents: 114
diff changeset
   396
sharedLibraryExtension
claus
parents: 114
diff changeset
   397
    "return a fileName extension used for dynamic loadable objects.
claus
parents: 114
diff changeset
   398
     This is very machine specific."
claus
parents: 114
diff changeset
   399
claus
parents: 114
diff changeset
   400
    |os|
claus
parents: 114
diff changeset
   401
claus
parents: 114
diff changeset
   402
    os := OperatingSystem getSystemType.
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   403
    (os = 'sys5_4') ifTrue:[^ '.so'].
115
claus
parents: 114
diff changeset
   404
    (os = 'iris') ifTrue:[^ '.so'].
claus
parents: 114
diff changeset
   405
    (os = 'linux') ifTrue:[^ '.o'].
claus
parents: 114
diff changeset
   406
    (os = 'aix') ifTrue:[^ '.so'].
claus
parents: 114
diff changeset
   407
    (os = 'hpux') ifTrue:[^ '.sl'].
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   408
    (os = 'win32') ifTrue:[^ '.dll'].
115
claus
parents: 114
diff changeset
   409
    (os = 'os2') ifTrue:[^ '.dll'].
119
claus
parents: 118
diff changeset
   410
claus
parents: 118
diff changeset
   411
    "/ mhmh what is a useful default ?
claus
parents: 118
diff changeset
   412
claus
parents: 118
diff changeset
   413
    ^ '.o'
115
claus
parents: 114
diff changeset
   414
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   415
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   416
validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   417
    "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
   418
     This is very machine specific."
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   419
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   420
    |os|
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   421
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   422
    os := OperatingSystem getSystemType.
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   423
    (os = 'sys5_4') ifTrue:[^ #('.so') ].
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   424
    (os = 'iris') ifTrue:[^ #('.so') ].
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   425
    (os = 'linux') ifTrue:[^ #('.o' '.obj' '.so') ].
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   426
    (os = 'aix') ifTrue:[^ #('.o' '.so') ].
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   427
    (os = 'hpux') ifTrue:[^ #('.o' '.sl') ].
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   428
    (os = 'win32') ifTrue:[^ #('.dll') ].
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   429
    (os = 'os2') ifTrue:[^ #('.dll') ].
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   430
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   431
    "/ mhmh what is a useful default ?
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   432
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   433
    ^ #('.o')
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   434
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   435
    "
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   436
     ObjectFileLoader validBinaryExtensions
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   437
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   438
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   439
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   440
!ObjectFileLoader class methodsFor:'dynamic class loading'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   441
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   442
invalidateAndRememberAllObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   443
    "invalidate code refs into all dynamically loaded object files.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   444
     Required before writing a snapshot image."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   445
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   446
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   447
	ActuallyLoadedObjects := LoadedObjects.
154
04716b86ad29 reloading compiled methods
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   448
	self rememberAllObjectFiles.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   449
	ActuallyLoadedObjects keys do:[:aFileName |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   450
	    |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   451
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   452
	    handle := ActuallyLoadedObjects at:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   453
	    handle isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   454
		self error:'oops, no handle'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   455
	    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   456
		self invalidateModule:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   457
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   458
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   459
	LoadedObjects := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   460
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   461
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   462
    "Created: 5.10.1995 / 15:48:56 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   463
    "Modified: 5.10.1995 / 16:48:51 / claus"
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   464
!
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   465
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   466
loadCPlusPlusObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   467
    "load a c++ object file (.o-file) into the image"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   468
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   469
    |handle initAddr list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   470
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   471
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   472
    handle isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   473
	Transcript showCr:('loadDynamic: ',aFileName,' failed.').
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   474
	^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   475
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   476
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   477
    list := self namesMatching:'__GLOBAL_$I*' segment:'[tT]' in:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   478
list size == 1 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   479
"/    (self isCPlusPlusObject:handle) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   480
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   481
	    'a c++ object file' infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   482
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   483
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   484
	 what I would like to get is the CTOR_LIST,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   485
	 and call each function.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   486
	 But dld cannot (currently) handle SET-type symbols, therefore
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   487
	 we search (using nm) for all __GLOBAL_$I* syms, get their values
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   488
	 and call them each
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
"/        list := self namesMatching:'__GLOBAL_$I*' segment:'[tT]' in:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   491
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   492
"/        initAddr := self getFunction:'__CTOR_LIST__' from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   493
"/        Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   494
"/            ('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   495
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   496
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   497
	initAddr := self getFunction:list first from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   498
	initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   499
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   500
	     try with added underscore
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
	    initAddr := self getFunction:('_' , list first) from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   503
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   504
	(initAddr isNil and:[list first startsWith:'_']) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   505
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   506
	     try with removed underscore
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   507
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   508
	    initAddr := self getFunction:(list first copyFrom:2) from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   509
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   510
	initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   511
	    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   512
		('no CTOR-func found (' , list first , ')') infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   513
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   514
	    self unloadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   515
	    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   516
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   517
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   518
	    ('calling CTORs at:' , (initAddr printStringRadix:16)) infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   519
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   520
	self callInitFunctionAt:initAddr 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   521
	     specialInit:false 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   522
	     forceOld:false 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   523
	     interruptable:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   524
	     argument:0
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   525
	     identifyAs:nil
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   526
	     returnsObject:false.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   527
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   528
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   529
	    'done with CTORs.' infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   530
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   531
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   532
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   533
	 cannot create a CPlusPlus class automatically (there could be more than
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   534
	 one classes in it too ...)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   535
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   536
	^ handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   537
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   538
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   539
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   540
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   541
	'unknown object file' infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   542
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   543
    self unloadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   544
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   545
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   546
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   547
loadClass:aClassName fromObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   548
    "load a compiled class (.o-file) into the image"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   549
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   550
    |handle initAddr symName newClass list moreHandles info status 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   551
     otherClass knownToBeOk|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   552
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   553
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   554
    handle isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   555
	Transcript showCr:('loadDynamic: ', aFileName,' failed.').
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   556
	^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   557
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   558
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   559
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   560
     get the Init-function; let the class install itself
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   561
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   562
    symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   563
    initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   564
    initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   565
	"try with added underscore"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   566
	symName := '__' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   567
	initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   568
	initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   569
	    "try with added period (AIX)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   570
	    symName := '._' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   571
	    initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   572
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   573
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   574
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   575
    knownToBeOk := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   576
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   577
"/    knownToBeOk ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   578
"/        Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   579
"/            'looking for undefs ...' infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   580
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   581
"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   582
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   583
"/         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
   584
"/         files (libs, other modules)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   585
"/        "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   586
"/        list := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   587
"/        list notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   588
"/            moreHandles := self loadModulesFromListOfUndefined:list.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   589
"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   590
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   591
"/             now, try again
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   592
"/            "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   593
"/            symName := '_' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   594
"/            initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   595
"/            initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   596
"/                "try with added underscore"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   597
"/                symName := '__' , aClassName , '_Init'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   598
"/                initAddr := self getFunction:symName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   599
"/            ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   600
"/        ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   601
"/    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   602
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   603
    initAddr notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   604
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   605
	    ('calling init at: ' , (initAddr printStringRadix:16)) infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   606
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   607
	info := self performModuleInitAt:initAddr identifyAs:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   608
	status := info at:1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   609
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   610
	 if any classes are missing ...
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
	(status == #missingClass:) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   613
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   614
	     ... and we are loading a module ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   615
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   616
	    Transcript showCr:'try for missing class in same object ...'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   617
	    otherClass := self loadClass:(status at:2) fromObjectFile:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   618
	    otherClass notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   619
		"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   620
		 try again ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   621
		"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   622
		Transcript showCr:'missing class is here; try again ...'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   623
		info := self performModuleInitAt:initAddr identifyAs:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   624
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   625
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   626
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   627
	(Symbol hasInterned:aClassName) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   628
	    newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   629
	    newClass notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   630
		newClass initialize.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   631
		"force cache flush"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   632
		Smalltalk at:aClassName asSymbol put:newClass.
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   633
		Smalltalk isInitialized ifTrue:[
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   634
		    Smalltalk changed.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   635
		]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   636
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   637
	] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   638
	    'LOADER: class ' errorPrint. aClassName errorPrint.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   639
	    ' did not define itself' errorPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   640
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   641
	     do not unload - could have installed other classes/methods ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   642
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   643
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   644
	^ newClass
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   645
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   646
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   647
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   648
	('no symbol: ', symName,' in ',aFileName) infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   649
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   650
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   651
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   652
     unload
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   653
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   654
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   655
	'unloading due to init failure:' infoPrint. handle pathName infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   656
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   657
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   658
    moreHandles notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   659
	moreHandles do:[:aHandle |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   660
	    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   661
		('unloading: ', aHandle printString) infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   662
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   663
	    self unloadDynamicObject:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   664
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   665
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   666
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   667
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   668
	('unloading: ', handle printString) infoPrintNL.
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
   669
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   670
    self unloadDynamicObject:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   671
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   672
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   673
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   674
     ObjectFileLoader loadClass:'Tetris'      fromObjectFile:'../clients/Tetris/Tetris.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   675
     ObjectFileLoader loadClass:'TetrisBlock' fromObjectFile:'../clients/Tetris/TBlock.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   676
     ObjectFileLoader loadClass:'Foo'         fromObjectFile:'classList.o'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   677
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   678
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   679
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   680
loadMethodObjectFile:aFileName
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   681
    "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
   682
     This does a slightly different initialization.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   683
     Return an object handle; nil on error"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   684
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   685
    |handle initAddr initName idx m|
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   686
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   687
    "
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   688
     load the objectfile
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   689
    "
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   690
    handle := self loadDynamicObject:aFileName.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   691
    handle isNil ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   692
	^ nil
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   693
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   694
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   695
    initName := aFileName asString.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   696
    (initName startsWith:'./') ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   697
	initName := initName copyFrom:3
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   698
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   699
    idx := initName indexOf:$..
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   700
    idx ~~ 0 ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   701
	initName := initName copyTo:(idx -1).
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   702
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   703
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   704
    initAddr := self getFunction:'__' , initName , '_Init' from:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   705
    initAddr isNil ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   706
	initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   707
	initAddr isNil ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   708
	    (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   709
		self listUndefinedSymbolsIn:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   710
		'undefined symbols in primitive code' errorPrintNL.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   711
	    ] ifFalse:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   712
		(initName , '_Init() lookup failed') errorPrintNL
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   713
	    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   714
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   715
	    self unloadDynamicObject:handle.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   716
	    ^ nil
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   717
	]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   718
    ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   719
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   720
    m := self
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   721
	callInitFunctionAt:initAddr 
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   722
	specialInit:true
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   723
	forceOld:true 
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   724
	interruptable:false
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   725
	argument:2
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   726
	identifyAs:handle
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   727
	returnsObject:true.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   728
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   729
    handle method:m.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   730
    ^ handle
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   731
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   732
    "Created: 5.12.1995 / 20:59:46 / cg"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   733
    "Modified: 6.12.1995 / 13:13:44 / cg"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   734
!
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   735
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   736
loadModulesFromListOfUndefined:list
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   737
    "try to figure out what has to be loaded to resolve symbols from list.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   738
     return a list of handles of loaded objects
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   739
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   740
    |inits classNames|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   741
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   742
    inits := list select:[:symbol | symbol notNil and:[symbol endsWith:'_Init']].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   743
    inits notNil ifTrue:[
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   744
        classNames := inits collect:[:symbol |
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   745
            (symbol startsWith:'___') ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   746
                symbol copyFrom:4 to:(symbol size - 5)
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   747
            ] ifFalse:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   748
                (symbol startsWith:'__') ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   749
                    symbol copyFrom:3 to:(symbol size - 5)
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   750
                ] ifFalse:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   751
                    (symbol startsWith:'_') ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   752
                        symbol copyFrom:2 to:(symbol size - 5)
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   753
                    ] ifFalse:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   754
                        symbol
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   755
                    ]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   756
                ]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   757
            ]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   758
        ].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   759
        "
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   760
         autoload those classes
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   761
        "
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   762
        classNames do:[:aClassName |
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   763
            |cls|
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   764
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   765
            (cls := Smalltalk classNamed:aClassName) notNil ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   766
                'autoloading ' infoPrint. aClassName infoPrintNL.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   767
                cls autoload
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   768
            ]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   769
        ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   770
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   771
    ^ nil
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   772
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   773
    "Modified: 17.12.1995 / 16:00:27 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   774
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   775
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   776
loadObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   777
    "load an object file (.o-file) into the image; 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   778
     the class name is not needed (multiple definitions may be in the file).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   779
     Return false on error, true if ok."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   780
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   781
    |handle initAddr className newClass initNames didInit info status suffixLen
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   782
     undefinedNames dummyHandle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   783
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   784
    handle := self loadDynamicObject:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   785
    handle isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   786
	Transcript showCr:('loadDynamic: ',aFileName,' failed.').
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   787
	^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   788
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   789
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   790
    didInit := false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   791
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   792
    "/ with dld, load may have worked, even if undefined symbols
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   793
    "/ are to be resolved. If thats the case, load all libraries ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   794
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   795
    SearchedLibraries notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   796
	(self hasUndefinedSymbolsIn:handle) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   797
	    SearchedLibraries do:[:libName |
147
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   798
		(self hasUndefinedSymbolsIn:handle) ifTrue:[
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   799
		    Transcript showCr:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   800
		    dummyHandle := Array new:4.
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   801
		    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   802
		    dummyHandle isNil ifTrue:[
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   803
			Transcript showCr:'   ... load of library ' , libName , ' failed.'.
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   804
		    ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   805
		]
147
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   806
	    ].
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   807
	    (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   808
		Transcript showCr:('loadDynamic: still undefined symbols in ',aFileName,'.').
9de6bea67dbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   809
	    ].
141
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
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   812
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   813
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   814
     first, expect the classes-name to be the fileName-base
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   815
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   816
    className := OperatingSystem baseNameOf:aFileName.
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   817
    suffixLen := 0.
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   818
    self validBinaryExtensions do:[:suffix |
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   819
	suffixLen == 0 ifTrue:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   820
	    (className endsWith:suffix) ifTrue:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   821
		suffixLen := suffix size
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   822
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   823
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   824
    ].
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   825
"/    (className endsWith:'.o') ifTrue:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   826
"/	suffixLen := 2.
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   827
"/    ] ifFalse:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   828
"/	(className endsWith:'.obj') ifTrue:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   829
"/	    suffixLen := 4.
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   830
"/	] ifFalse:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   831
"/	    (className endsWith:'.so') ifTrue:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   832
"/		suffixLen := 3.
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   833
"/	    ] ifFalse:[
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   834
"/		suffixLen := 0.
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   835
"/	    ]
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   836
"/	]
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   837
"/    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   838
    suffixLen ~~ 0 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   839
	className := className copyWithoutLast:suffixLen
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   840
    ].
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
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   843
     look for explicit init function
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   844
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   845
    initAddr := self getFunction:(className , '_Init') from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   846
    initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   847
	initAddr := self getFunction:('_' , className , '_Init') from:handle.    
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
    initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   850
	"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   851
	"/ special for broken ultrix nlist (will not find symbol with single
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   852
	"/ underscore; workaround: add another underscore
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   853
	"/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   854
	initAddr := self getFunction:('__' , className , '_Init') from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   855
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   856
    initAddr isNil ifTrue:[
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
	 look for reverse abbreviation
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
	className := Smalltalk classNameForFile:className.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   861
	className notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   862
	    initAddr := self getFunction:(className , '_Init') from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   863
	    initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   864
		initAddr := self getFunction:('_' , className , '_Init') from:handle.    
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   865
	    ].
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
    initAddr notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   869
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   870
	    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   871
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   872
	info := self performModuleInitAt:initAddr identifyAs:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   873
	status := info at:1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   874
	status == #ok ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   875
	    didInit := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   876
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   877
    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   878
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   879
	 look for init-function(s); call them all
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   880
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   881
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   882
	    'no init found; looking for candidates ...' infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   883
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   884
	initNames := self namesMatching:'*_Init' segment:'[tT]' in:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   885
	initNames notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   886
	    initNames do:[:aName |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   887
		initAddr := self getFunction:aName from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   888
		initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   889
		    (aName startsWith:'_') ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   890
			initAddr := self getFunction:(aName copyFrom:2) from:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   891
		    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   892
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   893
		initAddr isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   894
		    Transcript showCr:('no symbol: ',aName,' in ',aFileName).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   895
		] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   896
		    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   897
			('calling init at:' , (initAddr printStringRadix:16)) infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   898
		    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   899
		    self performModuleInitAt:initAddr identifyAs:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   900
		    didInit := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   901
		]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   902
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   903
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   904
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   905
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   906
"/    (Symbol hasInterned:className) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   907
"/        newClass := Smalltalk at:className asSymbol ifAbsent:[nil].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   908
"/        newClass notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   909
"/            newClass initialize.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   910
"/            "force cache flush"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   911
"/            Smalltalk at:className asSymbol put:newClass.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   912
"/        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   913
"/    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   914
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   915
    didInit ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   916
	status == #registrationFailed ifTrue:[
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
   917
	    Transcript showCr:'incompatible object (recompile without commonSymbols ?)'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   918
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   919
	self listUndefinedSymbolsIn:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   920
	self unloadDynamicObject:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   921
	Transcript showCr:'module not loaded.'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   922
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   923
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   924
    Smalltalk isInitialized ifTrue:[
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   925
	"
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   926
	 really dont know, if it has changed ...
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   927
	"
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   928
	Smalltalk changed.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   929
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   930
    ^ true
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   931
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   932
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   933
reloadAllRememberedObjectFiles
158
05f71dfacb31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   934
    "reload all object modules as were loaded when the image was saved.
05f71dfacb31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   935
     Some care has to be taken, if files are missing or otherwise corrupted."
05f71dfacb31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   936
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   937
    |oldDummyMethod where m newHandle|
154
04716b86ad29 reloading compiled methods
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   938
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   939
    PreviouslyLoadedObjects notNil ifTrue:[
177
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   940
        PreviouslyLoadedObjects do:[:entry |
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   941
            |fileName handle cls sel|
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   942
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   943
            fileName := entry key.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   944
            handle := entry value.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   945
            handle moduleID:nil.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   946
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   947
            handle isClassLibHandle ifTrue:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   948
                ('OBJFLOADER: reloading classes in ' , fileName , ' ...') infoPrintNL.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   949
                self loadObjectFile:fileName
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   950
            ] ifFalse:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   951
                handle isMethodHandle ifTrue:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   952
                    oldDummyMethod := handle method.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   953
                    oldDummyMethod isNil ifTrue:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   954
                        ('OBJFLOADER: ignore obsolete (already collected) method in ' , fileName) infoPrintNL
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   955
                    ] ifFalse:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   956
                        ('OBJFLOADER: reloading method in ' , fileName , ' ...') infoPrintNL.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   957
                        where := oldDummyMethod who.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   958
                        newHandle := self loadMethodObjectFile:fileName.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   959
                        newHandle isNil ifTrue:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   960
                            ('OBJFLOADER: failed to reload method in ' , fileName , ' ...') infoPrintNL.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   961
                        ] ifFalse:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   962
                            m := newHandle method.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   963
                            m source:(oldDummyMethod source).
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   964
                            m package:(oldDummyMethod package).
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   965
                            where notNil ifTrue:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   966
                                cls := where at:1.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   967
                                sel := where at:2.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   968
                                m == (cls compiledMethodAt:sel) ifFalse:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   969
                                    'OBJFLOADER: oops - loaded method installed wrong' errorPrintNL.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   970
                                ] ifTrue:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   971
                                    cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod).
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   972
                                ]
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   973
                            ].
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   974
                        ]
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   975
                    ]
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   976
                ] ifFalse:[
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   977
                    ('OBJFLOADER: oops - invalid (obsolete) objectFile handle: ' , handle printString) infoPrintNL.
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   978
                ]
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   979
            ]
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   980
        ].
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   981
        PreviouslyLoadedObjects := nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   982
    ]
156
2bf6dc265509 method loading
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   983
177
17c9b4cb2889 change notification when methods are loaded
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
   984
    "Modified: 23.12.1995 / 01:11:25 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   985
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   986
174
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   987
rememberAllObjectFiles
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   988
    LoadedObjects notNil ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   989
	PreviouslyLoadedObjects := OrderedCollection new.
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   990
	LoadedObjects keysAndValuesDo:[:name :handle |
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   991
	    handle isForCollectedObject ifTrue:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   992
		('OBJFLOADER: ignore object for already collected objects in ' , name) infoPrintNL
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   993
	    ] ifFalse:[
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   994
		PreviouslyLoadedObjects add:(name -> handle)
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   995
	    ]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   996
	].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   997
	PreviouslyLoadedObjects sort:[:a :b | a value moduleID < b value moduleID].
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   998
    ]
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
   999
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1000
    "Created: 5.12.1995 / 20:51:07 / cg"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1001
    "Modified: 6.12.1995 / 17:53:08 / cg"
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1002
!
3be731572be7 prints replaced by infoPrint
Claus Gittinger <cg@exept.de>
parents: 160
diff changeset
  1003
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1004
revalidateAllObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1005
    "revalidate code refs into all dynamically loaded object files.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1006
     Required after writing a snapshot image."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1007
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1008
    ActuallyLoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1009
	ActuallyLoadedObjects keys do:[:aFileName |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1010
	    |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1011
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1012
	    handle := ActuallyLoadedObjects at:aFileName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1013
	    handle isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1014
		self error:'oops, no handle'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1015
	    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1016
		self revalidateModule:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1017
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1018
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1019
	LoadedObjects := ActuallyLoadedObjects.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1020
	ActuallyLoadedObjects := PreviouslyLoadedObjects := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1021
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1022
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1023
    "Created: 5.10.1995 / 15:49:08 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1024
    "Modified: 5.10.1995 / 16:49:18 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1025
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1026
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1027
unloadAllObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1028
    "unload all dynamically loaded object files from the image.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1029
     see DANGER ALERT in ObjectFileLoader>>unloadObjectFile:"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1030
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1031
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1032
	LoadedObjects keys copy do:[:aFileName |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1033
	    self unloadObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1034
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1035
    ].
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1036
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1037
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1038
     ObjectFileLoader unloadAllObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1039
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1040
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1041
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1042
unloadAllObsoleteObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1043
    "unload all dynamically loaded object files for which the classes/method
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1044
     has been already garbage collected."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1045
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1046
    LoadedObjects notNil ifTrue:[
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1047
	LoadedObjects keys copy do:[:name |
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1048
	    |handle|
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1049
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1050
	    handle := LoadedObjects at:name ifAbsent:nil.
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1051
	    (handle notNil and:[handle isObsolete]) ifTrue:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1052
		self unloadObjectFile:name 
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1053
	    ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1054
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1055
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1056
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1057
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1058
     ObjectFileLoader unloadAllObsoleteObjectFiles
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1059
    "
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1060
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1061
    "Modified: 5.12.1995 / 18:16:52 / cg"
134
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1062
!
d93682ca90a1 more queries for valid objectfilenames
Claus Gittinger <cg@exept.de>
parents: 130
diff changeset
  1063
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1064
unloadAndRememberAllObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1065
    LoadedObjects notNil ifTrue:[
154
04716b86ad29 reloading compiled methods
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
  1066
	self rememberAllObjectFiles.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1067
	self unloadAllObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1068
    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1069
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1070
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1071
unloadObjectFile:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1072
    "unload an object file (.o-file) from the image.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1073
     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
  1074
     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
  1075
     track of these. For now, use at your own risk.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1076
     (especially critical are blocks-functions)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1077
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1078
    |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1079
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1080
    LoadedObjects notNil ifTrue:[
153
90df8e05815c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 151
diff changeset
  1081
	handle := LoadedObjects at:aFileName ifAbsent:nil
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1082
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1083
    handle isNil ifTrue:[
153
90df8e05815c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 151
diff changeset
  1084
	'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
  1085
	^ self
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1086
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1087
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1088
    "/ call the modules deInit-function ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1089
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1090
    "/ unload ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1091
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1092
    self unloadDynamicObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1093
! !
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
!ObjectFileLoader class methodsFor:'dynamic object access'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1096
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1097
callInitFunctionAt:address specialInit:special forceOld:forceOld interruptable:interruptable argument:argument identifyAs:handle returnsObject:returnsObject
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1098
    "call a function at address - a very dangerous operation.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1099
     This is needed to call the classes init-function after loading in a
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1100
     class-object file or to call the CTORS when c++ modules are loaded.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1101
     ForceOld (if true) will have the memory manager
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1102
     allocate things in oldSpace instead of newSpace.
178
7342b41b7fe7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1103
     If special is true, this is a smalltalk moduleInit (i.e. pass the vm-entries table);
7342b41b7fe7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 177
diff changeset
  1104
     otherwise, its called without arguments.
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1105
     DANGER: Internal & highly specialized. Dont use in your programs."
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1106
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1107
    |low hi lowAddr hiAddr moduleID retVal|
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
    hi := address // 16r10000.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1110
    low := address \\ 16r10000.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1111
    handle notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1112
	moduleID := handle moduleID
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1113
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1114
%{
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1115
    OBJ (*addr)();
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1116
    unsigned val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1117
    typedef void (*VOIDFUNC)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1118
    int savInt;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1119
    int prevSpace, force;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1120
    int arg = 0;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1121
    int wasBlocked = 1;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1122
    extern OBJ __BLOCKINTERRUPTS();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1123
    extern int __oldSpaceSize(), __oldSpaceUsed();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1124
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1125
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1126
	if (_isSmallInteger(argument)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1127
	    arg = __intVal(argument);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1128
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1129
	    val = (_intVal(hi) << 16) + _intVal(low);
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1130
	    addr = (OBJFUNC) val;
141
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
	    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1133
	     * allow function to be interrupted
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1134
	     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1135
	    if (interruptable != true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1136
		wasBlocked = (__BLOCKINTERRUPTS() == true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1137
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1138
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1139
	    force = (forceOld == true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1140
	    if (force) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1141
		if ((__oldSpaceSize() - __oldSpaceUsed()) < (64*1024)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1142
		    __moreOldSpace(__thisContext, 64*1024);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1143
		} 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1144
		prevSpace = __allocForceSpace(OLDSPACE);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1145
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1146
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1147
	    if (special == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1148
		if (__isSmallInteger(moduleID)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1149
		    __SET_MODULE_ID(__intVal(moduleID));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1150
		}
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1151
		retVal = (*addr)(arg, __pRT__ COMMA_CON);
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1152
		__SET_MODULE_ID(0);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1153
	    } else {
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1154
		retVal = (*addr)(arg COMMA_CON);
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1155
	    }
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1156
	    if (returnsObject != true) {
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1157
		retVal = nil;
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1158
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1159
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1160
	    if (force) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1161
		__allocForceSpace(prevSpace);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1162
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1163
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1164
	    if (! wasBlocked) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1165
		__UNBLOCKINTERRUPTS();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1166
	    }
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1167
	    RETURN (retVal);
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1168
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1169
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1170
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1171
    self primitiveFailed
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1172
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1173
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1174
classNameThatFailed
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1175
    "ask VM for the name of the class that caused trouble"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1176
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1177
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1178
    extern char *__name_registration_failure__();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1179
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1180
    RETURN (_MKSTRING(__name_registration_failure__()));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1181
%}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1182
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1183
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1184
deinitializeClassesFromModule:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1185
    "send #deinitialize to all classes of a module"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1186
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1187
    |classes|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1188
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1189
    classes := handle classes.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1190
    classes notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1191
	classes do:[:aClass |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1192
	    aClass isMeta ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1193
		Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1194
		    'send #deinitialize to:' infoPrint. aClass name infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1195
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1196
		aClass deinitialize
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1197
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1198
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1199
    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1200
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1201
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1202
getFunction:aString from:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1203
    "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
  1204
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1205
     Return the address of the function, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1206
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1207
    |fName|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1208
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1209
    OperatingSystem getSystemType = 'aix' ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1210
	fName := '.' , aString 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1211
    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1212
	fName := aString
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1213
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1214
    ^ self getSymbol:fName function:true from:handle
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1217
getListOfUndefinedSymbolsFrom:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1218
    "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
  1219
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1220
     Not all systems allow an object with undefined symbols to be
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1221
     loaded (actually, only dld does)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1222
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1223
    |list|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1224
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1225
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1226
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1227
    void (*func)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1228
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1229
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1230
    int nMax;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1231
    char **undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1232
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1233
    undefNames = dld_list_undefined_sym();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1234
    if (dld_undefined_sym_count > 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1235
	char **nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1236
	int index;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1237
	int count = dld_undefined_sym_count;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1238
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1239
	if (count > 100) count = 100;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1240
	list = __ARRAY_NEW_INT(count);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1241
	if (list) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1242
	    nm = undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1243
	    for (index = 0; index < count; index++) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1244
		OBJ s;
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
		s = _MKSTRING(*nm);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1247
		_ArrayInstPtr(list)->a_element[index] = s;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1248
		__STORE(list, s);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1249
		nm++;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1250
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1251
	    free(undefNames);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1252
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1253
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1254
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1255
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1256
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1257
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1258
     * dont know how to do it
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
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1261
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1262
#ifdef SYSV4_DL
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
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1265
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1266
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1267
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1268
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1269
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1270
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1271
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1272
#endif
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
#ifdef NEXT_DL
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
     * dont know how to do it
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1277
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1278
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1279
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1280
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1281
    /*
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1282
     * dont know how to do it
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1283
     */
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1284
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1285
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1286
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1287
    ^ list
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1290
getSymbol:aString function:isFunction from:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1291
    "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
  1292
     Handle must be the one returned previously from loadDynamicObject.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1293
     Return the address of the symbol, or nil on any error."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1294
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1295
    |sysHandle1 sysHandle2 lowAddr hiAddr|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1296
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1297
    sysHandle1 := aHandle sysHandle1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1298
    sysHandle2 := aHandle sysHandle2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1299
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1300
%{  /* STACK: 20000 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1301
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1302
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1303
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1304
    void (*func)();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1305
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1306
    char *name;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1307
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1308
    if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1309
	name = (char *) __stringVal(aString);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1310
	if (isFunction == false) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1311
	    addr = dld_get_symbol(name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1312
	} else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1313
	    func = (void (*) ()) dld_get_func(name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1314
	    if (func) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1315
		if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1316
		    printf("addr of %s = %x\n", name, (INT)func);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1317
		if (dld_function_executable_p(name)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1318
		    lowAddr = _MKSMALLINT( (INT)func & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1319
		    hiAddr = _MKSMALLINT( ((INT)func >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1320
		} else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1321
		    char **undefNames;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1322
		    char **nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1323
		    int i;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1324
        
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1325
		    if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1326
			printf ("function %s not executable\n", name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1327
			dld_perror("not executable");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1328
                    
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1329
			printf("undefined:\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1330
			nm = undefNames = dld_list_undefined_sym();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1331
			for (i=dld_undefined_sym_count; i; i--) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1332
			    printf("    %s\n", *nm++);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1333
			}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1334
			free(undefNames);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1335
		    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1336
		}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1337
	    } else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1338
		if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1339
		    printf ("function %s not found\n", name);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1340
		    dld_perror("get_func");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1341
		}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1342
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1343
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1344
    }
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
#endif /* GNU_DL */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1347
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1348
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1349
  {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1350
    void *h;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1351
    void *addr;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1352
    int val;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1353
    FARPROC entry;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1354
    HMODULE handle;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1355
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1356
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1357
        val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1358
        handle = (HMODULE)(val);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1359
        if (__isString(aString)) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1360
            if (ObjectFileLoader_Verbose == true)
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1361
                printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1362
            entry = GetProcAddress(handle, (char *) __stringVal(aString));
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1363
            if (entry != NULL) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1364
		addr = (void *)entry;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1365
                if (ObjectFileLoader_Verbose == true) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1366
                    printf("GetProcAddr %s ok; addr = %x\n", __stringVal(aString), addr);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1367
                }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1368
                lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1369
                hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1370
            } else {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1371
                if (ObjectFileLoader_Verbose == true) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1372
                    printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1373
                }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1374
            }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1375
        }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1376
    }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1377
  }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1378
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1379
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1380
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1381
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1382
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1383
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1384
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1385
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1386
    if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1387
	if (__isString(sysHandle1)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1388
	    if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1389
		printf("get sym <%s> handle = %x\n",
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1390
			__stringVal(aString), __stringVal(sysHandle1));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1391
	    addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1392
	    if (addr) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1393
		if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1394
		    printf("addr = %x\n", addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1395
		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1396
		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1397
	    } else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1398
		if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1399
		    printf("dl_getsymbol %s failed\n", __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1400
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1401
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1402
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1403
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1404
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1405
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1406
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1407
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1408
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1409
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1410
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1411
    OBJ low = sysHandle1, hi = sysHandle2;
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
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1414
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1415
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1416
	if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1417
	    if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1418
		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1419
	    addr = dlsym(h, (char *) __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1420
	    if (addr) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1421
		if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1422
		    printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1423
		}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1424
		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1425
		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1426
	    } else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1427
		if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1428
		    printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
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
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1431
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1432
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1433
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1434
#endif
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
#ifdef AIX_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1437
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1438
    OBJ fileName;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1439
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1440
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1441
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1442
    struct nlist nl[2];
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1443
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1444
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1445
    if (__bothSmallInteger(low, hi)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1446
     && __isString(fileName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1447
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1448
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1449
	if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1450
	    if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1451
		printf("get sym <%s> handle = %x file = %s\n", 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1452
			__stringVal(aString), h, __stringVal(fileName));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1453
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1454
	    nl[0].n_name = __stringVal(aString);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1455
	    nl[1].n_name = "";
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
	    if (nlist(__stringVal(fileName), &nl) == -1) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1458
		if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1459
		    printf("nlist error\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1460
	    } else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1461
		addr = (void *)((unsigned)nl[0].n_value + (unsigned)h);
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
		if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1464
		    printf("value=%x section=%d type=%x sclass=%d\n", 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1465
			    nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1466
		    printf("addr = %x\n", addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1467
		}
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
		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1470
		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1471
	    }
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
    }
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1476
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1477
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1478
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1479
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1480
    void *addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1481
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1482
    OBJ low = sysHandle1, hi = sysHandle2;
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
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1485
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1486
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1487
	if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1488
	    if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1489
		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1490
	    addr = dlsym(h, __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1491
	    if (addr) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1492
		if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1493
		    printf("addr = %x\n", addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1494
		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1495
		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1496
	    } else {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1497
		if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1498
		    printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
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
	}
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
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1503
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1504
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1505
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1506
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1507
    unsigned long addr;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1508
    long result;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1509
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1510
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1511
    if (__isString(aString)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1512
	if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1513
	    printf("get sym <%s>\n", __stringVal(aString));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1514
	errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1515
	result = rld_lookup(errOut,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1516
			    (char *) __stringVal(aString),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1517
			    &addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1518
	NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1519
	if (result) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1520
	    if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1521
		printf("addr = %x\n", addr);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1522
	    lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1523
	    hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1524
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1525
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1526
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1527
#endif
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1528
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1529
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1530
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1531
    lowAddr notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1532
	^ (hiAddr * 16r10000) + lowAddr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1533
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1534
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1535
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1536
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1537
hasUndefinedSymbolsIn:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1538
    ^ (self getListOfUndefinedSymbolsFrom:handle) size > 0
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
invalidateModule:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1542
    "invalidate all of the classes code objects ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1543
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1544
    |id|
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
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1547
	'invalidate module; name=' infoPrint. handle pathName infoPrint.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1548
	' id=' infoPrint. handle moduleID infoPrintNL.
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1551
    id := handle moduleID.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1552
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1553
    __INVALIDATE_BY_ID(__intVal(id));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1554
%}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1555
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1556
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1557
isCPlusPlusObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1558
    "return true, if the loaded object is a c++ object module"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1559
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1560
    (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
  1561
    (self getSymbol:'__CTOR_LIST__' function:true from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1562
    (self getSymbol:'__CTOR_LIST__' function:false from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1563
    (self getSymbol:'__gnu_compiled_cplusplus' function:false from:handle) notNil ifTrue:[^ true].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  1564
    ^ false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1565
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1566
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1567
isObjectiveCObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1568
    "not yet implemented"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1569
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1570
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1571
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1572
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1573
isSmalltalkObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1574
    "return true, if the loaded object is a smalltalk object module"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1575
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1576
    "not yet implemented - stc_compiled_smalltalk is a static symbol,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1577
     not found in list - need nm-interface, or nlist-walker
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1578
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1579
    ^ true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1580
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1581
    (self getSymbol:'__stc_compiled_smalltalk' function:true from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1582
    (self getSymbol:'__stc_compiled_smalltalk' function:false from:handle) notNil ifTrue:[^ true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1583
    ^ false
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1586
listUndefinedSymbolsIn:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1587
    |undefinedNames|
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
    undefinedNames := self getListOfUndefinedSymbolsFrom:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1590
    undefinedNames size > 0 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1591
	Transcript showCr:'undefined:'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1592
	undefinedNames do:[:aName |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1593
	    Transcript showCr:'    ' , aName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1594
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1595
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1596
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1597
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1598
loadDynamicObject:pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1599
    "load an object-file (load/map into my address space).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1600
     Return a non-nil handle if ok, nil otherwise.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1601
     No bindings are done - only a pure load is performed.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1602
     This function is not supported on all architectures.
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
    |handle buffer|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1606
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1607
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1608
	('loadDynamic: ' , pathName , ' ...') infoPrintNL
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1611
    "/ already loaded ?
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1612
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1613
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1614
	handle := LoadedObjects at:pathName ifAbsent:nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1615
	handle notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1616
	    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1617
		('... ' , pathName , ' already loaded.') infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1618
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1619
	    ^ handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1620
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1621
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1622
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1623
    "/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1624
    "/ the 1st two entries are system dependent;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1625
    "/ entry 3 is the pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1626
    "/ entry 4 is a unique ID
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1627
    "/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1628
    buffer := Array new:4.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1629
    buffer at:3 put:pathName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1630
    buffer at:4 put:NextHandleID. NextHandleID := NextHandleID + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1631
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1632
    buffer := self primLoadDynamicObject:pathName into:buffer.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1633
    buffer isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1634
	LastError == #notImplemented ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1635
	    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1636
		'no dynamic load facility or load failed.' infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1637
		Transcript showCr:'Try to load it myself ...'.
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
	    "try it the hard way"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1640
	    buffer := self loadFile:pathName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1641
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1642
	buffer isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1643
	    LastError == #linkError ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1644
		LinkErrorMessage notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1645
		    Transcript showCr:'Load error:' , LinkErrorMessage
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1646
		].    
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1647
	    ].    
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1648
	    ^ nil
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  1649
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1650
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1651
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1652
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1653
     remember loaded object for later unloading
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1654
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1655
    handle := ObjectFileHandle new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1656
    handle sysHandle1:(buffer at:1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1657
    handle sysHandle2:(buffer at:2).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1658
    handle pathName:(buffer at:3).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1659
    handle moduleID:(buffer at:4).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1660
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1661
    LoadedObjects isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1662
	LoadedObjects := Dictionary new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1663
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1664
    LoadedObjects at:pathName put:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1665
    Smalltalk flushCachedClasses.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1666
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1667
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1668
	('loadDynamic ok; handle is: ' , handle printString) infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1669
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1670
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1671
    ^ handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1672
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1673
    "sys5.4:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1674
     |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1675
     handle := ObjectFileLoader loadDynamicObject:'../stc/mod1.so'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1676
     ObjectFileLoader getFunction:'module1' from:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1677
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1678
    "next:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1679
     |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1680
     handle := ObjectFileLoader loadDynamicObject:'../goodies/Path/AbstrPath.o'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1681
     ObjectFileLoader getFunction:'__AbstractPath_Init' from:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1682
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1683
    "GLD:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1684
     |handle|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1685
     handle := ObjectFileLoader loadDynamicObject:'../clients/Tetris/Tetris.o'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1686
     ObjectFileLoader getFunction:'__TetrisBlock_Init' from:handle
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
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1689
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1690
loadStatus
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1691
    "ask VM if class-hierarchy has been completely loaded, and return a symbol describing
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1692
     the status."
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1693
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1694
    |checker checkSymbol status|
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1695
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1696
    checker := self.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1697
    checkSymbol := #'superClassCheck:'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1698
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1699
%{  /* NOREGISTER */
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1700
    status = __MKSMALLINT(__check_registration__(&checker, &checkSymbol));
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1701
%}.
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1702
    status == 0 ifTrue:[^ #ok].
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1703
    status == -1 ifTrue:[^ #missingClass].
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1704
    status == -2 ifTrue:[^ #versionMismatch].
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1705
    ^ #loadFailed
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1706
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1707
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1708
moduleInit:phase forceOld:forceOld interruptable:interruptable
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1709
    "initialization phases after registration.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1710
     DANGER: Pure magic; internal only -> dont use in your programs."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1711
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1712
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1713
    int savInt;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1714
    int prevSpace, force;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1715
    int arg = 0;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1716
    int wasBlocked = 1;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1717
    extern OBJ __BLOCKINTERRUPTS();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1718
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1719
    if (_isSmallInteger(phase)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1720
	if (interruptable != true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1721
	    wasBlocked = (__BLOCKINTERRUPTS() == true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1722
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1723
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1724
	force = (forceOld == true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1725
	if (force) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1726
	    prevSpace = __allocForceSpace(OLDSPACE);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1727
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1728
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1729
	__init_registered_modules__(__intVal(phase) COMMA_CON);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1730
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1731
	if (force) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1732
	    __allocForceSpace(prevSpace);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1733
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1734
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1735
	if (! wasBlocked) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1736
	    __UNBLOCKINTERRUPTS();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1737
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1738
	RETURN (self);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1739
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1740
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1741
    self primitiveFailed
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1742
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1743
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1744
namesMatching:aPattern segment:segmentPattern in:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1745
    "this is rubbish - it will vanish soon"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1746
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1747
    |p l s addr segment name entry|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1748
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1749
    OperatingSystem getSystemType = 'aix' ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1750
	^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1751
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1752
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1753
    l := OrderedCollection new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1754
    p := PipeStream readingFrom:(self nm:aFileName).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1755
    p isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1756
	('cannot read names from ' , aFileName) errorPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1757
	^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1758
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1759
    [p atEnd] whileFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1760
	entry := p nextLine.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1761
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1762
	    entry infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1763
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1764
	entry notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1765
	    s := ReadStream on:entry.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1766
	    addr := s nextAlphaNumericWord.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1767
	    segment := s nextAlphaNumericWord.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1768
	    name := s upToEnd withoutSeparators.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1769
	    (addr notNil and:[segment notNil and:[name notNil]]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1770
		(aPattern match:name) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1771
		    (segmentPattern isNil or:[segmentPattern match:segment]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1772
			l add:name.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1773
			Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1774
			    ('found name: ' , name) infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1775
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1776
		    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1777
			Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1778
			    name infoPrint. ' segment mismatch ' infoPrint.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1779
			    segmentPattern infoPrint. ' ' infoPrint. segment infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1780
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1781
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1782
		]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1783
	    ]
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  1784
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1785
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1786
    p close.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1787
    ^ l
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1788
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1789
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1790
performModuleInitAt:initAddr identifyAs:handle
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
     Initialize a smalltalk module.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1793
     need 4 passes to init: 0: let module register itself & create its pools/globals
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1794
			    0b check if modules superclasses are all loaded
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1795
			    1: let it get var-refs to other pools/globals
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1796
			    2: let it install install class, methods and literals
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1797
			    3: let it send #initialize to its class object
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1798
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1799
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1800
    |status badClassName infoCollection info classNames classes|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1801
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1802
    "/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1803
    "/ let it register itself
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1804
    "/ and define its globals
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1805
    "/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1806
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1807
	'phase 0 ...' infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1808
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1809
    self callInitFunctionAt:initAddr 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1810
	 specialInit:true 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1811
	 forceOld:true 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1812
	 interruptable:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1813
	 argument:0
155
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1814
	 identifyAs:handle
1884c71a2507 optionally pass back return value of init function
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
  1815
	 returnsObject:false.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1816
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
    "/ check if superclasses are present
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1819
    "/
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1820
    (status := self loadStatus) ~~ #ok ifTrue:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1821
	badClassName := self classNameThatFailed.
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1822
	(status == #missingClass) ifTrue:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1823
	    Transcript showCr:'load failed - missing class: ' , badClassName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1824
	    ^ Array with:#missingClass:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1825
		    with:badClassName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1826
	].
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
  1827
	(status == #versionMismatch) ifTrue:[
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1828
	    Transcript showCr:'load failed - version mismatch: ' , badClassName.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1829
	    ^ Array with:#versionMismatch:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1830
		    with:badClassName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1831
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1832
	Transcript showCr:'load failed'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1833
	^ Array with:#loadFailed
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1834
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1835
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1836
    "/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1837
    "/ remaining initialization
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1838
    "/
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1839
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1840
	'phase 1 ...' infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1841
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1842
    self moduleInit:1 forceOld:true interruptable:false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1843
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1844
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1845
	'phase 2 ...' infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1846
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1847
    self moduleInit:2 forceOld:true interruptable:false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1848
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1849
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1850
	'phase 3 ...' infoPrintNL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1851
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1852
    ObjectMemory flushCaches.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1853
    self moduleInit:3 forceOld:false interruptable:true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1854
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1855
    "/ ask objectMemory for the classes we have just loaded
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1856
    "/ and register them in the handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1857
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1858
    infoCollection := ObjectMemory binaryModuleInfo.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1859
    info := infoCollection at:handle moduleID ifAbsent:nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1860
    info isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1861
	"/ mhmh registration failed -
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1862
	^ Array with:#registrationFailed
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1863
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1864
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1865
    classNames := info at:#classNames.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1866
    classNames size > 0 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1867
	classes := classNames collect:[:nm | Smalltalk classNamed:nm].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1868
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1869
    classes size > 0 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1870
	classes := classes asArray.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1871
	classes := classes , (classes collect:[:aClass | aClass class]).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1872
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1873
    handle classes:classes.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1874
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1875
    ^ Array with:#ok
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  1876
!
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  1877
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1878
primLoadDynamicObject:pathName into:anInfoBuffer
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1879
    "load an object-file (map into my address space).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1880
     Return an OS-handle (whatever that is) - where some space
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1881
     (a 3-element array) has to be passed in for this.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1882
     The first two entries are used in a machine dependent way,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1883
     and callers may not depend on what is found there 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1884
     (instead, only pass around handles transparently).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1885
     This function is not supported on all architectures."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1886
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1887
%{  /* UNLIMITEDSTACK */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1888
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1889
    if (! __isArray(anInfoBuffer)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1890
     || (_arraySize(anInfoBuffer) < 3)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1891
	return nil;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1892
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1893
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1894
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1895
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1896
    static firstCall = 1;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1897
    extern char *__myName__;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1898
    extern dld_ignore_redefinitions;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1899
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1900
    if (firstCall) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1901
	firstCall = 0;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1902
	(void) dld_init (__myName__);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1903
	dld_ignore_redefinitions = 1;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1904
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1905
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1906
    if (__isString(pathName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1907
	if (dld_link(__stringVal(pathName))) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1908
	    if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1909
		printf ("link file %s failed\n", __stringVal(pathName));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1910
		dld_perror("cant link");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1911
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1912
	    ObjectFileLoader_LastError = @symbol(linkError);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1913
	    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1914
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1915
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1916
	__STORE(anInfoBuffer, pathName);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1917
	RETURN ( anInfoBuffer );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1918
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1919
    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1920
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1921
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1922
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1923
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1924
  {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1925
    HINSTANCE handle;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1926
    int err;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1927
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1928
    if (__isString(pathName)) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1929
        if ((handle = LoadLibrary(__stringVal(pathName))) == NULL) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1930
	    err = GetLastError();
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1931
            if (ObjectFileLoader_Verbose == true) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1932
                printf ("LoadLibrary %s failed; error: %x\n", 
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1933
				__stringVal(pathName), err);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1934
            }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1935
            ObjectFileLoader_LastError = __MKINT(err);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1936
            RETURN ( nil );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1937
        }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1938
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = _MKSMALLINT( (int)handle & 0xFFFF );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1939
	_ArrayInstPtr(anInfoBuffer)->a_element[1] = _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1940
        RETURN ( anInfoBuffer );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1941
    }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1942
    RETURN ( nil );
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1943
  }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1944
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  1945
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1946
#ifdef DL1_6
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1947
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1948
    extern char *__myName__;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1949
    char *ldname;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1950
    OBJ tmpName;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1951
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1952
    if (__isString(pathName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1953
	if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1954
	    if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1955
		printf ("link file %s failed\n", __stringVal(pathName));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1956
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1957
	    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1958
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1959
	/*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1960
	 * returns the name of the temporary ld-file
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1961
	 * use that as handle ...
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1962
	 */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1963
	tmpName = _MKSTRING(ldname);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1964
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1965
	__STORE(anInfoBuffer, tmpName);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1966
	RETURN ( anInfoBuffer );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1967
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1968
    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1969
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1970
#endif
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
#ifdef AIX_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1973
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1974
    extern char *__myName__;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1975
    char *ldname;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1976
    int *handle;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1977
    extern errno;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1978
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1979
    if (__isString(pathName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1980
	if ( (handle = (int *) load(__stringVal(pathName), 0, 0)) == 0 ) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1981
	    if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1982
		char *messages[64];
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1983
		int i;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1984
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1985
		printf ("load file %s failed errno=%d\n", 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1986
				__stringVal(pathName), errno);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1987
		switch (errno) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1988
		    case ENOEXEC:
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1989
			printf("   load messages:\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1990
			loadquery(L_GETMESSAGES, messages, sizeof(messages));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1991
			for (i=0; messages[i]; i++) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1992
			    printf("      %s\n", messages[i]);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1993
			}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1994
			break;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1995
		}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1996
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1997
	    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1998
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1999
	if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2000
	    printf("load %s handle = %x\n", __stringVal(pathName), handle);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2001
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2002
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2003
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = _MKSMALLINT( (int)handle & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2004
	_ArrayInstPtr(anInfoBuffer)->a_element[1] = _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2005
	RETURN (anInfoBuffer);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2006
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2007
    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2008
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2009
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2010
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2011
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2012
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2013
    void *handle;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2014
    char *nm;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2015
    char *errMsg;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2016
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2017
    if ((pathName == nil) || __isString(pathName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2018
	handle = dlopen(pathName == nil ? (char *)0 : __stringVal(pathName), RTLD_NOW);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2019
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2020
	if (! handle) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2021
	    errMsg = dlerror();
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2022
	    fprintf(stderr, "dlopen %s error:\n", __stringVal(pathName));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2023
	    fprintf(stderr, "    <%s>\n", errMsg);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2024
	    ObjectFileLoader_LastError = @symbol(linkError);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2025
	    ObjectFileLoader_LinkErrorMessage = _MKSTRING(errMsg);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2026
	    RETURN (nil);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2027
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2028
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2029
	if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2030
	    printf("open %s handle = %x\n", __stringVal(pathName), handle);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2031
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2032
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2033
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = _MKSMALLINT( (int)handle & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2034
	_ArrayInstPtr(anInfoBuffer)->a_element[1] = _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2035
	RETURN (anInfoBuffer);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2036
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2037
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2038
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2039
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2040
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2041
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2042
    void *handle;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2043
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2044
    if ((pathName == nil) || __isString(pathName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2045
	if (pathName == nil)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2046
	    handle = dlopen((char *)0, 1);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2047
	else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2048
	    handle = dlopen(__stringVal(pathName), 1);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2049
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2050
	if (! handle) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2051
	    fprintf(stderr, "dlopen %s error: <%s>\n", 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2052
				__stringVal(pathName), dlerror());
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2053
	    ObjectFileLoader_LastError = @symbol(linkError);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2054
	    RETURN (nil);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2055
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2056
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2057
	if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2058
	    printf("open %s handle = %x\n", __stringVal(pathName), handle);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2059
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2060
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2061
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = _MKSMALLINT( (int)handle & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2062
	_ArrayInstPtr(anInfoBuffer)->a_element[1] = _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2063
	RETURN (anInfoBuffer);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2064
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2065
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2066
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2067
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2068
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2069
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2070
    long result;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2071
    char *files[2];
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2072
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2073
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2074
    if (__isString(pathName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2075
	files[0] = (char *) __stringVal(pathName);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2076
	files[1] = (char *) 0;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2077
	errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2078
	result = rld_load(errOut,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2079
			  (struct mach_header **)0,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2080
			  files,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2081
			  (char *)0);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2082
	NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2083
	if (! result) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2084
	    ObjectFileLoader_LastError = @symbol(linkError);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2085
	    fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2086
	    RETURN (nil);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2087
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2088
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2089
	if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2090
	    printf("rld_load %s ok\n", __stringVal(pathName));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2091
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2092
	_ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2093
	__STORE(anInfoBuffer, pathName);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2094
	RETURN ( anInfoBuffer );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2095
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2096
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2097
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2098
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2099
    LastError := #notImplemented.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2100
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2101
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2102
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2103
primUnloadDynamicObject:aHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2104
    "unload an object-file (unmap from my address space).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2105
     This is a low-level entry, which does not care if there are
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2106
     still any code references (from blocks or methods) to this
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2107
     module. Calling it for still living classes will definitely
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2108
     lead to some fatal conditions to occur later."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2109
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2110
    |sysHandle1 sysHandle2|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2111
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2112
    sysHandle1 := aHandle sysHandle1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2113
    sysHandle2 := aHandle sysHandle2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2114
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2115
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2116
#ifdef GNU_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2117
    if (__isString(sysHandle1)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2118
	if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2119
	    if (ObjectFileLoader_Verbose == true) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2120
		printf ("unlink file %s failed\n", __stringVal(sysHandle1));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2121
		dld_perror("cant unlink");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2122
	    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2123
	    RETURN (false);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2124
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2125
	RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2126
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2127
    RETURN (false);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2128
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2129
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2130
#ifdef WIN_DL
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2131
    int val;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2132
    HINSTANCE handle;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2133
    int err;
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2134
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2135
    if (__bothSmallInteger(sysHandle1, sysHandle2)) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2136
        val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2137
        handle = (HINSTANCE)(val);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2138
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2139
        if (FreeLibrary(handle) != TRUE) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2140
	    err = GetLastError();
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2141
            if (ObjectFileLoader_Verbose == true) {
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2142
                printf ("unlink file %s failed; error: %x\n", 
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2143
			__stringVal(sysHandle1), err);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2144
            }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2145
            RETURN (false);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2146
        }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2147
        RETURN (true);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2148
    }
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2149
    RETURN (false);
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2150
#endif
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  2151
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2152
#ifdef SYSV4_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2153
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2154
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2155
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2156
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2157
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2158
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2159
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2160
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2161
	if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2162
	    printf("close handle = %x\n", h);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2163
	if (dlclose(h) != 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2164
	    fprintf(stderr, "dlclose failed with:<%s>\n", dlerror());
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2165
	    RETURN (false);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2166
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2167
	RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2168
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2169
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2170
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2171
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2172
#ifdef SUN_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2173
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2174
    void *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2175
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2176
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2177
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2178
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2179
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2180
	h = (void *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2181
	if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2182
	    printf("close handle = %x\n", h);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2183
	dlclose(h);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2184
	RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2185
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2186
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2187
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2188
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2189
#ifdef AIX_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2190
  {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2191
    int *h;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2192
    int val;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2193
    OBJ low = sysHandle1, hi = sysHandle2;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2194
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2195
    if (__bothSmallInteger(low, hi)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2196
	val = (_intVal(hi) << 16) + _intVal(low);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2197
	h = (int *)(val);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2198
	if (ObjectFileLoader_Verbose == true)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2199
	    printf("unload handle = %x\n", h);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2200
	if ( unload(h) != 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2201
	    fprintf(stderr, "unload failed\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2202
	    RETURN (false);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2203
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2204
	RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2205
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2206
  }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2207
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2208
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2209
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2210
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2211
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2212
releaseSymbolTable
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2213
    "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
  2214
     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
  2215
     On other architectures, this is not needed and therefore a noop."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2216
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2217
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2218
#ifdef NEXT_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2219
    NXStream *errOut;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2220
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2221
    errOut = NXOpenFile(2, 2);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2222
    rld_unload_all(errOut, (long)0);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2223
    rld_load_basefile(errOut, "smalltalk");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2224
    NXClose(errOut);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2225
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2226
%}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2227
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2228
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2229
revalidateModule:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2230
    "revalidate all of the classes code objects ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2231
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2232
    |id|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2233
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2234
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2235
	'revalidate module; name=' infoPrint. handle pathName infoPrint.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2236
	' id=' infoPrint. handle moduleID infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2237
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2238
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2239
    id := handle moduleID.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2240
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2241
    __REVALIDATE_BY_ID(__intVal(id));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2242
%}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2243
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2244
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2245
superClassCheck:aClass
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2246
    "callBack from class registration code in VM: make certain, that aClass is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2247
     loaded too ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2248
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2249
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2250
	'checkCall for:' infoPrint. aClass name infoPrint. ' -> ' infoPrint.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2251
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2252
    aClass isBehavior ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2253
	Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2254
	    'false' infoPrintNL. 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2255
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2256
	'LOADER: check failed - no behavior' infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2257
	^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2258
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2259
    ('LOADER: check for ' , aClass name , ' being loaded') infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2260
    aClass autoload.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2261
    (aClass isBehavior and:[aClass isLoaded]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2262
	('LOADER: ok, loaded. continue registration of actual class') infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2263
	^ true
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2264
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2265
    ('LOADER: nope not loaded. fail registration of actual class') infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2266
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2267
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2268
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2269
unloadDynamicObject:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2270
    "close an object-file (unmap from my address space)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2271
     and remove the entry from the remembered object file set.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2272
     This is a low-level entry, which does not care if there are
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2273
     still any code references (from blocks or methods) to this
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2274
     module. Calling it for still living classes will definitely
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2275
     lead to some fatal conditions to occur later."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2276
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2277
    |key|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2278
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2279
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2280
	'unload module name=' infoPrint. handle pathName infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2281
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2282
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2283
    self deinitializeClassesFromModule:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2284
    self unregisterModule:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2285
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2286
    (self primUnloadDynamicObject:handle) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2287
	^ self error:'unloadDynamic failed'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2288
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2289
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2290
     remove from loaded objects
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2291
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2292
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2293
	key := LoadedObjects keyAtEqualValue:handle.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2294
	key notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2295
	    LoadedObjects removeKey:key
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2296
	]
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2297
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2298
    Smalltalk flushCachedClasses.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2299
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2300
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2301
     for individual methods, we keep the methodObject,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2302
     but make it unexecutable. Its still visible in the browser.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2303
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2304
    handle isMethodHandle ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2305
	handle method notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2306
	    handle method makeInvalid.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2307
	    ObjectMemory flushCaches.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2308
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2309
    ]
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2310
!
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2311
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2312
unregisterModule:handle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2313
    "unregister classes in the VM.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2314
     This invalidates all of the classes code objects ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2315
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2316
    |id|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2317
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2318
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2319
	'unregister module; name=' infoPrint. handle pathName infoPrint.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2320
	' id=' infoPrint. handle moduleID infoPrintNL.
28
a9d33ea0692d loads objces on iris5
claus
parents: 20
diff changeset
  2321
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2322
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2323
    id := handle moduleID.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2324
%{
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2325
    __UNREGISTER_BY_ID(__intVal(id));
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2326
%}
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2327
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2328
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2329
!ObjectFileLoader class methodsFor:'loading objects'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2330
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2331
loadFile:oFile
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2332
    "load in an object file - return a handle or nil.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2333
     This is only needed if no dynamic link facility exists.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2334
     It allocates some memory for text and data, calls for the linker
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2335
     to relocate the oFile to that address and loads the sections."
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2336
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2337
    |unixCommand errStream errors errText
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2338
     text data textSize dataSize dataAddr textAddr newTextSize newDataSize|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2339
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2340
    "find out, how much memory we need"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2341
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2342
    textSize := self textSizeOf:oFile.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2343
    textSize isNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2344
	'bad text-size in object file' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2345
	^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2346
    ].
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
  2347
    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2348
	('text-size: ' , (textSize printStringRadix:16)) infoPrintNL
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2349
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2350
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2351
    dataSize := self dataSizeOf:oFile.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2352
    dataSize isNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2353
	'bad data-size in object file' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2354
	^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2355
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2356
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
  2357
    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2358
	('data-size: ' , (dataSize printStringRadix:16)) infoPrintNL
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2359
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2360
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2361
    "allocate some memory for text and some for data;
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2362
     then call linker to link the file to those addresses"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2363
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2364
    self needSeparateIDSpaces ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2365
	text := ExternalBytes newForText:textSize.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2366
	text isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2367
	    'cannot allocate memory for text' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2368
	    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2369
	].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2370
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2371
	Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2372
	    ('text: ' , (text address printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2373
	].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2374
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2375
	(dataSize ~~ 0) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2376
	    data := ExternalBytes newForData:dataSize.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2377
	    (data isNil) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2378
		'cannot allocate memory for data' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2379
		text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2380
		^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2381
	    ].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2382
	    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2383
		('data: ' , (data address printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2384
	    ]
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2385
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2386
	dataSize == 0 ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2387
	    unixCommand := (self absLd:oFile text:text address) , ' >/tmp/out 2>/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2388
	] ifFalse:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2389
	    unixCommand := (self absLd:oFile text:text address data:data address) 
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2390
			   , ' >/tmp/out 2>/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2391
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2392
    ] ifFalse:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2393
	text := ExternalBytes newForText:(textSize + dataSize).
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2394
	text isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2395
	    'cannot allocate memory for text+data' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2396
	    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2397
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2398
	Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2399
	    ('addr: ' , (text address printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2400
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2401
	unixCommand := (self absLd:oFile text:text address) , ' >/tmp/out 2>/tmp/err'.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2402
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2403
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
  2404
    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2405
	('executing: ' , unixCommand) infoPrintNL
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2406
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2407
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
  2408
    'linking ...' printNewline.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2409
    (OperatingSystem executeCommand:unixCommand) ifFalse: [
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2410
	errStream := FileStream oldFileNamed:'/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2411
	errStream notNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2412
	    errors := errStream contents.
58
15b00d1236db asText eliminated
claus
parents: 53
diff changeset
  2413
	    errText := errors asStringCollection.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2414
	    (errText size > 20) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2415
		errText grow:20.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2416
		errText add:'... '.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2417
		errors := errText
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2418
	    ].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2419
	    OperatingSystem executeCommand:'rm /tmp/err /tmp/out'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2420
	    self notify:('link errors:\\' , errors asString) withCRs
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2421
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2422
	'link unsuccessful.' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2423
	text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2424
	data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2425
	^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2426
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2427
95
claus
parents: 94
diff changeset
  2428
    'link successful' infoPrintNL.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2429
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2430
    OperatingSystem executeCommand:'rm /tmp/err /tmp/out'.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2431
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2432
    "find out, if space needs have changed after link (they do so on some machines)"
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2433
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2434
    newTextSize := self textSizeOf:'a.out'.
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2435
    newTextSize isNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2436
	'bad new-text-size in a.out object file' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2437
	text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2438
	data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2439
	^ nil
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2440
    ].
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
  2441
    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2442
	('new-text-size: ' , (newTextSize printStringRadix:16)) infoPrintNL
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2443
    ].
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2444
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2445
    newDataSize := self dataSizeOf:'a.out'.
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2446
    newDataSize isNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2447
	'bad new-data-size in a.out object file' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2448
	text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2449
	data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2450
	^ nil
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2451
    ].
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2452
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
  2453
    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2454
	('new-data-size: ' , (newDataSize printStringRadix:16)) infoPrintNL
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2455
    ].
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2456
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2457
    "if size has changed, do it again"
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2458
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2459
    ((newTextSize ~~ textSize) or:[newDataSize ~~ dataSize]) ifTrue:[
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2460
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2461
	'size changed after link - do it again' printNewline.
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2462
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2463
	text notNil ifTrue:[text free. text := nil].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2464
	data notNil ifTrue:[data free. data := nil].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2465
	textSize := newTextSize.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2466
	dataSize := newDataSize.
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2467
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2468
	self needSeparateIDSpaces ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2469
	    text := ExternalBytes newForText:textSize.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2470
	    text isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2471
		'cannot allocate memory for new text' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2472
		^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2473
	    ].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2474
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2475
	    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2476
		('new text: ' , (text address printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2477
	    ].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2478
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2479
	    (dataSize ~~ 0) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2480
		data := ExternalBytes newForData:dataSize.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2481
		(data isNil) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2482
		    'cannot allocate memory for new data' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2483
		    text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2484
		    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2485
		].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2486
		Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2487
		    ('new data: ' , (data address printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2488
		]
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2489
	    ].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2490
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2491
	    dataSize == 0 ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2492
		unixCommand := (self absLd:oFile text:text address) , ' >/tmp/out 2>/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2493
	    ] ifFalse:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2494
		unixCommand := (self absLd:oFile text:text address data:data address) 
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2495
			       , ' >/tmp/out 2>/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2496
	    ]
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2497
	] ifFalse:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2498
	    text := ExternalBytes newForText:(textSize + dataSize).
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2499
	    text isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2500
		'cannot allocate memory for new text' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2501
		^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2502
	    ].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2503
	    Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2504
		('new text+data: ' , (text address printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2505
	    ].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2506
	    unixCommand := (self absLd:oFile text:text address) , ' >/tmp/out 2>/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2507
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2508
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2509
	Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2510
	    ('executing: ' , unixCommand) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2511
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2512
95
claus
parents: 94
diff changeset
  2513
	'linking ...' infoPrintNL.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2514
	(OperatingSystem executeCommand:unixCommand) ifFalse: [
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2515
	    errStream := FileStream oldFileNamed:'/tmp/err'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2516
	    errStream notNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2517
		errors := errStream contents.
58
15b00d1236db asText eliminated
claus
parents: 53
diff changeset
  2518
		errText := errors asStringCollection.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2519
		(errText size > 20) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2520
		    errText grow:20.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2521
		    errText add:'... '.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2522
		    errors := errText
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2523
		].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2524
		OperatingSystem executeCommand:'rm /tmp/err /tmp/out'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2525
		self notify:('link errors:\\' , errors asString) withCRs
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2526
	    ].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2527
	    'link unsuccessful.' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2528
	    text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2529
	    data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2530
	    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2531
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2532
95
claus
parents: 94
diff changeset
  2533
	'link successful' infoPrintNL.
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2534
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2535
	OperatingSystem executeCommand:'rm /tmp/err /tmp/out'.
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2536
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2537
	"check again for size change - should not happen"
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2538
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2539
	newTextSize := self textSizeOf:'a.out'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2540
	newTextSize isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2541
	    'bad text-size in a.out object file' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2542
	    text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2543
	    data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2544
	    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2545
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2546
	Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2547
	    ('new-text-size: ' , (newTextSize printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2548
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2549
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2550
	newDataSize := self dataSizeOf:'a.out'.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2551
	newDataSize isNil ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2552
	    'bad data-size in object file' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2553
	    text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2554
	    data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2555
	    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2556
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2557
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2558
	Verbose ifTrue:[
95
claus
parents: 94
diff changeset
  2559
	    ('new-data-size: ' , (newDataSize printStringRadix:16)) infoPrintNL
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2560
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2561
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2562
	((newTextSize ~~ textSize) or:[newDataSize ~~ dataSize]) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2563
	    'size changed again - I give up' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2564
	    text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2565
	    data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2566
	    ^ nil
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2567
	].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2568
    ].
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2569
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2570
    "only thing left to do is to load in text at textAddr and
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2571
     data at dataAddr ... "
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2572
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2573
    text notNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2574
	textAddr := text address
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2575
    ] ifFalse:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2576
	textAddr := nil
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2577
    ].
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2578
    data notNil ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2579
	dataAddr := data address
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2580
    ] ifFalse:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2581
	dataAddr := nil
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2582
    ].
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2583
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
  2584
    Verbose ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2585
	textAddr notNil ifTrue:[
95
claus
parents: 94
diff changeset
  2586
	    ('loading ' , textSize printString , ' bytes at ' , (textAddr printStringRadix:16)) infoPrintNL.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2587
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2588
	dataAddr notNil ifTrue:[
95
claus
parents: 94
diff changeset
  2589
	    ('loading ' , dataSize printString , ' bytes at ' , (dataAddr printStringRadix:16)) infoPrintNL.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2590
	].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
  2591
    ].
6
0cd4e7480440 *** empty log message ***
claus
parents: 3
diff changeset
  2592
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2593
    (self loadObjectFile:'a.out'
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2594
		textAddr:textAddr textSize:textSize
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2595
		dataAddr:dataAddr dataSize:dataSize) isNil ifTrue: [
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2596
	'load error' errorPrintNL.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2597
	text notNil ifTrue:[text free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2598
	data notNil ifTrue:[data free].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2599
	^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2600
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2601
95
claus
parents: 94
diff changeset
  2602
    'dynamic load successful' infoPrintNL.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2603
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2604
    OperatingSystem executeCommand:'mv a.out SymbolTable'.
10
73e97b6175c4 *** empty log message ***
claus
parents: 6
diff changeset
  2605
    MySymbolTable := 'SymbolTable'.
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2606
    ^ (Array with:text with:data)
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2607
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2608
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2609
loadFile:oFile with:librariesString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2610
    "load in an object files code, linking in libraries.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2611
     This is only needed if no dynamic link facility exists."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2612
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2613
    |tmpOfile errStream errors errText handle pid cmd|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2614
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2615
    pid := OperatingSystem getProcessId printString.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2616
    tmpOfile := '/tmp/stc_ld' ,  pid.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2617
    cmd := 'ld -o ', tmpOfile, ' -r ' , oFile , ' ' , librariesString , '>/tmp/out 2>/tmp/err'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2618
    Verbose ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2619
	('executing: ld -o ', cmd) infoPrintNL
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2620
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2621
    (OperatingSystem executeCommand:cmd) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2622
	errStream := FileStream oldFileNamed:'/tmp/err'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2623
	errStream isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2624
	    self notify:'errors during link.'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2625
	] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2626
	    errors := errStream contents.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2627
	    errText := errors asStringCollection.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2628
	    (errText size > 20) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2629
		errText grow:20.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2630
		errText add:'... '.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2631
		errors := errText
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2632
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2633
	    OperatingSystem executeCommand:'rm /tmp/err /tmp/out'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2634
	    self notify:('link errors:\\' , errors asString) withCRs
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2635
	].
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2636
	^ false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2637
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2638
    handle := self loadFile:tmpOfile.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2639
    OperatingSystem executeCommand:('rm ' , tmpOfile).
15
992c3d87edbf *** empty log message ***
claus
parents: 10
diff changeset
  2640
    ^ handle
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2641
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2642
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2643
!ObjectFileLoader class methodsFor:'primitive loading'!
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2644
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2645
dataSizeOf:aFileName
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2646
    "
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2647
     get the size of the data-segment (nBytes)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2648
    "
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2649
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2650
%{  /* NOCONTEXT */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2651
#ifdef HAS_DL
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2652
    /*
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2653
     * not needed, if dynamic link facilities exist
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2654
     */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2655
#else /* no DL-support */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2656
    char *fname;
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2657
    int fd;
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2658
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2659
    if (! __isString(aFileName)) {
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2660
	RETURN ( nil );
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2661
    }
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2662
98
claus
parents: 97
diff changeset
  2663
    fname = (char *) __stringVal(aFileName);
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2664
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2665
# if defined(A_DOT_OUT) && !defined(ELF)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2666
#  if !defined(sco) && !defined(isc)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2667
    {
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2668
	struct exec header;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2669
	unsigned size;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2670
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2671
	if ((fd = open(fname, 0)) < 0) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2672
	    fprintf(stderr, "cannot open <%s>\n", fname);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2673
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2674
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2675
	if (read(fd, &header, sizeof(header)) != sizeof(header)) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2676
	    fprintf(stderr, "cannot read header of <%s>\n", fname);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2677
	    close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2678
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2679
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2680
	close(fd);
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2681
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2682
	if (N_MAGIC(header) != OMAGIC) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2683
	    fprintf(stderr, "header is (0%o) %x - should be (0%o)%x\n",
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2684
					N_MAGIC(header), N_MAGIC(header),
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2685
					OMAGIC, OMAGIC);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2686
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2687
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2688
	size = header.a_data;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2689
#   if defined(sinix) && defined(BSD)
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2690
	size += header.a_bss;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2691
#   endif
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2692
	RETURN ( _MKSMALLINT(size) );
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2693
    }
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2694
#  endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2695
# endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2696
    /*
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2697
     * need support for other headers ... (i.e. coff, elf)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2698
     */
175
f94969b034c7 make it compilable (at least) on WIN32 (which defines COFF ?!)
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2699
#endif /* not HAS_DL */
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2700
%}
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2701
.
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2702
    ^ self error:'objectFile format not supported'
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2703
!
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2704
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2705
loadObjectFile:aFileName textAddr:textAddr textSize:textSize
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2706
			 dataAddr:dataAddr dataSize:dataSize
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2707
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2708
    "the object in aFileName must have been linked for
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2709
     absolute address textAddr/dataAddr (using ld -A).
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2710
     Load the contents from the file. Memory must have previously
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2711
     been allocated using ExternalBytes."
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2712
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2713
%{  /* NOCONTEXT */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2714
#ifdef HAS_DL
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2715
    /*
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2716
     * not needed, if dynamic link facilities exist
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2717
     */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2718
#else /* no DL-support */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2719
    if (! __isString(aFileName)) {
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2720
	RETURN ( nil );
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2721
    }
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2722
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2723
# if defined(A_DOT_OUT) && !defined(ELF)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2724
#  if !defined(sco) && !defined(isc)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2725
    {
98
claus
parents: 97
diff changeset
  2726
	char *fname = (char *) __stringVal(aFileName);
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2727
	unsigned taddr, daddr;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2728
	unsigned tsize, dsize;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2729
	unsigned toffset = 0;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2730
	unsigned doffset = 0;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2731
	int fd;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2732
	struct exec header;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2733
	char *cp;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2734
	int bssCount;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2735
	unsigned magic = OMAGIC;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2736
	int nread;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2737
60
0db697f03def *** empty log message ***
claus
parents: 58
diff changeset
  2738
	taddr = __isSmallInteger(textAddr) ? (unsigned) _intVal(textAddr) : 0;
0db697f03def *** empty log message ***
claus
parents: 58
diff changeset
  2739
	daddr = __isSmallInteger(dataAddr) ? (unsigned) _intVal(dataAddr) : 0;
0db697f03def *** empty log message ***
claus
parents: 58
diff changeset
  2740
	tsize = __isSmallInteger(textSize) ? _intVal(textSize) : 0;
0db697f03def *** empty log message ***
claus
parents: 58
diff changeset
  2741
	dsize = __isSmallInteger(dataSize) ? _intVal(dataSize) : 0;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2742
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2743
	if ((fd = open(fname, 0)) < 0)  {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2744
	    fprintf(stderr, "cannot open <%s>\n", fname);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2745
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2746
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2747
	if (read(fd, &header, sizeof(header)) != sizeof(header)) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2748
	    fprintf(stderr, "cannot read header of <%s>\n", fname);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2749
	    close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2750
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2751
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2752
	if (N_MAGIC(header) != magic) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2753
	    fprintf(stderr, "header is (0%o) %x should be (0%o) %x\n",
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2754
					N_MAGIC(header), N_MAGIC(header),
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2755
					magic, magic);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2756
	    close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2757
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2758
	}
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2759
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2760
	/*
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2761
	 * some linkers produce a huge output file, with zeros up to the
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2762
	 * real code ... - thats what toffset, doffset are for.
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2763
	 */
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2764
#   if defined(sinix) && defined(BSD)
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2765
	toffset = N_TXTADDR(header);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2766
	doffset = toffset + taddr + tsize /* - 0x800 */;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2767
	daddr = taddr + tsize;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2768
#   else
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2769
#    if defined(mips) && defined(ultrix)
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2770
	toffset = N_TXTOFF(header.ex_f, header.ex_o);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2771
	doffset = toffset + tsize;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2772
	daddr = taddr + tsize;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2773
#    else
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2774
#     if defined(N_TXTOFF)
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2775
	toffset = N_TXTOFF(header);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2776
	doffset = N_DATOFF(header);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2777
	daddr = taddr + tsize;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2778
#     else
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2779
	fprintf(stderr, "dont know text/data offsets in objectfile\n");
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2780
	RETURN ( nil );
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2781
#     endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2782
#    endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2783
#   endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2784
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2785
#   ifdef SUPERDEBUG
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2786
	printf("toffs:%x taddr:%x tsize:%d doffs:%x daddr:%x dsize:%d\n",
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2787
		toffset, taddr, tsize, doffset,daddr, dsize);
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2788
#   endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2789
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2790
	if (lseek(fd, (long)toffset, 0) < 0) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2791
	    fprintf(stderr, "cannot seek to text\n");
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2792
	    close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2793
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2794
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2795
	if ((nread = read(fd, taddr, tsize)) != tsize) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2796
	    perror("read");
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2797
	    fprintf(stderr, "cannot read text wanted:%d got:%d\n", tsize, nread);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2798
	    close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2799
	    RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2800
	}
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2801
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2802
#   ifdef SUPERDEBUG
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2803
	printf("1st bytes of text: %02x %02x %02x %02x\n",
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2804
		*((char *)taddr) & 0xFF, *((char *)taddr+1) & 0xFF,
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2805
		*((char *)taddr+2) & 0xFF, *((char *)taddr+3) & 0xFF);
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2806
#   endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2807
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2808
	if (dsize) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2809
	    if (lseek(fd, (long)doffset, 0) < 0) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2810
		fprintf(stderr, "cannot seek to data\n");
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2811
		close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2812
		RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2813
	    }
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2814
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2815
	    if (read(fd, daddr, dsize) != dsize) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2816
		fprintf(stderr, "cannot read data\n");
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2817
		close(fd);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2818
		RETURN ( nil );
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2819
	    }
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2820
#   ifdef SUPERDEBUG
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2821
	    {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2822
		char *ptr;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2823
		int i;
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2824
    
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2825
		ptr = (char *)daddr;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2826
		fprintf(stderr, "bytes of data (at %x):\n", ptr);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2827
		for (i=dsize; i>0; i--, ptr++)
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2828
		    printf("%02x ", *ptr & 0xFF);
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2829
	    }
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2830
#   endif
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2831
	}
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2832
	close(fd);
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2833
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2834
#   ifdef NOTDEF
45
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2835
	if (header.a_bss != 0) {
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2836
	    fprintf(stderr, "warning: bss not empty\n");
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2837
	    cp = ((char *)daddr) + header.a_data;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2838
	    for (bssCount=header.a_bss; bssCount; bssCount--)
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2839
		*cp++ = 0;
e8331ba8ad5d *** empty log message ***
claus
parents: 37
diff changeset
  2840
	}
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2841
#   endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2842
    }
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2843
    RETURN ( self );
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2844
#  endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2845
# endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2846
    /*
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2847
     * need support for other headers ... (i.e. coff, elf)
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2848
     */
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2849
#endif
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2850
%}.
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2851
    ^ self error:'objectFile format not supported'
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2852
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2853
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2854
textSizeOf:aFileName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2855
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2856
     get the size of the text-segment (nBytes)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2857
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2858
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2859
%{  /* NOCONTEXT */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2860
#ifdef HAS_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2861
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2862
     * not needed, if dynamic link facilities exist
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2863
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2864
#else /* no DL-support */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2865
    char *fname;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2866
    int fd;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2867
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2868
    if (! __isString(aFileName)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2869
	RETURN (nil);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2870
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2871
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2872
    fname = (char *) __stringVal(aFileName);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2873
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2874
# if defined(A_DOT_OUT) && !defined(ELF)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2875
#  if !defined(sco) && !defined(isc)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2876
    {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2877
	struct exec header;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2878
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2879
	if ((fd = open(fname, 0)) < 0) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2880
	    fprintf(stderr, "cannot open <%s>\n", fname);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2881
	    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2882
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2883
	if (read(fd, &header, sizeof(header)) != sizeof(header)) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2884
	    fprintf(stderr, "cannot read header of <%s>\n", fname);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2885
	    close(fd);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2886
	    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2887
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2888
	close(fd);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2889
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2890
	if (N_MAGIC(header) != OMAGIC) {
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2891
	    fprintf(stderr, "header is (0%o) %x - should be (0%o)%x\n",
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2892
					N_MAGIC(header), N_MAGIC(header),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2893
					OMAGIC, OMAGIC);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2894
	    RETURN ( nil );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2895
	}
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2896
	RETURN ( _MKSMALLINT(header.a_text) );
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2897
    }
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2898
#  endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2899
# endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2900
    /*
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2901
     * need support for other headers ... (i.e. coff, elf)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2902
     */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2903
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2904
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2905
    ^ self error:'objectFile format not supported'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2906
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2907
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2908
!ObjectFileLoader class methodsFor:'queries'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2909
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2910
canLoadObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2911
    "return true, if loading is possible"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2912
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2913
    self primCanLoadObjectFiles ifTrue:[^true].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2914
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2915
    "/ 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
  2916
    "/ for some specific machine
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2917
    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2918
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2919
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2920
loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2921
    "return a collection containing the names of all
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2922
     dynamically loaded objects."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2923
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2924
    LoadedObjects isNil ifTrue:[^ #()].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2925
    ^ LoadedObjects keys copy
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2926
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2927
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2928
     ObjectFileLoader loadedObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2929
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2930
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2931
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2932
loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2933
    "return a collection of all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2934
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2935
    LoadedObjects isNil ifTrue:[^ #()].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2936
    ^ LoadedObjects 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2937
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2938
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2939
     ObjectFileLoader loadedObjectHandles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2940
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2941
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2942
    "Created: 17.9.1995 / 14:28:55 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2943
    "Modified: 17.9.1995 / 16:13:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2944
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2945
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2946
loadedObjectHandlesDo:aBlock
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2947
    "enumerate all handles"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2948
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2949
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2950
	LoadedObjects copy do:aBlock.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2951
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2952
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2953
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2954
     ObjectFileLoader loadedObjectHandlesDo:[:h | h pathName printNL]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2955
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2956
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2957
    "Created: 14.9.1995 / 22:03:13 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2958
    "Modified: 14.9.1995 / 22:32:48 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2959
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2960
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2961
pathNameFromID:id
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2962
    "given an id, return the pathName, or nil for static modules"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2963
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2964
    LoadedObjects notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2965
	LoadedObjects keysAndValuesDo:[:name :handle |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2966
	    handle moduleID == id ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2967
		^ handle pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2968
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2969
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2970
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2971
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2972
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2973
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2974
     ObjectFileLoader pathNameFromID:1        
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2975
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2976
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2977
    "Modified: 28.8.1995 / 18:08:28 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2978
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2979
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2980
primCanLoadObjectFiles
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2981
    "return true, if loading is possible using a standard mechanism"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2982
%{  /* NOCONTEXT */
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2983
#ifdef HAS_DL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2984
# if !defined(OS_DEFINE) || defined(unknownOS)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2985
    fprintf(stderr, "*** OS_DEFINE not correct\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2986
# else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2987
#  if !defined(CPU_DEFINE) || defined(unknownCPU)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2988
    fprintf(stderr, "*** CPU_DEFINE not correct\n");
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2989
#  else
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2990
    RETURN (true);
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2991
#  endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2992
# endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2993
#endif
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2994
%}.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  2995
    ^ false
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2996
! !
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
  2997
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  2998
!ObjectFileLoader class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  2999
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  3000
version
180
a38d34ef8bde dynamic load works on NT !
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
  3001
    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.71 1995-12-26 18:43:21 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 147
diff changeset
  3002
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  3003
ObjectFileLoader initialize!