win32 error message if LoadLibrary fails
authorClaus Gittinger <cg@exept.de>
Wed, 05 May 1999 14:29:41 +0200
changeset 846 8d1a4228c0e3
parent 845 e9da9bd2bc27
child 847 7decf59c15ba
win32 error message if LoadLibrary fails
ObjFLoader.st
ObjectFileLoader.st
--- a/ObjFLoader.st	Tue May 04 17:19:00 1999 +0200
+++ b/ObjFLoader.st	Wed May 05 14:29:41 1999 +0200
@@ -246,13 +246,13 @@
       robustness.
 
     There are basically two totally different mechanisms to do this:
-        a) if there exists some dynamic-link facility such as:
-           GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
-           or LoadLibrary (Win32), this is used
-
-        b) if no such facility exists, the normal linker is used to
-           link the module to text/data address as previously malloced,
-           and the object file loaded into that space.
+	a) if there exists some dynamic-link facility such as:
+	   GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
+	   or LoadLibrary (Win32), this is used
+
+	b) if no such facility exists, the normal linker is used to
+	   link the module to text/data address as previously malloced,
+	   and the object file loaded into that space.
            
     Currently, not all mechanisms work fully satisfying.
     For example, the sun dl*-functions do an exit on link-errors (which
@@ -279,7 +279,7 @@
     loaded at image restart time).
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 "
 ! !
 
@@ -289,94 +289,94 @@
     |systemType|
 
     OperatingSystem isMSDOSlike ifTrue:[
-        "/ default setup for msc
-        OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
-            LinkCommand isNil ifTrue:[
-                LinkCommand := 'tlink32'.
-                LinkCommand := 'ilink32'.
-            ].
-            LinkArgs isNil ifTrue:[
-                LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ..\libbc\librun.lib'.
-                LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'.
-            ].
-            SearchedLibraries := #(
-                                    'import32.lib'
-                                  ).
-        ] ifFalse:[
-            LinkCommand isNil ifTrue:[
-                LinkCommand := 'link'
-            ].
-            LinkArgs isNil ifTrue:[
-                LinkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
-            ].
-        ].
+	"/ default setup for msc
+	OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
+	    LinkCommand isNil ifTrue:[
+		LinkCommand := 'tlink32'.
+		LinkCommand := 'ilink32'.
+	    ].
+	    LinkArgs isNil ifTrue:[
+		LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ..\libbc\librun.lib'.
+		LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'.
+	    ].
+	    SearchedLibraries := #(
+				    'import32.lib'
+				  ).
+	] ifFalse:[
+	    LinkCommand isNil ifTrue:[
+		LinkCommand := 'link'
+	    ].
+	    LinkArgs isNil ifTrue:[
+		LinkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
+	    ].
+	].
     ].
 
     MySymbolTable isNil ifTrue:[
-        Verbose := false.
-        NextHandleID := 1.
-        ObjectMemory addDependent:self.
-
-        OperatingSystem isMSDOSlike ifTrue:[
-            SearchedLibraries := #(
-                                    'import32.lib'
-                                  ).
-        ].
-
-        OperatingSystem isUNIXlike ifTrue:[
-            systemType := OperatingSystem getOSType.
-
-            "/ name of object file, where initial symbol table is found
-            "/ not req'd for all architectures.
-
-            MySymbolTable := 'stx'.
-
-            "/ default set of libraries to be considered when
-            "/ unresolved symbols are encountered during the load.
-            "/ Only req'd for linux and sunos non-ELF systems.
-            "/ Can (should) be set in the smalltalk.rc file.
-
-            SearchedLibraries := #().
-
-            (systemType = 'linux' 
-            or:[systemType = 'sunos']) ifTrue:[
-                '/usr/lib/libc.a' asFilename isReadable ifTrue:[
-                    SearchedLibraries := #('/usr/lib/libc.a')
-                ] ifFalse:[
-                    '/lib/libc.a' asFilename isReadable ifTrue:[
-                        SearchedLibraries := #('/lib/libc.a')
-                    ]
-                ]
-            ].
-
-            "/ default libraryPath where shared objects are searched for
-            "/ when a dynamic library is loaded without an explicit path.
-
-            LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
-            LoadLibraryPath isNil ifTrue:[
-                LoadLibraryPath := #('.'
-                                     'lib'
-                                     '/usr/local/smalltalk/lib'
-                                     '/usr/local/lib'
-                                     '/usr/lib'
-                                     '/lib'
-                                    ) asOrderedCollection.
-            ].
-
-            "/ default libraryPath where shared objects are expected
-            "/ when a sharedObject load requires other objects to be loaded.
-            "/ Only req'd for aix.
-            "/ For more compatibility with ELF systems, look for a shell variable
-            "/ named LD_LIBRARY_PATH, and - if present - take that instead if a default.
-            "/ Can (should) be set in the smalltalk.rc file.
-
-            systemType = 'aix' ifTrue:[
-                LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
-                LibPath isNil ifTrue:[
-                    LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'.
-                ]
-            ].
-        ]
+	Verbose := false.
+	NextHandleID := 1.
+	ObjectMemory addDependent:self.
+
+	OperatingSystem isMSDOSlike ifTrue:[
+	    SearchedLibraries := #(
+				    'import32.lib'
+				  ).
+	].
+
+	OperatingSystem isUNIXlike ifTrue:[
+	    systemType := OperatingSystem getOSType.
+
+	    "/ name of object file, where initial symbol table is found
+	    "/ not req'd for all architectures.
+
+	    MySymbolTable := 'stx'.
+
+	    "/ default set of libraries to be considered when
+	    "/ unresolved symbols are encountered during the load.
+	    "/ Only req'd for linux and sunos non-ELF systems.
+	    "/ Can (should) be set in the smalltalk.rc file.
+
+	    SearchedLibraries := #().
+
+	    (systemType = 'linux' 
+	    or:[systemType = 'sunos']) ifTrue:[
+		'/usr/lib/libc.a' asFilename isReadable ifTrue:[
+		    SearchedLibraries := #('/usr/lib/libc.a')
+		] ifFalse:[
+		    '/lib/libc.a' asFilename isReadable ifTrue:[
+			SearchedLibraries := #('/lib/libc.a')
+		    ]
+		]
+	    ].
+
+	    "/ default libraryPath where shared objects are searched for
+	    "/ when a dynamic library is loaded without an explicit path.
+
+	    LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
+	    LoadLibraryPath isNil ifTrue:[
+		LoadLibraryPath := #('.'
+				     'lib'
+				     '/usr/local/smalltalk/lib'
+				     '/usr/local/lib'
+				     '/usr/lib'
+				     '/lib'
+				    ) asOrderedCollection.
+	    ].
+
+	    "/ default libraryPath where shared objects are expected
+	    "/ when a sharedObject load requires other objects to be loaded.
+	    "/ Only req'd for aix.
+	    "/ For more compatibility with ELF systems, look for a shell variable
+	    "/ named LD_LIBRARY_PATH, and - if present - take that instead if a default.
+	    "/ Can (should) be set in the smalltalk.rc file.
+
+	    systemType = 'aix' ifTrue:[
+		LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
+		LibPath isNil ifTrue:[
+		    LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'.
+		]
+	    ].
+	]
     ]
 
     "
@@ -483,7 +483,7 @@
 
     fn := aFilename asFilename.
     self validBinaryExtensions do:[:ext |
-        (fn hasSuffix:ext) ifTrue:[^ true].
+	(fn hasSuffix:ext) ifTrue:[^ true].
     ].
     ^ false
 
@@ -682,11 +682,11 @@
     |os|
 
     OperatingSystem isMSDOSlike ifTrue:[
-        "/ includes all of win32s, win95, winNT & os/2
-        ^ #('dll')
+	"/ includes all of win32s, win95, winNT & os/2
+	^ #('dll')
     ].
     OperatingSystem isVMSlike ifTrue:[
-        ^ #('exe')
+	^ #('exe')
     ].
 
     os := OperatingSystem getSystemType.
@@ -697,10 +697,10 @@
     (os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ].
     (os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ].
     (os = 'linux') ifTrue:[
-        self loadableBinaryObjectFormat == #aout ifTrue:[
-            ^ #('o' 'obj' 'a')
-        ].
-        ^ #('so' 'o' 'obj' ) 
+	self loadableBinaryObjectFormat == #aout ifTrue:[
+	    ^ #('o' 'obj' 'a')
+	].
+	^ #('so' 'o' 'obj' ) 
     ].
     (os = 'aix') ifTrue:[^ #('o' 'so') ].
     (os = 'hpux') ifTrue:[^ #(" 'o' " 'sl') ].
@@ -974,43 +974,43 @@
 
     libFilename := aLibraryFileName asFilename.
     (s := libFilename suffix) isEmpty ifTrue:[
-        suffixes := self validBinaryExtensions
+	suffixes := self validBinaryExtensions
     ] ifFalse:[
-        suffixes := #('')
+	suffixes := #('')
     ].
 
     "/ try each suffix ...
     suffixes do:[:aSuffix | 
-        |fn f|
-
-        fn := aLibraryFileName , '.' , aSuffix.
-
-        (libFilename isAbsolute 
-        or:[(aLibraryFileName startsWith:'./')
-        or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
-            f := fn asFilename.
-            f exists ifTrue:[
-                handle := self loadObjectFile:fn.
-                handle notNil ifTrue:[^ handle].
-            ]
-        ] ifFalse:[
-            "/ try each directory    
-            LoadLibraryPath size > 0 ifTrue:[
-                (LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) 
-                do:[:aDir |
-                    f := aDir asFilename construct:fn.
-                    f exists ifTrue:[
-                        handle := self loadObjectFile:f pathName.
-                        handle notNil ifTrue:[^ handle].
-                    ]
-                ]
-            ].
-            "/ try to load it by name - maybe someone else knows
-            "/ how to find it (the system itself)
-
-            handle := self loadObjectFile:fn.
-            handle notNil ifTrue:[^ handle].
-        ]
+	|fn f|
+
+	fn := aLibraryFileName , '.' , aSuffix.
+
+	(libFilename isAbsolute 
+	or:[(aLibraryFileName startsWith:'./')
+	or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
+	    f := fn asFilename.
+	    f exists ifTrue:[
+		handle := self loadObjectFile:fn.
+		handle notNil ifTrue:[^ handle].
+	    ]
+	] ifFalse:[
+	    "/ try each directory    
+	    LoadLibraryPath size > 0 ifTrue:[
+		(LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) 
+		do:[:aDir |
+		    f := aDir asFilename construct:fn.
+		    f exists ifTrue:[
+			handle := self loadObjectFile:f pathName.
+			handle notNil ifTrue:[^ handle].
+		    ]
+		]
+	    ].
+	    "/ try to load it by name - maybe someone else knows
+	    "/ how to find it (the system itself)
+
+	    handle := self loadObjectFile:fn.
+	    handle notNil ifTrue:[^ handle].
+	]
     ].
 
     ^ nil
@@ -1035,7 +1035,7 @@
     "/
     handle := self loadDynamicObject:aFileName.
     handle isNil ifTrue:[
-        ^ nil
+	^ nil
     ].
 
     "/
@@ -1045,39 +1045,39 @@
 
     initAddr := self getFunction:'__' , initName , '_Init' from:handle.
     initAddr isNil ifTrue:[
-        initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
-        initAddr isNil ifTrue:[
-            (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
-                self listUndefinedSymbolsIn:handle.
-                'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR.
-            ] ifFalse:[
-                ('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
-            ].
-
-            "/
-            "/ not found - unload
-            "/
-            self unloadDynamicObject:handle.
-            ^ nil
-        ]
+	initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
+	initAddr isNil ifTrue:[
+	    (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
+		self listUndefinedSymbolsIn:handle.
+		'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR.
+	    ] ifFalse:[
+		('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
+	    ].
+
+	    "/
+	    "/ not found - unload
+	    "/
+	    self unloadDynamicObject:handle.
+	    ^ nil
+	]
     ].
 
     Object osSignalInterruptSignal handle:[:ex |
-        ('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
-        self unloadDynamicObject:handle.
-        ^ nil
+	('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
+	self unloadDynamicObject:handle.
+	^ nil
     ] do:[
-        "/
-        "/ call it - it returns the new method object
-        "/
-        m := self
-            callInitFunctionAt:initAddr 
-            specialInit:true
-            forceOld:true 
-            interruptable:false
-            argument:2
-            identifyAs:handle
-            returnsObject:true.
+	"/
+	"/ call it - it returns the new method object
+	"/
+	m := self
+	    callInitFunctionAt:initAddr 
+	    specialInit:true
+	    forceOld:true 
+	    interruptable:false
+	    argument:2
+	    identifyAs:handle
+	    returnsObject:true.
     ].
 
     handle method:m.
@@ -1101,13 +1101,13 @@
 
     handle := self loadDynamicObject:aFileName.
     handle isNil ifTrue:[
-        Transcript showCR:('failed to load: ' , aFileName).
-        ('ObjectFileLoader [warning]: '
-         , aFileName
-         , ' failed. ('
-         , LinkErrorMessage
-         , ')') errorPrintCR.
-        ^ nil
+	Transcript showCR:('failed to load: ' , aFileName).
+	('ObjectFileLoader [warning]: '
+	 , aFileName
+	 , ' failed. ('
+	 , LinkErrorMessage
+	 , ')') errorPrintCR.
+	^ nil
     ].
 
     didInit := false.
@@ -1117,23 +1117,23 @@
     "/ are to be resolved. If thats the case, load all libraries ...
 
     SearchedLibraries notNil ifTrue:[
-        (self hasUndefinedSymbolsIn:handle) ifTrue:[
-            self initializeLoader.
-
-            SearchedLibraries do:[:libName |
-                (self hasUndefinedSymbolsIn:handle) ifTrue:[
-                    Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
-                    dummyHandle := Array new:4.
-                    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
+	(self hasUndefinedSymbolsIn:handle) ifTrue:[
+	    self initializeLoader.
+
+	    SearchedLibraries do:[:libName |
+		(self hasUndefinedSymbolsIn:handle) ifTrue:[
+		    Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
+		    dummyHandle := Array new:4.
+		    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
 "/                    dummyHandle isNil ifTrue:[
 "/                        Transcript showCR:'   ... load of library ' , libName , ' failed.'.
 "/                    ]
-                ]
-            ].
-            (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
-                Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.').
-            ].
-        ]
+		]
+	    ].
+	    (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
+		Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.').
+	    ].
+	]
     ].
 
     "
@@ -1151,113 +1151,113 @@
     initAddr := self findInitFunction:className in:handle.
 
     initAddr notNil ifTrue:[
-        Verbose ifTrue:[
-            ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR.
-        ].
-        info := self performModuleInitAt:initAddr for:nil identifyAs:handle.
-        status := info at:1.
-        status == #ok ifTrue:[
-            didInit := true.
-        ]
+	Verbose ifTrue:[
+	    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR.
+	].
+	info := self performModuleInitAt:initAddr for:nil identifyAs:handle.
+	status := info at:1.
+	status == #ok ifTrue:[
+	    didInit := true.
+	]
     ] ifFalse:[
-        "/
-        "/ look for explicit C-init (xxx__Init) function
-        "/ This is used in C object files
-        "/
-        initAddr := self findFunction:className suffix:'__Init' in:handle.
-        initAddr notNil ifTrue:[
-            isCModule := true.
-
-            Object osSignalInterruptSignal handle:[:ex |
-                ('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , aFileName) errorPrintCR.
-                status := #initFailed.
-            ] do:[
-                (self callInitFunctionAt:initAddr 
-                     specialInit:false 
-                     forceOld:true 
-                     interruptable:false
-                     argument:0
-                     identifyAs:handle
-                     returnsObject:false) < 0 ifTrue:[
-
-                    Verbose ifTrue:[
-                        'init function return failure ... unload' infoPrintCR.
-                    ].
-                    status := #initFailed.
-                ] ifFalse:[
-                    didInit := true.
-                ]
-            ]
-        ] ifFalse:[
-            status := #noInitFunction.
-
-            "
-             look for any init-function(s); call them all
-            "
-            Verbose ifTrue:[
-                'no good init functions found; looking for candidates ...' infoPrintCR.
-            ].
-            initNames := self namesMatching:'*_Init' segment:'[tT?]' in:aFileName.
-            initNames notNil ifTrue:[
-                initNames do:[:aName |
-                    initAddr := self getFunction:aName from:handle.
-                    initAddr isNil ifTrue:[
-                        (aName startsWith:'_') ifTrue:[
-                            initAddr := self getFunction:(aName copyFrom:2) from:handle.
-                        ].
-                    ].
-                    initAddr isNil ifTrue:[
-                        Transcript showCR:('no symbol: ',aName,' in ',aFileName).
-                    ] ifFalse:[
-                        Verbose ifTrue:[
-                            ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR
-                        ].
-                        self performModuleInitAt:initAddr for:nil identifyAs:handle.
-                        didInit := true.
-                    ]
-                ].
-            ].
-        ]
+	"/
+	"/ look for explicit C-init (xxx__Init) function
+	"/ This is used in C object files
+	"/
+	initAddr := self findFunction:className suffix:'__Init' in:handle.
+	initAddr notNil ifTrue:[
+	    isCModule := true.
+
+	    Object osSignalInterruptSignal handle:[:ex |
+		('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , aFileName) errorPrintCR.
+		status := #initFailed.
+	    ] do:[
+		(self callInitFunctionAt:initAddr 
+		     specialInit:false 
+		     forceOld:true 
+		     interruptable:false
+		     argument:0
+		     identifyAs:handle
+		     returnsObject:false) < 0 ifTrue:[
+
+		    Verbose ifTrue:[
+			'init function return failure ... unload' infoPrintCR.
+		    ].
+		    status := #initFailed.
+		] ifFalse:[
+		    didInit := true.
+		]
+	    ]
+	] ifFalse:[
+	    status := #noInitFunction.
+
+	    "
+	     look for any init-function(s); call them all
+	    "
+	    Verbose ifTrue:[
+		'no good init functions found; looking for candidates ...' infoPrintCR.
+	    ].
+	    initNames := self namesMatching:'*_Init' segment:'[tT?]' in:aFileName.
+	    initNames notNil ifTrue:[
+		initNames do:[:aName |
+		    initAddr := self getFunction:aName from:handle.
+		    initAddr isNil ifTrue:[
+			(aName startsWith:'_') ifTrue:[
+			    initAddr := self getFunction:(aName copyFrom:2) from:handle.
+			].
+		    ].
+		    initAddr isNil ifTrue:[
+			Transcript showCR:('no symbol: ',aName,' in ',aFileName).
+		    ] ifFalse:[
+			Verbose ifTrue:[
+			    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR
+			].
+			self performModuleInitAt:initAddr for:nil identifyAs:handle.
+			didInit := true.
+		    ]
+		].
+	    ].
+	]
     ].
 
     didInit ifFalse:[
-        status == #noInitFunction ifTrue:[
-            msg := 'LOADER: no init function; assume load ok'
-        ] ifFalse:[
-
-            status == #registrationFailed ifTrue:[
-                Transcript showCR:'LOADER:incompatible object (recompile without commonSymbols ?)'
-            ].
-            status ~~ #initFailed ifTrue:[
-                self listUndefinedSymbolsIn:handle.
-            ].
-
-            Verbose ifTrue:[
-                'unloading, since init failed ...' infoPrintCR.
-            ].
-            self unloadDynamicObject:handle.
-            handle := nil.
-
-            status == #initFailed ifTrue:[
-                msg := 'LOADER: module not loaded (init function signalled failure).'
-            ] ifFalse:[
-                (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:aFileName) notNil ifTrue:[
-                    msg := 'LOADER: module not loaded (no _Init entry - looks like an incomplete sepInitCode object).'
-                ] ifFalse:[
-                    msg := 'LOADER: module not loaded (no _Init entry in object file ?).'
-                ].
-            ].
-        ].
-        Transcript showCR:msg
+	status == #noInitFunction ifTrue:[
+	    msg := 'LOADER: no init function; assume load ok'
+	] ifFalse:[
+
+	    status == #registrationFailed ifTrue:[
+		Transcript showCR:'LOADER:incompatible object (recompile without commonSymbols ?)'
+	    ].
+	    status ~~ #initFailed ifTrue:[
+		self listUndefinedSymbolsIn:handle.
+	    ].
+
+	    Verbose ifTrue:[
+		'unloading, since init failed ...' infoPrintCR.
+	    ].
+	    self unloadDynamicObject:handle.
+	    handle := nil.
+
+	    status == #initFailed ifTrue:[
+		msg := 'LOADER: module not loaded (init function signalled failure).'
+	    ] ifFalse:[
+		(self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:aFileName) notNil ifTrue:[
+		    msg := 'LOADER: module not loaded (no _Init entry - looks like an incomplete sepInitCode object).'
+		] ifFalse:[
+		    msg := 'LOADER: module not loaded (no _Init entry in object file ?).'
+		].
+	    ].
+	].
+	Transcript showCR:msg
     ].
 
     isCModule ifFalse:[
-        Smalltalk isInitialized ifTrue:[
-            "
-             really dont know, if it has changed ...
-            "
-            Smalltalk changed.
-        ]
+	Smalltalk isInitialized ifTrue:[
+	    "
+	     really dont know, if it has changed ...
+	    "
+	    Smalltalk changed.
+	]
     ].
     ^ handle
 
@@ -1844,16 +1844,16 @@
     name := aFileName asFilename.
     suffixLen := 0.
     self validBinaryExtensions do:[:suffix |
-        suffixLen == 0 ifTrue:[
-            (name hasSuffix:suffix) ifTrue:[
-                suffixLen := suffix size + 1
-            ]
-        ]
+	suffixLen == 0 ifTrue:[
+	    (name hasSuffix:suffix) ifTrue:[
+		suffixLen := suffix size + 1
+	    ]
+	]
     ].
     name := name baseName.
 
     suffixLen ~~ 0 ifTrue:[
-        name := name copyWithoutLast:suffixLen
+	name := name copyWithoutLast:suffixLen
     ].
     ^ name.
 
@@ -2348,87 +2348,87 @@
     osType := OperatingSystem getOSType.
 
     osType = 'win32' ifTrue:[
-        self activityNotification:'create def file'.
-
-        "/ create a .def file.
-        expFileName := '.\' , baseFileName , '.def'.
-
-        expFile := expFileName asFilename writeStream.
-        expFile notNil ifTrue:[
-            OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
-                expFile nextPutLine:'LIBRARY ' , baseFileName.
-                expFile nextPutLine:'SEGMENTS'.
-                expFile nextPutLine:'    INITCODE PRELOAD SHARED'.
+	self activityNotification:'create def file'.
+
+	"/ create a .def file.
+	expFileName := '.\' , baseFileName , '.def'.
+
+	expFile := expFileName asFilename writeStream.
+	expFile notNil ifTrue:[
+	    OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
+		expFile nextPutLine:'LIBRARY ' , baseFileName.
+		expFile nextPutLine:'SEGMENTS'.
+		expFile nextPutLine:'    INITCODE PRELOAD SHARED'.
 "/                expFile nextPutLine:'    INITDATA READ WRITE'.
-                expFile nextPutLine:'EXPORTS'.
-                expFile nextPutLine:' __' , baseFileName , '_Init'.
-            ] ifFalse:[
-                expFile nextPutLine:'LIBRARY ' , baseFileName.
-                expFile nextPutLine:'CODE EXECUTE READ SHARED'.
-                expFile nextPutLine:'DATA READ WRITE'.
-                expFile nextPutLine:'SECTIONS'.
-                expFile nextPutLine:' INITCODE READ EXECUTE SHARED'.
-                expFile nextPutLine:' INITDATA READ WRITE'.
-                expFile nextPutLine:' RODATA READ SHARED'.
-                expFile nextPutLine:'EXPORTS'.
-                expFile nextPutLine:' _' , baseFileName , '_Init'.
-                expFile nextPutLine:'IMPORTS'.
-            ].
-            expFile close.
-        ].
-
-        self activityNotification:'generating shared object'.
-
-        LinkArgs isNil ifTrue:[
-            ld := LinkCommand , ' ' , baseFileName , '.obj'.
-            ld := ld
-               , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
-               , ' /OUT:' , baseFileName , '.dll '
-               , ' /DEF:' , baseFileName , '.def'.
-        ] ifFalse:[
-            OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
-                ld := LinkCommand , ' ' , (LinkArgs bindWith:baseFileName).
-                ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
-                ld := ld , ',' , baseFileName , '.dll,,..\libbc\librun.lib '.
-                ld := ld , (SearchedLibraries asStringCollection asStringWith: $ ).
-                ld := ld , ' ..\libbc\stxc32i.lib,,'.
-            ] ifFalse:[
-                LastError := 'currently only support borlandC'.
-                self halt:'currently only support borlandC'.
-                ^ nil
-            ]
-        ].
-
-        outfile := (baseFileName , '.out').
-        OperatingSystem isMSWINDOWSNTlike ifTrue:[
-            ok := OperatingSystem executeCommand:ld
-        ] ifFalse:[
-            ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
-
-            ok ifFalse:[
-                output := (baseFileName , '.out') asFilename contents asString.
-                Transcript showCR:output; endEntry.
-            ]
-        ].
-
-        (baseFileName , '.out') asFilename delete.
-        (baseFileName , '.tds') asFilename delete.
-        (baseFileName , '.ilc') asFilename delete.
-        (baseFileName , '.ild') asFilename delete.
-        (baseFileName , '.ilf') asFilename delete.
-        (baseFileName , '.ils') asFilename delete.
-        (baseFileName , '.lib') asFilename delete.
-        (baseFileName , '.map') asFilename delete.
-        (baseFileName , '.def') asFilename delete.
-        (baseFileName , '.obj') asFilename delete.
-
-        ok ifFalse:[
-            "/ self halt.
-            LastError := output.
-            ^ nil
-        ].
-        oFileName := (Filename currentDirectory construct:(baseFileName , self sharedLibraryExtension)) name.
-        ^ oFileName
+		expFile nextPutLine:'EXPORTS'.
+		expFile nextPutLine:' __' , baseFileName , '_Init'.
+	    ] ifFalse:[
+		expFile nextPutLine:'LIBRARY ' , baseFileName.
+		expFile nextPutLine:'CODE EXECUTE READ SHARED'.
+		expFile nextPutLine:'DATA READ WRITE'.
+		expFile nextPutLine:'SECTIONS'.
+		expFile nextPutLine:' INITCODE READ EXECUTE SHARED'.
+		expFile nextPutLine:' INITDATA READ WRITE'.
+		expFile nextPutLine:' RODATA READ SHARED'.
+		expFile nextPutLine:'EXPORTS'.
+		expFile nextPutLine:' _' , baseFileName , '_Init'.
+		expFile nextPutLine:'IMPORTS'.
+	    ].
+	    expFile close.
+	].
+
+	self activityNotification:'generating shared object'.
+
+	LinkArgs isNil ifTrue:[
+	    ld := LinkCommand , ' ' , baseFileName , '.obj'.
+	    ld := ld
+	       , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
+	       , ' /OUT:' , baseFileName , '.dll '
+	       , ' /DEF:' , baseFileName , '.def'.
+	] ifFalse:[
+	    OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
+		ld := LinkCommand , ' ' , (LinkArgs bindWith:baseFileName).
+		ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
+		ld := ld , ',' , baseFileName , '.dll,,..\libbc\librun.lib '.
+		ld := ld , (SearchedLibraries asStringCollection asStringWith: $ ).
+		ld := ld , ' ..\libbc\stxc32i.lib,,'.
+	    ] ifFalse:[
+		LastError := 'currently only support borlandC'.
+		self halt:'currently only support borlandC'.
+		^ nil
+	    ]
+	].
+
+	outfile := (baseFileName , '.out').
+	OperatingSystem isMSWINDOWSNTlike ifTrue:[
+	    ok := OperatingSystem executeCommand:ld
+	] ifFalse:[
+	    ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
+
+	    ok ifFalse:[
+		output := (baseFileName , '.out') asFilename contents asString.
+		Transcript showCR:output; endEntry.
+	    ]
+	].
+
+	(baseFileName , '.out') asFilename delete.
+	(baseFileName , '.tds') asFilename delete.
+	(baseFileName , '.ilc') asFilename delete.
+	(baseFileName , '.ild') asFilename delete.
+	(baseFileName , '.ilf') asFilename delete.
+	(baseFileName , '.ils') asFilename delete.
+	(baseFileName , '.lib') asFilename delete.
+	(baseFileName , '.map') asFilename delete.
+	(baseFileName , '.def') asFilename delete.
+	(baseFileName , '.obj') asFilename delete.
+
+	ok ifFalse:[
+	    "/ self halt.
+	    LastError := output.
+	    ^ nil
+	].
+	oFileName := (Filename currentDirectory construct:(baseFileName , self sharedLibraryExtension)) name.
+	^ oFileName
     ].
 
     "/ UNIX systems
@@ -2437,116 +2437,116 @@
     needSharedObject := false.
 
     osType = 'irix' ifTrue:[
-        "
-         link it to a shared object with 'ld -shared'
-        "
-        needSharedObject := true.
-        ldArg := '-shared'.
+	"
+	 link it to a shared object with 'ld -shared'
+	"
+	needSharedObject := true.
+	ldArg := '-shared'.
     ].
 
     osType = 'sys5_4' ifTrue:[
-        "
-         link it to a shared object with 'ld -G'
-        "
-        needSharedObject := true.
-        ldArg := '-G'.
+	"
+	 link it to a shared object with 'ld -G'
+	"
+	needSharedObject := true.
+	ldArg := '-G'.
     ].
 
     osType = 'osf' ifTrue:[
-        "
-         link it to a shared object with 'ld -shared'
-        "
-        needSharedObject := true.
-        ldArg := '-shared'.
+	"
+	 link it to a shared object with 'ld -shared'
+	"
+	needSharedObject := true.
+	ldArg := '-shared'.
     ].
 
     osType = 'linux' ifTrue:[
-        ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[
-            "
-             link it to a shared object with 'ld -shared'
-            "
-            needSharedObject := true.
-            ldArg := '-shared'.
-        ]
+	ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[
+	    "
+	     link it to a shared object with 'ld -shared'
+	    "
+	    needSharedObject := true.
+	    ldArg := '-shared'.
+	]
     ].
 
     osType = 'solaris' ifTrue:[
-        "
-         link it to a shared object with 'ld -G -B dynamic'
-        "
-        needSharedObject := true.
+	"
+	 link it to a shared object with 'ld -G -B dynamic'
+	"
+	needSharedObject := true.
 "/        ldArg := '-G -B dynamic'.
-        ldArg := '-G -Bdynamic'.
+	ldArg := '-G -Bdynamic'.
     ].
 
     osType = 'hpux' ifTrue:[
-        "
-         link it to a shared object with 'ld -b -B immediate'
-        "
-        needSharedObject := true.
-        ldArg := '-b -B immediate'.
+	"
+	 link it to a shared object with 'ld -b -B immediate'
+	"
+	needSharedObject := true.
+	ldArg := '-b -B immediate'.
     ].
 
     osType = 'aix' ifTrue:[
-        self activityNotification:'create export file'.
-
-        "/ create an exports file.
-        expFileName := './' , baseFileName , '.exp'.
-
-        expFile := expFileName asFilename writeStream.
-        expFile notNil ifTrue:[
-            expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
-            expFile cr.
-            expFile nextPutAll:'_' , baseFileName , '_Init'.
-            expFile close.
-        ].
-
-        self activityNotification:'generating shared object'.
-
-        "
-         link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE'
-        "
-        needSharedObject := true.
-        ld := 'cc'.
-        librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
-        librunExpFileName isNil ifTrue:[
-            LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'.
-            ^ nil
-        ].
-
-        ldArg := '-bI:' , librunExpFileName ,
-                ' -bE:' , baseFileName , '.exp' ,
-                ' -bM:SRE -e _' , baseFileName , '_Init'.
+	self activityNotification:'create export file'.
+
+	"/ create an exports file.
+	expFileName := './' , baseFileName , '.exp'.
+
+	expFile := expFileName asFilename writeStream.
+	expFile notNil ifTrue:[
+	    expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
+	    expFile cr.
+	    expFile nextPutAll:'_' , baseFileName , '_Init'.
+	    expFile close.
+	].
+
+	self activityNotification:'generating shared object'.
+
+	"
+	 link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE'
+	"
+	needSharedObject := true.
+	ld := 'cc'.
+	librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
+	librunExpFileName isNil ifTrue:[
+	    LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'.
+	    ^ nil
+	].
+
+	ldArg := '-bI:' , librunExpFileName ,
+		' -bE:' , baseFileName , '.exp' ,
+		' -bM:SRE -e _' , baseFileName , '_Init'.
     ].
 
     oFileName := './' , baseFileName , (self objectFileExtension).
     needSharedObject ifTrue:[
-        self activityNotification:'generating shared object'.
-
-        soFileName := './' , baseFileName , (self sharedLibraryExtension). 
-        OperatingSystem removeFile:soFileName.
-        ld := ld , ' ' , ldArg , ' ', 
-                 (SearchedLibraries asStringCollection asStringWith: $ ), 
-                 ' -o ' , soFileName , ' ' , oFileName.
-
-        Verbose ifTrue:[
-            'linking with:' infoPrintCR.
-            '   ' infoPrint. ld infoPrintCR.
-        ].         
-        ok := OperatingSystem 
-                executeCommand:(ld , ' >errorOutput 2>&1').
-
-        ok ifFalse:[
-            output := 'errorOutput' asFilename contents asString.
-            Transcript showCR:'linker error message:'.
-            Transcript showCR:output; endEntry.
-        ].
-
-        OperatingSystem removeFile:oFileName.
-        expFileName notNil ifTrue:[
-            OperatingSystem removeFile:expFileName
-        ].
-        ^ soFileName. 
+	self activityNotification:'generating shared object'.
+
+	soFileName := './' , baseFileName , (self sharedLibraryExtension). 
+	OperatingSystem removeFile:soFileName.
+	ld := ld , ' ' , ldArg , ' ', 
+		 (SearchedLibraries asStringCollection asStringWith: $ ), 
+		 ' -o ' , soFileName , ' ' , oFileName.
+
+	Verbose ifTrue:[
+	    'linking with:' infoPrintCR.
+	    '   ' infoPrint. ld infoPrintCR.
+	].         
+	ok := OperatingSystem 
+		executeCommand:(ld , ' >errorOutput 2>&1').
+
+	ok ifFalse:[
+	    output := 'errorOutput' asFilename contents asString.
+	    Transcript showCR:'linker error message:'.
+	    Transcript showCR:output; endEntry.
+	].
+
+	OperatingSystem removeFile:oFileName.
+	expFileName notNil ifTrue:[
+	    OperatingSystem removeFile:expFileName
+	].
+	^ soFileName. 
     ].
 
     "
@@ -2790,6 +2790,8 @@
 	    __win32_fflush(stderr);
 	}
 	if (handle == NULL) {
+	    char *msg;
+
 	    err = GetLastError();
 	    if ((@global(ErrorPrinting) == true) 
 	     || (@global(Verbose) == true)) {
@@ -2799,7 +2801,14 @@
 	    }
 	    @global(LastError) = @symbol(loadError);;
 	    @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
-	    @global(LinkErrorMessage) = __MKSTRING("LoadLibrary error");
+	    switch (err) {
+                case ERROR_BAD_FORMAT:
+		    msg = "LoadLibrary error - bad format";
+		default:
+		    msg = "LoadLibrary error";
+		    break;
+	    }
+	    @global(LinkErrorMessage) = __MKSTRING(msg);
 	    RETURN ( nil );
 	}
 	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
@@ -3213,7 +3222,7 @@
     |key fileName functionName deInitAddr m|
 
     Verbose ifTrue:[
-        'unload module name=' infoPrint. handle pathName infoPrintCR.
+	'unload module name=' infoPrint. handle pathName infoPrintCR.
     ].
 
     "/
@@ -3221,54 +3230,54 @@
     "/
 
     handle isFunctionObjectHandle ifTrue:[
-        handle functions do:[:f |
-                                f notNil ifTrue:[
-                                    f code:0
-                                ]
-                            ].
+	handle functions do:[:f |
+				f notNil ifTrue:[
+				    f code:0
+				]
+			    ].
     ].
 
     handle isClassLibHandle ifTrue:[
-        self deinitializeClassesFromModule:handle.
-        self unregisterModule:handle.
+	self deinitializeClassesFromModule:handle.
+	self unregisterModule:handle.
     ] ifFalse:[    
-        handle isMethodHandle ifTrue:[
-            self unregisterModule:handle.
-        ] ifFalse:[
-            "/
-            "/ call its deInit function (if present)
-            "/
-            fileName := handle pathName asFilename baseName.
-            functionName := self initFunctionBasenameForFile:fileName.
-
-            deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
-            deInitAddr notNil ifTrue:[
-                self callInitFunctionAt:deInitAddr 
-                     specialInit:false 
-                     forceOld:true 
-                     interruptable:false
-                     argument:0
-                     identifyAs:handle
-                     returnsObject:false.
-            ]
-        ]
+	handle isMethodHandle ifTrue:[
+	    self unregisterModule:handle.
+	] ifFalse:[
+	    "/
+	    "/ call its deInit function (if present)
+	    "/
+	    fileName := handle pathName asFilename baseName.
+	    functionName := self initFunctionBasenameForFile:fileName.
+
+	    deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
+	    deInitAddr notNil ifTrue:[
+		self callInitFunctionAt:deInitAddr 
+		     specialInit:false 
+		     forceOld:true 
+		     interruptable:false
+		     argument:0
+		     identifyAs:handle
+		     returnsObject:false.
+	    ]
+	]
     ].
 
     "/
     "/ now, really unload
     "/
     (self primUnloadDynamicObject:handle) ifFalse:[
-        ^ self error:'unloadDynamic failed'
+	^ self error:'unloadDynamic failed'
     ].
 
     "/
     "/ remove from loaded objects
     "/
     LoadedObjects notNil ifTrue:[
-        key := LoadedObjects keyAtEqualValue:handle.
-        key notNil ifTrue:[
-            LoadedObjects removeKey:key
-        ]
+	key := LoadedObjects keyAtEqualValue:handle.
+	key notNil ifTrue:[
+	    LoadedObjects removeKey:key
+	]
     ].
 
     "
@@ -3276,17 +3285,17 @@
      but make it unexecutable. Its still visible in the browser.
     "
     handle isMethodHandle ifTrue:[
-        ((m := handle method) notNil 
-        and:[m ~~ 0]) ifTrue:[
-            m makeUnloaded.
-        ]
+	((m := handle method) notNil 
+	and:[m ~~ 0]) ifTrue:[
+	    m makeUnloaded.
+	]
     ].
 
     handle isClassLibHandle ifTrue:[
-        Smalltalk flushCachedClasses.
+	Smalltalk flushCachedClasses.
     ].
     handle isMethodHandle ifTrue:[
-        ObjectMemory flushCaches.
+	ObjectMemory flushCaches.
     ].
 
     handle moduleID:nil.
@@ -3775,6 +3784,6 @@
 !ObjectFileLoader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.192 1999-05-04 15:19:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.193 1999-05-05 12:29:41 cg Exp $'
 ! !
 ObjectFileLoader initialize!
--- a/ObjectFileLoader.st	Tue May 04 17:19:00 1999 +0200
+++ b/ObjectFileLoader.st	Wed May 05 14:29:41 1999 +0200
@@ -246,13 +246,13 @@
       robustness.
 
     There are basically two totally different mechanisms to do this:
-        a) if there exists some dynamic-link facility such as:
-           GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
-           or LoadLibrary (Win32), this is used
-
-        b) if no such facility exists, the normal linker is used to
-           link the module to text/data address as previously malloced,
-           and the object file loaded into that space.
+	a) if there exists some dynamic-link facility such as:
+	   GNU-DL, dlopen (sparc, SYS5.4), rld_open (NeXT),
+	   or LoadLibrary (Win32), this is used
+
+	b) if no such facility exists, the normal linker is used to
+	   link the module to text/data address as previously malloced,
+	   and the object file loaded into that space.
            
     Currently, not all mechanisms work fully satisfying.
     For example, the sun dl*-functions do an exit on link-errors (which
@@ -279,7 +279,7 @@
     loaded at image restart time).
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 "
 ! !
 
@@ -289,94 +289,94 @@
     |systemType|
 
     OperatingSystem isMSDOSlike ifTrue:[
-        "/ default setup for msc
-        OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
-            LinkCommand isNil ifTrue:[
-                LinkCommand := 'tlink32'.
-                LinkCommand := 'ilink32'.
-            ].
-            LinkArgs isNil ifTrue:[
-                LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ..\libbc\librun.lib'.
-                LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'.
-            ].
-            SearchedLibraries := #(
-                                    'import32.lib'
-                                  ).
-        ] ifFalse:[
-            LinkCommand isNil ifTrue:[
-                LinkCommand := 'link'
-            ].
-            LinkArgs isNil ifTrue:[
-                LinkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
-            ].
-        ].
+	"/ default setup for msc
+	OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
+	    LinkCommand isNil ifTrue:[
+		LinkCommand := 'tlink32'.
+		LinkCommand := 'ilink32'.
+	    ].
+	    LinkArgs isNil ifTrue:[
+		LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -c -ap -Tpd -s -Gi -v -w-dup ..\libbc\librun.lib'.
+		LinkArgs := '-L..\libbc -L\Programme\Borland\CBuilder3\lib -r -c -ap -Tpd -Gi -w-dup'.
+	    ].
+	    SearchedLibraries := #(
+				    'import32.lib'
+				  ).
+	] ifFalse:[
+	    LinkCommand isNil ifTrue:[
+		LinkCommand := 'link'
+	    ].
+	    LinkArgs isNil ifTrue:[
+		LinkArgs := '/NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL /OUT:%1.dll /DEF:%1.def'
+	    ].
+	].
     ].
 
     MySymbolTable isNil ifTrue:[
-        Verbose := false.
-        NextHandleID := 1.
-        ObjectMemory addDependent:self.
-
-        OperatingSystem isMSDOSlike ifTrue:[
-            SearchedLibraries := #(
-                                    'import32.lib'
-                                  ).
-        ].
-
-        OperatingSystem isUNIXlike ifTrue:[
-            systemType := OperatingSystem getOSType.
-
-            "/ name of object file, where initial symbol table is found
-            "/ not req'd for all architectures.
-
-            MySymbolTable := 'stx'.
-
-            "/ default set of libraries to be considered when
-            "/ unresolved symbols are encountered during the load.
-            "/ Only req'd for linux and sunos non-ELF systems.
-            "/ Can (should) be set in the smalltalk.rc file.
-
-            SearchedLibraries := #().
-
-            (systemType = 'linux' 
-            or:[systemType = 'sunos']) ifTrue:[
-                '/usr/lib/libc.a' asFilename isReadable ifTrue:[
-                    SearchedLibraries := #('/usr/lib/libc.a')
-                ] ifFalse:[
-                    '/lib/libc.a' asFilename isReadable ifTrue:[
-                        SearchedLibraries := #('/lib/libc.a')
-                    ]
-                ]
-            ].
-
-            "/ default libraryPath where shared objects are searched for
-            "/ when a dynamic library is loaded without an explicit path.
-
-            LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
-            LoadLibraryPath isNil ifTrue:[
-                LoadLibraryPath := #('.'
-                                     'lib'
-                                     '/usr/local/smalltalk/lib'
-                                     '/usr/local/lib'
-                                     '/usr/lib'
-                                     '/lib'
-                                    ) asOrderedCollection.
-            ].
-
-            "/ default libraryPath where shared objects are expected
-            "/ when a sharedObject load requires other objects to be loaded.
-            "/ Only req'd for aix.
-            "/ For more compatibility with ELF systems, look for a shell variable
-            "/ named LD_LIBRARY_PATH, and - if present - take that instead if a default.
-            "/ Can (should) be set in the smalltalk.rc file.
-
-            systemType = 'aix' ifTrue:[
-                LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
-                LibPath isNil ifTrue:[
-                    LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'.
-                ]
-            ].
-        ]
+	Verbose := false.
+	NextHandleID := 1.
+	ObjectMemory addDependent:self.
+
+	OperatingSystem isMSDOSlike ifTrue:[
+	    SearchedLibraries := #(
+				    'import32.lib'
+				  ).
+	].
+
+	OperatingSystem isUNIXlike ifTrue:[
+	    systemType := OperatingSystem getOSType.
+
+	    "/ name of object file, where initial symbol table is found
+	    "/ not req'd for all architectures.
+
+	    MySymbolTable := 'stx'.
+
+	    "/ default set of libraries to be considered when
+	    "/ unresolved symbols are encountered during the load.
+	    "/ Only req'd for linux and sunos non-ELF systems.
+	    "/ Can (should) be set in the smalltalk.rc file.
+
+	    SearchedLibraries := #().
+
+	    (systemType = 'linux' 
+	    or:[systemType = 'sunos']) ifTrue:[
+		'/usr/lib/libc.a' asFilename isReadable ifTrue:[
+		    SearchedLibraries := #('/usr/lib/libc.a')
+		] ifFalse:[
+		    '/lib/libc.a' asFilename isReadable ifTrue:[
+			SearchedLibraries := #('/lib/libc.a')
+		    ]
+		]
+	    ].
+
+	    "/ default libraryPath where shared objects are searched for
+	    "/ when a dynamic library is loaded without an explicit path.
+
+	    LoadLibraryPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
+	    LoadLibraryPath isNil ifTrue:[
+		LoadLibraryPath := #('.'
+				     'lib'
+				     '/usr/local/smalltalk/lib'
+				     '/usr/local/lib'
+				     '/usr/lib'
+				     '/lib'
+				    ) asOrderedCollection.
+	    ].
+
+	    "/ default libraryPath where shared objects are expected
+	    "/ when a sharedObject load requires other objects to be loaded.
+	    "/ Only req'd for aix.
+	    "/ For more compatibility with ELF systems, look for a shell variable
+	    "/ named LD_LIBRARY_PATH, and - if present - take that instead if a default.
+	    "/ Can (should) be set in the smalltalk.rc file.
+
+	    systemType = 'aix' ifTrue:[
+		LibPath := OperatingSystem getEnvironment:'LD_LIBRARY_PATH'.
+		LibPath isNil ifTrue:[
+		    LibPath := '.:/usr/local/smalltalk/lib:/usr/local/lib:/usr/lib:/lib'.
+		]
+	    ].
+	]
     ]
 
     "
@@ -483,7 +483,7 @@
 
     fn := aFilename asFilename.
     self validBinaryExtensions do:[:ext |
-        (fn hasSuffix:ext) ifTrue:[^ true].
+	(fn hasSuffix:ext) ifTrue:[^ true].
     ].
     ^ false
 
@@ -682,11 +682,11 @@
     |os|
 
     OperatingSystem isMSDOSlike ifTrue:[
-        "/ includes all of win32s, win95, winNT & os/2
-        ^ #('dll')
+	"/ includes all of win32s, win95, winNT & os/2
+	^ #('dll')
     ].
     OperatingSystem isVMSlike ifTrue:[
-        ^ #('exe')
+	^ #('exe')
     ].
 
     os := OperatingSystem getSystemType.
@@ -697,10 +697,10 @@
     (os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ].
     (os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ].
     (os = 'linux') ifTrue:[
-        self loadableBinaryObjectFormat == #aout ifTrue:[
-            ^ #('o' 'obj' 'a')
-        ].
-        ^ #('so' 'o' 'obj' ) 
+	self loadableBinaryObjectFormat == #aout ifTrue:[
+	    ^ #('o' 'obj' 'a')
+	].
+	^ #('so' 'o' 'obj' ) 
     ].
     (os = 'aix') ifTrue:[^ #('o' 'so') ].
     (os = 'hpux') ifTrue:[^ #(" 'o' " 'sl') ].
@@ -974,43 +974,43 @@
 
     libFilename := aLibraryFileName asFilename.
     (s := libFilename suffix) isEmpty ifTrue:[
-        suffixes := self validBinaryExtensions
+	suffixes := self validBinaryExtensions
     ] ifFalse:[
-        suffixes := #('')
+	suffixes := #('')
     ].
 
     "/ try each suffix ...
     suffixes do:[:aSuffix | 
-        |fn f|
-
-        fn := aLibraryFileName , '.' , aSuffix.
-
-        (libFilename isAbsolute 
-        or:[(aLibraryFileName startsWith:'./')
-        or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
-            f := fn asFilename.
-            f exists ifTrue:[
-                handle := self loadObjectFile:fn.
-                handle notNil ifTrue:[^ handle].
-            ]
-        ] ifFalse:[
-            "/ try each directory    
-            LoadLibraryPath size > 0 ifTrue:[
-                (LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) 
-                do:[:aDir |
-                    f := aDir asFilename construct:fn.
-                    f exists ifTrue:[
-                        handle := self loadObjectFile:f pathName.
-                        handle notNil ifTrue:[^ handle].
-                    ]
-                ]
-            ].
-            "/ try to load it by name - maybe someone else knows
-            "/ how to find it (the system itself)
-
-            handle := self loadObjectFile:fn.
-            handle notNil ifTrue:[^ handle].
-        ]
+	|fn f|
+
+	fn := aLibraryFileName , '.' , aSuffix.
+
+	(libFilename isAbsolute 
+	or:[(aLibraryFileName startsWith:'./')
+	or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[
+	    f := fn asFilename.
+	    f exists ifTrue:[
+		handle := self loadObjectFile:fn.
+		handle notNil ifTrue:[^ handle].
+	    ]
+	] ifFalse:[
+	    "/ try each directory    
+	    LoadLibraryPath size > 0 ifTrue:[
+		(LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) 
+		do:[:aDir |
+		    f := aDir asFilename construct:fn.
+		    f exists ifTrue:[
+			handle := self loadObjectFile:f pathName.
+			handle notNil ifTrue:[^ handle].
+		    ]
+		]
+	    ].
+	    "/ try to load it by name - maybe someone else knows
+	    "/ how to find it (the system itself)
+
+	    handle := self loadObjectFile:fn.
+	    handle notNil ifTrue:[^ handle].
+	]
     ].
 
     ^ nil
@@ -1035,7 +1035,7 @@
     "/
     handle := self loadDynamicObject:aFileName.
     handle isNil ifTrue:[
-        ^ nil
+	^ nil
     ].
 
     "/
@@ -1045,39 +1045,39 @@
 
     initAddr := self getFunction:'__' , initName , '_Init' from:handle.
     initAddr isNil ifTrue:[
-        initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
-        initAddr isNil ifTrue:[
-            (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
-                self listUndefinedSymbolsIn:handle.
-                'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR.
-            ] ifFalse:[
-                ('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
-            ].
-
-            "/
-            "/ not found - unload
-            "/
-            self unloadDynamicObject:handle.
-            ^ nil
-        ]
+	initAddr := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
+	initAddr isNil ifTrue:[
+	    (self getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
+		self listUndefinedSymbolsIn:handle.
+		'ObjectFileLoader [info]: undefined symbols in primitive code' infoPrintCR.
+	    ] ifFalse:[
+		('ObjectFileLoader [info]: ' , initName , '_Init() lookup failed') errorPrintCR
+	    ].
+
+	    "/
+	    "/ not found - unload
+	    "/
+	    self unloadDynamicObject:handle.
+	    ^ nil
+	]
     ].
 
     Object osSignalInterruptSignal handle:[:ex |
-        ('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
-        self unloadDynamicObject:handle.
-        ^ nil
+	('ObjectFileLoader [warning]: hard error in initFunction: ' , initName , ' of method-module ' , aFileName) errorPrintCR.
+	self unloadDynamicObject:handle.
+	^ nil
     ] do:[
-        "/
-        "/ call it - it returns the new method object
-        "/
-        m := self
-            callInitFunctionAt:initAddr 
-            specialInit:true
-            forceOld:true 
-            interruptable:false
-            argument:2
-            identifyAs:handle
-            returnsObject:true.
+	"/
+	"/ call it - it returns the new method object
+	"/
+	m := self
+	    callInitFunctionAt:initAddr 
+	    specialInit:true
+	    forceOld:true 
+	    interruptable:false
+	    argument:2
+	    identifyAs:handle
+	    returnsObject:true.
     ].
 
     handle method:m.
@@ -1101,13 +1101,13 @@
 
     handle := self loadDynamicObject:aFileName.
     handle isNil ifTrue:[
-        Transcript showCR:('failed to load: ' , aFileName).
-        ('ObjectFileLoader [warning]: '
-         , aFileName
-         , ' failed. ('
-         , LinkErrorMessage
-         , ')') errorPrintCR.
-        ^ nil
+	Transcript showCR:('failed to load: ' , aFileName).
+	('ObjectFileLoader [warning]: '
+	 , aFileName
+	 , ' failed. ('
+	 , LinkErrorMessage
+	 , ')') errorPrintCR.
+	^ nil
     ].
 
     didInit := false.
@@ -1117,23 +1117,23 @@
     "/ are to be resolved. If thats the case, load all libraries ...
 
     SearchedLibraries notNil ifTrue:[
-        (self hasUndefinedSymbolsIn:handle) ifTrue:[
-            self initializeLoader.
-
-            SearchedLibraries do:[:libName |
-                (self hasUndefinedSymbolsIn:handle) ifTrue:[
-                    Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
-                    dummyHandle := Array new:4.
-                    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
+	(self hasUndefinedSymbolsIn:handle) ifTrue:[
+	    self initializeLoader.
+
+	    SearchedLibraries do:[:libName |
+		(self hasUndefinedSymbolsIn:handle) ifTrue:[
+		    Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
+		    dummyHandle := Array new:4.
+		    dummyHandle := self primLoadDynamicObject:libName into:dummyHandle.
 "/                    dummyHandle isNil ifTrue:[
 "/                        Transcript showCR:'   ... load of library ' , libName , ' failed.'.
 "/                    ]
-                ]
-            ].
-            (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
-                Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.').
-            ].
-        ]
+		]
+	    ].
+	    (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
+		Transcript showCR:('LOADER: still undefined symbols in ',aFileName,'.').
+	    ].
+	]
     ].
 
     "
@@ -1151,113 +1151,113 @@
     initAddr := self findInitFunction:className in:handle.
 
     initAddr notNil ifTrue:[
-        Verbose ifTrue:[
-            ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR.
-        ].
-        info := self performModuleInitAt:initAddr for:nil identifyAs:handle.
-        status := info at:1.
-        status == #ok ifTrue:[
-            didInit := true.
-        ]
+	Verbose ifTrue:[
+	    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR.
+	].
+	info := self performModuleInitAt:initAddr for:nil identifyAs:handle.
+	status := info at:1.
+	status == #ok ifTrue:[
+	    didInit := true.
+	]
     ] ifFalse:[
-        "/
-        "/ look for explicit C-init (xxx__Init) function
-        "/ This is used in C object files
-        "/
-        initAddr := self findFunction:className suffix:'__Init' in:handle.
-        initAddr notNil ifTrue:[
-            isCModule := true.
-
-            Object osSignalInterruptSignal handle:[:ex |
-                ('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , aFileName) errorPrintCR.
-                status := #initFailed.
-            ] do:[
-                (self callInitFunctionAt:initAddr 
-                     specialInit:false 
-                     forceOld:true 
-                     interruptable:false
-                     argument:0
-                     identifyAs:handle
-                     returnsObject:false) < 0 ifTrue:[
-
-                    Verbose ifTrue:[
-                        'init function return failure ... unload' infoPrintCR.
-                    ].
-                    status := #initFailed.
-                ] ifFalse:[
-                    didInit := true.
-                ]
-            ]
-        ] ifFalse:[
-            status := #noInitFunction.
-
-            "
-             look for any init-function(s); call them all
-            "
-            Verbose ifTrue:[
-                'no good init functions found; looking for candidates ...' infoPrintCR.
-            ].
-            initNames := self namesMatching:'*_Init' segment:'[tT?]' in:aFileName.
-            initNames notNil ifTrue:[
-                initNames do:[:aName |
-                    initAddr := self getFunction:aName from:handle.
-                    initAddr isNil ifTrue:[
-                        (aName startsWith:'_') ifTrue:[
-                            initAddr := self getFunction:(aName copyFrom:2) from:handle.
-                        ].
-                    ].
-                    initAddr isNil ifTrue:[
-                        Transcript showCR:('no symbol: ',aName,' in ',aFileName).
-                    ] ifFalse:[
-                        Verbose ifTrue:[
-                            ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR
-                        ].
-                        self performModuleInitAt:initAddr for:nil identifyAs:handle.
-                        didInit := true.
-                    ]
-                ].
-            ].
-        ]
+	"/
+	"/ look for explicit C-init (xxx__Init) function
+	"/ This is used in C object files
+	"/
+	initAddr := self findFunction:className suffix:'__Init' in:handle.
+	initAddr notNil ifTrue:[
+	    isCModule := true.
+
+	    Object osSignalInterruptSignal handle:[:ex |
+		('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , aFileName) errorPrintCR.
+		status := #initFailed.
+	    ] do:[
+		(self callInitFunctionAt:initAddr 
+		     specialInit:false 
+		     forceOld:true 
+		     interruptable:false
+		     argument:0
+		     identifyAs:handle
+		     returnsObject:false) < 0 ifTrue:[
+
+		    Verbose ifTrue:[
+			'init function return failure ... unload' infoPrintCR.
+		    ].
+		    status := #initFailed.
+		] ifFalse:[
+		    didInit := true.
+		]
+	    ]
+	] ifFalse:[
+	    status := #noInitFunction.
+
+	    "
+	     look for any init-function(s); call them all
+	    "
+	    Verbose ifTrue:[
+		'no good init functions found; looking for candidates ...' infoPrintCR.
+	    ].
+	    initNames := self namesMatching:'*_Init' segment:'[tT?]' in:aFileName.
+	    initNames notNil ifTrue:[
+		initNames do:[:aName |
+		    initAddr := self getFunction:aName from:handle.
+		    initAddr isNil ifTrue:[
+			(aName startsWith:'_') ifTrue:[
+			    initAddr := self getFunction:(aName copyFrom:2) from:handle.
+			].
+		    ].
+		    initAddr isNil ifTrue:[
+			Transcript showCR:('no symbol: ',aName,' in ',aFileName).
+		    ] ifFalse:[
+			Verbose ifTrue:[
+			    ('calling init at:' , (initAddr printStringRadix:16)) infoPrintCR
+			].
+			self performModuleInitAt:initAddr for:nil identifyAs:handle.
+			didInit := true.
+		    ]
+		].
+	    ].
+	]
     ].
 
     didInit ifFalse:[
-        status == #noInitFunction ifTrue:[
-            msg := 'LOADER: no init function; assume load ok'
-        ] ifFalse:[
-
-            status == #registrationFailed ifTrue:[
-                Transcript showCR:'LOADER:incompatible object (recompile without commonSymbols ?)'
-            ].
-            status ~~ #initFailed ifTrue:[
-                self listUndefinedSymbolsIn:handle.
-            ].
-
-            Verbose ifTrue:[
-                'unloading, since init failed ...' infoPrintCR.
-            ].
-            self unloadDynamicObject:handle.
-            handle := nil.
-
-            status == #initFailed ifTrue:[
-                msg := 'LOADER: module not loaded (init function signalled failure).'
-            ] ifFalse:[
-                (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:aFileName) notNil ifTrue:[
-                    msg := 'LOADER: module not loaded (no _Init entry - looks like an incomplete sepInitCode object).'
-                ] ifFalse:[
-                    msg := 'LOADER: module not loaded (no _Init entry in object file ?).'
-                ].
-            ].
-        ].
-        Transcript showCR:msg
+	status == #noInitFunction ifTrue:[
+	    msg := 'LOADER: no init function; assume load ok'
+	] ifFalse:[
+
+	    status == #registrationFailed ifTrue:[
+		Transcript showCR:'LOADER:incompatible object (recompile without commonSymbols ?)'
+	    ].
+	    status ~~ #initFailed ifTrue:[
+		self listUndefinedSymbolsIn:handle.
+	    ].
+
+	    Verbose ifTrue:[
+		'unloading, since init failed ...' infoPrintCR.
+	    ].
+	    self unloadDynamicObject:handle.
+	    handle := nil.
+
+	    status == #initFailed ifTrue:[
+		msg := 'LOADER: module not loaded (init function signalled failure).'
+	    ] ifFalse:[
+		(self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:aFileName) notNil ifTrue:[
+		    msg := 'LOADER: module not loaded (no _Init entry - looks like an incomplete sepInitCode object).'
+		] ifFalse:[
+		    msg := 'LOADER: module not loaded (no _Init entry in object file ?).'
+		].
+	    ].
+	].
+	Transcript showCR:msg
     ].
 
     isCModule ifFalse:[
-        Smalltalk isInitialized ifTrue:[
-            "
-             really dont know, if it has changed ...
-            "
-            Smalltalk changed.
-        ]
+	Smalltalk isInitialized ifTrue:[
+	    "
+	     really dont know, if it has changed ...
+	    "
+	    Smalltalk changed.
+	]
     ].
     ^ handle
 
@@ -1844,16 +1844,16 @@
     name := aFileName asFilename.
     suffixLen := 0.
     self validBinaryExtensions do:[:suffix |
-        suffixLen == 0 ifTrue:[
-            (name hasSuffix:suffix) ifTrue:[
-                suffixLen := suffix size + 1
-            ]
-        ]
+	suffixLen == 0 ifTrue:[
+	    (name hasSuffix:suffix) ifTrue:[
+		suffixLen := suffix size + 1
+	    ]
+	]
     ].
     name := name baseName.
 
     suffixLen ~~ 0 ifTrue:[
-        name := name copyWithoutLast:suffixLen
+	name := name copyWithoutLast:suffixLen
     ].
     ^ name.
 
@@ -2348,87 +2348,87 @@
     osType := OperatingSystem getOSType.
 
     osType = 'win32' ifTrue:[
-        self activityNotification:'create def file'.
-
-        "/ create a .def file.
-        expFileName := '.\' , baseFileName , '.def'.
-
-        expFile := expFileName asFilename writeStream.
-        expFile notNil ifTrue:[
-            OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
-                expFile nextPutLine:'LIBRARY ' , baseFileName.
-                expFile nextPutLine:'SEGMENTS'.
-                expFile nextPutLine:'    INITCODE PRELOAD SHARED'.
+	self activityNotification:'create def file'.
+
+	"/ create a .def file.
+	expFileName := '.\' , baseFileName , '.def'.
+
+	expFile := expFileName asFilename writeStream.
+	expFile notNil ifTrue:[
+	    OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
+		expFile nextPutLine:'LIBRARY ' , baseFileName.
+		expFile nextPutLine:'SEGMENTS'.
+		expFile nextPutLine:'    INITCODE PRELOAD SHARED'.
 "/                expFile nextPutLine:'    INITDATA READ WRITE'.
-                expFile nextPutLine:'EXPORTS'.
-                expFile nextPutLine:' __' , baseFileName , '_Init'.
-            ] ifFalse:[
-                expFile nextPutLine:'LIBRARY ' , baseFileName.
-                expFile nextPutLine:'CODE EXECUTE READ SHARED'.
-                expFile nextPutLine:'DATA READ WRITE'.
-                expFile nextPutLine:'SECTIONS'.
-                expFile nextPutLine:' INITCODE READ EXECUTE SHARED'.
-                expFile nextPutLine:' INITDATA READ WRITE'.
-                expFile nextPutLine:' RODATA READ SHARED'.
-                expFile nextPutLine:'EXPORTS'.
-                expFile nextPutLine:' _' , baseFileName , '_Init'.
-                expFile nextPutLine:'IMPORTS'.
-            ].
-            expFile close.
-        ].
-
-        self activityNotification:'generating shared object'.
-
-        LinkArgs isNil ifTrue:[
-            ld := LinkCommand , ' ' , baseFileName , '.obj'.
-            ld := ld
-               , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
-               , ' /OUT:' , baseFileName , '.dll '
-               , ' /DEF:' , baseFileName , '.def'.
-        ] ifFalse:[
-            OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
-                ld := LinkCommand , ' ' , (LinkArgs bindWith:baseFileName).
-                ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
-                ld := ld , ',' , baseFileName , '.dll,,..\libbc\librun.lib '.
-                ld := ld , (SearchedLibraries asStringCollection asStringWith: $ ).
-                ld := ld , ' ..\libbc\stxc32i.lib,,'.
-            ] ifFalse:[
-                LastError := 'currently only support borlandC'.
-                self halt:'currently only support borlandC'.
-                ^ nil
-            ]
-        ].
-
-        outfile := (baseFileName , '.out').
-        OperatingSystem isMSWINDOWSNTlike ifTrue:[
-            ok := OperatingSystem executeCommand:ld
-        ] ifFalse:[
-            ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
-
-            ok ifFalse:[
-                output := (baseFileName , '.out') asFilename contents asString.
-                Transcript showCR:output; endEntry.
-            ]
-        ].
-
-        (baseFileName , '.out') asFilename delete.
-        (baseFileName , '.tds') asFilename delete.
-        (baseFileName , '.ilc') asFilename delete.
-        (baseFileName , '.ild') asFilename delete.
-        (baseFileName , '.ilf') asFilename delete.
-        (baseFileName , '.ils') asFilename delete.
-        (baseFileName , '.lib') asFilename delete.
-        (baseFileName , '.map') asFilename delete.
-        (baseFileName , '.def') asFilename delete.
-        (baseFileName , '.obj') asFilename delete.
-
-        ok ifFalse:[
-            "/ self halt.
-            LastError := output.
-            ^ nil
-        ].
-        oFileName := (Filename currentDirectory construct:(baseFileName , self sharedLibraryExtension)) name.
-        ^ oFileName
+		expFile nextPutLine:'EXPORTS'.
+		expFile nextPutLine:' __' , baseFileName , '_Init'.
+	    ] ifFalse:[
+		expFile nextPutLine:'LIBRARY ' , baseFileName.
+		expFile nextPutLine:'CODE EXECUTE READ SHARED'.
+		expFile nextPutLine:'DATA READ WRITE'.
+		expFile nextPutLine:'SECTIONS'.
+		expFile nextPutLine:' INITCODE READ EXECUTE SHARED'.
+		expFile nextPutLine:' INITDATA READ WRITE'.
+		expFile nextPutLine:' RODATA READ SHARED'.
+		expFile nextPutLine:'EXPORTS'.
+		expFile nextPutLine:' _' , baseFileName , '_Init'.
+		expFile nextPutLine:'IMPORTS'.
+	    ].
+	    expFile close.
+	].
+
+	self activityNotification:'generating shared object'.
+
+	LinkArgs isNil ifTrue:[
+	    ld := LinkCommand , ' ' , baseFileName , '.obj'.
+	    ld := ld
+	       , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
+	       , ' /OUT:' , baseFileName , '.dll '
+	       , ' /DEF:' , baseFileName , '.def'.
+	] ifFalse:[
+	    OperatingSystem getCCDefine ='__BORLANDC__' ifTrue:[
+		ld := LinkCommand , ' ' , (LinkArgs bindWith:baseFileName).
+		ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
+		ld := ld , ',' , baseFileName , '.dll,,..\libbc\librun.lib '.
+		ld := ld , (SearchedLibraries asStringCollection asStringWith: $ ).
+		ld := ld , ' ..\libbc\stxc32i.lib,,'.
+	    ] ifFalse:[
+		LastError := 'currently only support borlandC'.
+		self halt:'currently only support borlandC'.
+		^ nil
+	    ]
+	].
+
+	outfile := (baseFileName , '.out').
+	OperatingSystem isMSWINDOWSNTlike ifTrue:[
+	    ok := OperatingSystem executeCommand:ld
+	] ifFalse:[
+	    ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
+
+	    ok ifFalse:[
+		output := (baseFileName , '.out') asFilename contents asString.
+		Transcript showCR:output; endEntry.
+	    ]
+	].
+
+	(baseFileName , '.out') asFilename delete.
+	(baseFileName , '.tds') asFilename delete.
+	(baseFileName , '.ilc') asFilename delete.
+	(baseFileName , '.ild') asFilename delete.
+	(baseFileName , '.ilf') asFilename delete.
+	(baseFileName , '.ils') asFilename delete.
+	(baseFileName , '.lib') asFilename delete.
+	(baseFileName , '.map') asFilename delete.
+	(baseFileName , '.def') asFilename delete.
+	(baseFileName , '.obj') asFilename delete.
+
+	ok ifFalse:[
+	    "/ self halt.
+	    LastError := output.
+	    ^ nil
+	].
+	oFileName := (Filename currentDirectory construct:(baseFileName , self sharedLibraryExtension)) name.
+	^ oFileName
     ].
 
     "/ UNIX systems
@@ -2437,116 +2437,116 @@
     needSharedObject := false.
 
     osType = 'irix' ifTrue:[
-        "
-         link it to a shared object with 'ld -shared'
-        "
-        needSharedObject := true.
-        ldArg := '-shared'.
+	"
+	 link it to a shared object with 'ld -shared'
+	"
+	needSharedObject := true.
+	ldArg := '-shared'.
     ].
 
     osType = 'sys5_4' ifTrue:[
-        "
-         link it to a shared object with 'ld -G'
-        "
-        needSharedObject := true.
-        ldArg := '-G'.
+	"
+	 link it to a shared object with 'ld -G'
+	"
+	needSharedObject := true.
+	ldArg := '-G'.
     ].
 
     osType = 'osf' ifTrue:[
-        "
-         link it to a shared object with 'ld -shared'
-        "
-        needSharedObject := true.
-        ldArg := '-shared'.
+	"
+	 link it to a shared object with 'ld -shared'
+	"
+	needSharedObject := true.
+	ldArg := '-shared'.
     ].
 
     osType = 'linux' ifTrue:[
-        ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[
-            "
-             link it to a shared object with 'ld -shared'
-            "
-            needSharedObject := true.
-            ldArg := '-shared'.
-        ]
+	ObjectFileLoader loadableBinaryObjectFormat == #elf ifTrue:[
+	    "
+	     link it to a shared object with 'ld -shared'
+	    "
+	    needSharedObject := true.
+	    ldArg := '-shared'.
+	]
     ].
 
     osType = 'solaris' ifTrue:[
-        "
-         link it to a shared object with 'ld -G -B dynamic'
-        "
-        needSharedObject := true.
+	"
+	 link it to a shared object with 'ld -G -B dynamic'
+	"
+	needSharedObject := true.
 "/        ldArg := '-G -B dynamic'.
-        ldArg := '-G -Bdynamic'.
+	ldArg := '-G -Bdynamic'.
     ].
 
     osType = 'hpux' ifTrue:[
-        "
-         link it to a shared object with 'ld -b -B immediate'
-        "
-        needSharedObject := true.
-        ldArg := '-b -B immediate'.
+	"
+	 link it to a shared object with 'ld -b -B immediate'
+	"
+	needSharedObject := true.
+	ldArg := '-b -B immediate'.
     ].
 
     osType = 'aix' ifTrue:[
-        self activityNotification:'create export file'.
-
-        "/ create an exports file.
-        expFileName := './' , baseFileName , '.exp'.
-
-        expFile := expFileName asFilename writeStream.
-        expFile notNil ifTrue:[
-            expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
-            expFile cr.
-            expFile nextPutAll:'_' , baseFileName , '_Init'.
-            expFile close.
-        ].
-
-        self activityNotification:'generating shared object'.
-
-        "
-         link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE'
-        "
-        needSharedObject := true.
-        ld := 'cc'.
-        librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
-        librunExpFileName isNil ifTrue:[
-            LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'.
-            ^ nil
-        ].
-
-        ldArg := '-bI:' , librunExpFileName ,
-                ' -bE:' , baseFileName , '.exp' ,
-                ' -bM:SRE -e _' , baseFileName , '_Init'.
+	self activityNotification:'create export file'.
+
+	"/ create an exports file.
+	expFileName := './' , baseFileName , '.exp'.
+
+	expFile := expFileName asFilename writeStream.
+	expFile notNil ifTrue:[
+	    expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
+	    expFile cr.
+	    expFile nextPutAll:'_' , baseFileName , '_Init'.
+	    expFile close.
+	].
+
+	self activityNotification:'generating shared object'.
+
+	"
+	 link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE'
+	"
+	needSharedObject := true.
+	ld := 'cc'.
+	librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'.
+	librunExpFileName isNil ifTrue:[
+	    LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'.
+	    ^ nil
+	].
+
+	ldArg := '-bI:' , librunExpFileName ,
+		' -bE:' , baseFileName , '.exp' ,
+		' -bM:SRE -e _' , baseFileName , '_Init'.
     ].
 
     oFileName := './' , baseFileName , (self objectFileExtension).
     needSharedObject ifTrue:[
-        self activityNotification:'generating shared object'.
-
-        soFileName := './' , baseFileName , (self sharedLibraryExtension). 
-        OperatingSystem removeFile:soFileName.
-        ld := ld , ' ' , ldArg , ' ', 
-                 (SearchedLibraries asStringCollection asStringWith: $ ), 
-                 ' -o ' , soFileName , ' ' , oFileName.
-
-        Verbose ifTrue:[
-            'linking with:' infoPrintCR.
-            '   ' infoPrint. ld infoPrintCR.
-        ].         
-        ok := OperatingSystem 
-                executeCommand:(ld , ' >errorOutput 2>&1').
-
-        ok ifFalse:[
-            output := 'errorOutput' asFilename contents asString.
-            Transcript showCR:'linker error message:'.
-            Transcript showCR:output; endEntry.
-        ].
-
-        OperatingSystem removeFile:oFileName.
-        expFileName notNil ifTrue:[
-            OperatingSystem removeFile:expFileName
-        ].
-        ^ soFileName. 
+	self activityNotification:'generating shared object'.
+
+	soFileName := './' , baseFileName , (self sharedLibraryExtension). 
+	OperatingSystem removeFile:soFileName.
+	ld := ld , ' ' , ldArg , ' ', 
+		 (SearchedLibraries asStringCollection asStringWith: $ ), 
+		 ' -o ' , soFileName , ' ' , oFileName.
+
+	Verbose ifTrue:[
+	    'linking with:' infoPrintCR.
+	    '   ' infoPrint. ld infoPrintCR.
+	].         
+	ok := OperatingSystem 
+		executeCommand:(ld , ' >errorOutput 2>&1').
+
+	ok ifFalse:[
+	    output := 'errorOutput' asFilename contents asString.
+	    Transcript showCR:'linker error message:'.
+	    Transcript showCR:output; endEntry.
+	].
+
+	OperatingSystem removeFile:oFileName.
+	expFileName notNil ifTrue:[
+	    OperatingSystem removeFile:expFileName
+	].
+	^ soFileName. 
     ].
 
     "
@@ -2790,6 +2790,8 @@
 	    __win32_fflush(stderr);
 	}
 	if (handle == NULL) {
+	    char *msg;
+
 	    err = GetLastError();
 	    if ((@global(ErrorPrinting) == true) 
 	     || (@global(Verbose) == true)) {
@@ -2799,7 +2801,14 @@
 	    }
 	    @global(LastError) = @symbol(loadError);;
 	    @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
-	    @global(LinkErrorMessage) = __MKSTRING("LoadLibrary error");
+	    switch (err) {
+                case ERROR_BAD_FORMAT:
+		    msg = "LoadLibrary error - bad format";
+		default:
+		    msg = "LoadLibrary error";
+		    break;
+	    }
+	    @global(LinkErrorMessage) = __MKSTRING(msg);
 	    RETURN ( nil );
 	}
 	__ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
@@ -3213,7 +3222,7 @@
     |key fileName functionName deInitAddr m|
 
     Verbose ifTrue:[
-        'unload module name=' infoPrint. handle pathName infoPrintCR.
+	'unload module name=' infoPrint. handle pathName infoPrintCR.
     ].
 
     "/
@@ -3221,54 +3230,54 @@
     "/
 
     handle isFunctionObjectHandle ifTrue:[
-        handle functions do:[:f |
-                                f notNil ifTrue:[
-                                    f code:0
-                                ]
-                            ].
+	handle functions do:[:f |
+				f notNil ifTrue:[
+				    f code:0
+				]
+			    ].
     ].
 
     handle isClassLibHandle ifTrue:[
-        self deinitializeClassesFromModule:handle.
-        self unregisterModule:handle.
+	self deinitializeClassesFromModule:handle.
+	self unregisterModule:handle.
     ] ifFalse:[    
-        handle isMethodHandle ifTrue:[
-            self unregisterModule:handle.
-        ] ifFalse:[
-            "/
-            "/ call its deInit function (if present)
-            "/
-            fileName := handle pathName asFilename baseName.
-            functionName := self initFunctionBasenameForFile:fileName.
-
-            deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
-            deInitAddr notNil ifTrue:[
-                self callInitFunctionAt:deInitAddr 
-                     specialInit:false 
-                     forceOld:true 
-                     interruptable:false
-                     argument:0
-                     identifyAs:handle
-                     returnsObject:false.
-            ]
-        ]
+	handle isMethodHandle ifTrue:[
+	    self unregisterModule:handle.
+	] ifFalse:[
+	    "/
+	    "/ call its deInit function (if present)
+	    "/
+	    fileName := handle pathName asFilename baseName.
+	    functionName := self initFunctionBasenameForFile:fileName.
+
+	    deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
+	    deInitAddr notNil ifTrue:[
+		self callInitFunctionAt:deInitAddr 
+		     specialInit:false 
+		     forceOld:true 
+		     interruptable:false
+		     argument:0
+		     identifyAs:handle
+		     returnsObject:false.
+	    ]
+	]
     ].
 
     "/
     "/ now, really unload
     "/
     (self primUnloadDynamicObject:handle) ifFalse:[
-        ^ self error:'unloadDynamic failed'
+	^ self error:'unloadDynamic failed'
     ].
 
     "/
     "/ remove from loaded objects
     "/
     LoadedObjects notNil ifTrue:[
-        key := LoadedObjects keyAtEqualValue:handle.
-        key notNil ifTrue:[
-            LoadedObjects removeKey:key
-        ]
+	key := LoadedObjects keyAtEqualValue:handle.
+	key notNil ifTrue:[
+	    LoadedObjects removeKey:key
+	]
     ].
 
     "
@@ -3276,17 +3285,17 @@
      but make it unexecutable. Its still visible in the browser.
     "
     handle isMethodHandle ifTrue:[
-        ((m := handle method) notNil 
-        and:[m ~~ 0]) ifTrue:[
-            m makeUnloaded.
-        ]
+	((m := handle method) notNil 
+	and:[m ~~ 0]) ifTrue:[
+	    m makeUnloaded.
+	]
     ].
 
     handle isClassLibHandle ifTrue:[
-        Smalltalk flushCachedClasses.
+	Smalltalk flushCachedClasses.
     ].
     handle isMethodHandle ifTrue:[
-        ObjectMemory flushCaches.
+	ObjectMemory flushCaches.
     ].
 
     handle moduleID:nil.
@@ -3775,6 +3784,6 @@
 !ObjectFileLoader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.192 1999-05-04 15:19:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.193 1999-05-05 12:29:41 cg Exp $'
 ! !
 ObjectFileLoader initialize!