--- a/ObjectFileLoader.st Thu Mar 10 15:01:45 2016 +0100
+++ b/ObjectFileLoader.st Fri Mar 11 00:45:36 2016 +0100
@@ -741,21 +741,21 @@
|os|
OperatingSystem isMSDOSlike ifTrue:[
- "/ includes all Windows systems & os/2
- ^ 'dll'
+ "/ includes all Windows systems & os/2
+ ^ 'dll'
].
OperatingSystem isVMSlike ifTrue:[
- ^ 'exe'
+ ^ 'exe'
].
os := OperatingSystem getSystemType.
"/ are we really still supporting that old stuff?
(self loadableBinaryObjectFormat == #aout) ifTrue:[
- "/ not really shared, but loadable
- ^ 'o'
+ "/ not really shared, but loadable
+ ^ 'o'
].
(os = #hpux) ifTrue:[
- ^ 'sl'
+ ^ 'sl'
].
^ 'so'
@@ -780,20 +780,20 @@
|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.
(os = 'linux') ifTrue:[
- "/ are we really still supporting that old stuff?
- self loadableBinaryObjectFormat == #aout ifTrue:[
- ^ #('o' 'obj' 'a')
- ].
- ^ #('so')
+ "/ are we really still supporting that old stuff?
+ self loadableBinaryObjectFormat == #aout ifTrue:[
+ ^ #('o' 'obj' 'a')
+ ].
+ ^ #('so')
].
(os = 'hpux') ifTrue:[^ #('sl') ].
(os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ].
@@ -907,7 +907,7 @@
handle := self loadDynamicObject:aFileName.
handle isNil ifTrue:[
- ^ nil
+ ^ nil
].
"
@@ -916,9 +916,9 @@
symName := '_' , aClassName , '_Init'.
initAddr := self getFunction:symName from:handle.
initAddr isNil ifTrue:[
- "try with added underscore"
- symName := '__' , aClassName , '_Init'.
- initAddr := self getFunction:symName from:handle.
+ "try with added underscore"
+ symName := '__' , aClassName , '_Init'.
+ initAddr := self getFunction:symName from:handle.
].
knownToBeOk := true.
@@ -952,78 +952,78 @@
"/ ].
initAddr notNil ifTrue:[
- Verbose ifTrue:[
- ('calling init at: ' , (initAddr printStringRadix:16)) errorPrintCR.
- ].
- info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
- status := info at:1.
- "
- if any classes are missing ...
- "
- (status == #missingClass) ifTrue:[
- "
- ... and we are loading a module ...
- "
- Transcript showCR:'ObjectFileLoader [info]: try for missing class in same object ...'.
- Verbose ifTrue:[
- 'try for missing class:' errorPrint. (info at:2) errorPrintCR.
- ].
- otherClass := self loadClass:(info at:2) fromObjectFile:aFileName.
- otherClass notNil ifTrue:[
- "
- try again ...
- "
- Transcript showCR:'ObjectFileLoader [info]: missing class is here; try again ...'.
- info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
- status := info at:1.
- ]
- ].
-
- Verbose ifTrue:[
- 'done init status=' errorPrint. info errorPrintCR.
- ].
- (status == #unregisteredSuperclass) ifTrue:[
- Transcript showCR:'ObjectFileLoader [info]: superclass is not registered'.
- ].
-
- (Symbol hasInterned:aClassName) ifTrue:[
- newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil].
- Verbose ifTrue:[
- 'newClass is: ' errorPrint. newClass errorPrintCR
- ].
- newClass notNil ifTrue:[
- Smalltalk at:aClassName asSymbol put:newClass.
-
- (newClass includesSelector:#initialize) ifTrue:[
- Verbose ifTrue:[
- 'initialize newClass ...' errorPrintCR
- ].
- newClass initialize.
- ].
- "force cache flush"
- Smalltalk isInitialized ifTrue:[
- Smalltalk changed.
- ]
- ].
- ] ifFalse:[
- 'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint.
- ' did not define itself' errorPrintCR
- "
- do not unload - could have installed other classes/methods ...
- "
- ].
- ^ newClass
+ Verbose ifTrue:[
+ ('calling init at: ' , (initAddr printStringRadix:16)) errorPrintCR.
+ ].
+ info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
+ status := info at:1.
+ "
+ if any classes are missing ...
+ "
+ (status == #missingClass) ifTrue:[
+ "
+ ... and we are loading a module ...
+ "
+ Transcript showCR:'ObjectFileLoader [info]: try for missing class in same object ...'.
+ Verbose ifTrue:[
+ 'try for missing class:' errorPrint. (info at:2) errorPrintCR.
+ ].
+ otherClass := self loadClass:(info at:2) fromObjectFile:aFileName.
+ otherClass notNil ifTrue:[
+ "
+ try again ...
+ "
+ Transcript showCR:'ObjectFileLoader [info]: missing class is here; try again ...'.
+ info := self performModuleInitAt:initAddr for:aClassName identifyAs:handle.
+ status := info at:1.
+ ]
+ ].
+
+ Verbose ifTrue:[
+ 'done init status=' errorPrint. info errorPrintCR.
+ ].
+ (status == #unregisteredSuperclass) ifTrue:[
+ Transcript showCR:'ObjectFileLoader [info]: superclass is not registered'.
+ ].
+
+ (Symbol hasInterned:aClassName) ifTrue:[
+ newClass := Smalltalk at:aClassName asSymbol ifAbsent:[nil].
+ Verbose ifTrue:[
+ 'newClass is: ' errorPrint. newClass errorPrintCR
+ ].
+ newClass notNil ifTrue:[
+ Smalltalk at:aClassName asSymbol put:newClass.
+
+ (newClass includesSelector:#initialize) ifTrue:[
+ Verbose ifTrue:[
+ 'initialize newClass ...' errorPrintCR
+ ].
+ newClass initialize.
+ ].
+ "force cache flush"
+ Smalltalk isInitialized ifTrue:[
+ Smalltalk changed.
+ ]
+ ].
+ ] ifFalse:[
+ 'ObjectFileLoader [warning]: class ' errorPrint. aClassName errorPrint.
+ ' did not define itself' errorPrintCR
+ "
+ do not unload - could have installed other classes/methods ...
+ "
+ ].
+ ^ newClass
].
Verbose ifTrue:[
- ('no symbol: ', symName,' in ',aFileName) errorPrintCR.
+ ('no symbol: ', symName,' in ',aFileName) errorPrintCR.
].
"
unload
"
Verbose ifTrue:[
- 'unloading due to init failure:' errorPrint. handle pathName errorPrintCR.
+ 'unloading due to init failure:' errorPrint. handle pathName errorPrintCR.
].
"/ moreHandles notNil ifTrue:[
@@ -1036,7 +1036,7 @@
"/ ].
Verbose ifTrue:[
- ('unloading: ', handle printString) errorPrintCR.
+ ('unloading: ', handle printString) errorPrintCR.
].
self unloadDynamicObject:handle.
^ nil
@@ -1233,13 +1233,13 @@
handle := self handleForDynamicObject:filename.
handle notNil ifTrue:[
- "already loaded"
- ^ handle.
+ "already loaded"
+ ^ handle.
].
handle := self loadDynamicObject:filename.
handle isNil ifTrue:[
- ^ nil
+ ^ nil
].
didInit := false.
@@ -1249,23 +1249,23 @@
are to be resolved. If that's the case, load all libraries ..."
ParserFlags searchedLibraries notNil ifTrue:[
- (self hasUndefinedSymbolsIn:handle) ifTrue:[
- self initializeLoader.
-
- ParserFlags 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.
+
+ ParserFlags 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:('ObjectFileLoader [info]: still undefined symbols in ', pathName,'.').
- ].
- ]
+ ]
+ ].
+ (self hasUndefinedSymbolsIn:handle) isNil ifTrue:[
+ Transcript showCR:('ObjectFileLoader [info]: still undefined symbols in ', pathName,'.').
+ ].
+ ]
].
"
@@ -1280,208 +1280,208 @@
This is used in ST packaged classLib object files"
(initFunctionName startsWith:'lib') ifTrue:[
- definitionClassName := initFunctionName copyFrom:4.
- definitionClass := Smalltalk classNamed:definitionClassName.
+ definitionClassName := initFunctionName copyFrom:4.
+ definitionClass := Smalltalk classNamed:definitionClassName.
].
(definitionClass isNil or:[definitionClass isLoaded not]) ifTrue:[
- "the project definition class has not been loaded yet.
- initialize and load it"
-
- initDefinitionAddr := self findInitDefinitionFunction:initFunctionName in:handle.
- initDefinitionAddr isNil ifTrue:[
- ('WARNING: no init definitions for: ' , pathName) errorPrintCR.
- ] ifFalse:[
- Verbose ifTrue:[
- ('calling initDefinition at:' , (initDefinitionAddr printStringRadix:16)) errorPrintCR.
- ].
- info := self
- performModuleInitAt:initDefinitionAddr
- invokeInitializeMethods:false
- for:definitionClassName
- identifyAs:handle.
- status := info at:1.
- status == #ok ifTrue:[
- "/ now, we have only loaded and installed the projectDefinition class.
- "/ (but no containing classes or extensions, yet).
- "/ let the projectDefinition load any prereqs
- definitionClassName notNil ifTrue:[
- definitionClass := Smalltalk classNamed:definitionClassName.
- definitionClass notNil ifTrue:[
- definitionClass
- initialize;
- loadMandatoryPreRequisitesAsAutoloaded:false.
- ].
- ].
- ]
- ].
+ "the project definition class has not been loaded yet.
+ initialize and load it"
+
+ initDefinitionAddr := self findInitDefinitionFunction:initFunctionName in:handle.
+ initDefinitionAddr isNil ifTrue:[
+ ('WARNING: no init definitions for: ' , pathName) errorPrintCR.
+ ] ifFalse:[
+ Verbose ifTrue:[
+ ('calling initDefinition at:' , (initDefinitionAddr printStringRadix:16)) errorPrintCR.
+ ].
+ info := self
+ performModuleInitAt:initDefinitionAddr
+ invokeInitializeMethods:false
+ for:definitionClassName
+ identifyAs:handle.
+ status := info at:1.
+ status == #ok ifTrue:[
+ "/ now, we have only loaded and installed the projectDefinition class.
+ "/ (but no containing classes or extensions, yet).
+ "/ let the projectDefinition load any prereqs
+ definitionClassName notNil ifTrue:[
+ definitionClass := Smalltalk classNamed:definitionClassName.
+ definitionClass notNil ifTrue:[
+ definitionClass
+ initialize;
+ loadMandatoryPreRequisitesAsAutoloaded:false.
+ ].
+ ].
+ ]
+ ].
].
"look for explicit init (xxx_Init) function
This is used in ST object files"
initAddr := self findInitFunction:initFunctionName in:handle.
initAddr notNil ifTrue:[
- Verbose ifTrue:[
- ('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR.
- ].
- info := self
- performModuleInitAt:initAddr
- invokeInitializeMethods:invokeInitializeMethods
- for:nil
- identifyAs:handle.
- status := info at:1.
- status == #ok ifTrue:[
- didInit := true.
- definitionClassName notNil ifTrue:[
- definitionClass := Smalltalk classNamed:definitionClassName.
- ]
- ]
+ Verbose ifTrue:[
+ ('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR.
+ ].
+ info := self
+ performModuleInitAt:initAddr
+ invokeInitializeMethods:invokeInitializeMethods
+ for:nil
+ identifyAs:handle.
+ status := info at:1.
+ status == #ok ifTrue:[
+ didInit := true.
+ definitionClassName notNil ifTrue:[
+ definitionClass := Smalltalk classNamed:definitionClassName.
+ ]
+ ]
] ifFalse:[
- "look for explicit C-init (xxx__Init) function
- This is used in C object files"
-
- initAddr := self findFunction:initFunctionName suffix:'__Init' in:handle.
- initAddr notNil ifTrue:[
- isCModule := true.
-
- OSSignalInterrupt handle:[:ex |
- ('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , pathName) errorPrintCR.
- status := #initFailed.
- ] do:[
- (self
- saveCallInitFunctionAt:initAddr
- in:pathNameOrFilename
- specialInit:false
- forceOld:true
- interruptable:false
- argument:0
- identifyAs:handle
- returnsObject:false) < 0
- ifTrue:[
- Verbose ifTrue:[
- 'init function return failure ... unload' errorPrintCR.
- ].
- 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 ...' errorPrintCR.
- ].
- initNames := self namesMatching:'*_Init' segment:'[tT?]' in:pathName.
- 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 ', pathName).
- ] ifFalse:[
- Verbose ifTrue:[
- ('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR
- ].
- self
- performModuleInitAt:initAddr
- invokeInitializeMethods:invokeInitializeMethods
- for:nil
- identifyAs:handle.
- didInit := true.
- ]
- ].
- ].
- ]
+ "look for explicit C-init (xxx__Init) function
+ This is used in C object files"
+
+ initAddr := self findFunction:initFunctionName suffix:'__Init' in:handle.
+ initAddr notNil ifTrue:[
+ isCModule := true.
+
+ OSSignalInterrupt handle:[:ex |
+ ('ObjectFileLoader [warning]: hard error in initFunction of class-module: ' , pathName) errorPrintCR.
+ status := #initFailed.
+ ] do:[
+ (self
+ saveCallInitFunctionAt:initAddr
+ in:pathNameOrFilename
+ specialInit:false
+ forceOld:true
+ interruptable:false
+ argument:0
+ identifyAs:handle
+ returnsObject:false) < 0
+ ifTrue:[
+ Verbose ifTrue:[
+ 'init function return failure ... unload' errorPrintCR.
+ ].
+ 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 ...' errorPrintCR.
+ ].
+ initNames := self namesMatching:'*_Init' segment:'[tT?]' in:pathName.
+ 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 ', pathName).
+ ] ifFalse:[
+ Verbose ifTrue:[
+ ('calling init at:' , (initAddr printStringRadix:16)) errorPrintCR
+ ].
+ self
+ performModuleInitAt:initAddr
+ invokeInitializeMethods:invokeInitializeMethods
+ for:nil
+ identifyAs:handle.
+ didInit := true.
+ ]
+ ].
+ ].
+ ]
].
(invokeInitializeMethods and:[didInit not]) ifTrue:[
- status == #noInitFunction ifTrue:[
- msg := 'no classLib init function found; assume load ok'
- ] ifFalse:[
- (status ~~ #registrationFailed
- and:[status ~~ #initFailed
- and:[status ~~ #missingClass
- and:[status ~~ #versionMismatch]]])
- ifTrue:[
- self listUndefinedSymbolsIn:handle.
- ].
-
- Verbose ifTrue:[
- 'unloading, since init failed ...' errorPrintCR.
- ].
-
- "/ give caller a chance to prevent unloading (to register later, when a prerequisite class comes)
- status == #missingClass ifTrue:[
- self breakPoint:#sv.
- doNotUnload := (SuperClassMissingErrorNotification query ? false).
- ] ifFalse:[
- status == #registrationFailed ifTrue:[
- self breakPoint:#sv.
- doNotUnload := (RegistrationFailedErrorNotification query ? false).
- ] ifFalse:[
- doNotUnload := false.
- ].
- ].
- doNotUnload ifFalse:[
- self unloadDynamicObject:handle.
- Verbose ifTrue:[
- 'unloaded.' errorPrintCR.
- ].
- handle := nil.
- ].
-
- status == #initFailed ifTrue:[
- msg := 'module not loaded (init function signaled failure).'
- ] ifFalse:[
- status == #missingClass ifTrue:[
- msg := 'module not loaded (superclass missing: ' , (info at:2) , ').'
- ] ifFalse:[
- status == #registrationFailed ifTrue:[
- msg := 'module registration failed (incompatible object or missing superclass)'
- ] ifFalse:[
- status == #versionMismatch ifTrue:[
- msg := 'module registration failed (class version mismatch ' , (info at:2) printString , ')'
- ] ifFalse:[
- (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:pathName) notNil ifTrue:[
- msg := 'module not loaded (unknown error reason).'
- ] ifFalse:[
- msg := 'module not loaded (no _Init entry in object file ?).'
- ]
- ]
- ].
- ].
- ].
- ].
- msg := 'ObjectFileLoader [info]: <1p>: <2p>' expandMacrosWith:pathNameOrFilename asFilename baseName with:msg.
- Smalltalk isStandAloneApp ifTrue:[
- msg errorPrintCR
- ] ifFalse:[
- Transcript showCR:msg
- ].
+ status == #noInitFunction ifTrue:[
+ msg := 'no classLib init function found; assume load ok'
+ ] ifFalse:[
+ (status ~~ #registrationFailed
+ and:[status ~~ #initFailed
+ and:[status ~~ #missingClass
+ and:[status ~~ #versionMismatch]]])
+ ifTrue:[
+ self listUndefinedSymbolsIn:handle.
+ ].
+
+ Verbose ifTrue:[
+ 'unloading, since init failed ...' errorPrintCR.
+ ].
+
+ "/ give caller a chance to prevent unloading (to register later, when a prerequisite class comes)
+ status == #missingClass ifTrue:[
+ self breakPoint:#sv.
+ doNotUnload := (SuperClassMissingErrorNotification query ? false).
+ ] ifFalse:[
+ status == #registrationFailed ifTrue:[
+ self breakPoint:#sv.
+ doNotUnload := (RegistrationFailedErrorNotification query ? false).
+ ] ifFalse:[
+ doNotUnload := false.
+ ].
+ ].
+ doNotUnload ifFalse:[
+ self unloadDynamicObject:handle.
+ Verbose ifTrue:[
+ 'unloaded.' errorPrintCR.
+ ].
+ handle := nil.
+ ].
+
+ status == #initFailed ifTrue:[
+ msg := 'module not loaded (init function signaled failure).'
+ ] ifFalse:[
+ status == #missingClass ifTrue:[
+ msg := 'module not loaded (superclass missing: ' , (info at:2) , ').'
+ ] ifFalse:[
+ status == #registrationFailed ifTrue:[
+ msg := 'module registration failed (incompatible object or missing superclass)'
+ ] ifFalse:[
+ status == #versionMismatch ifTrue:[
+ msg := 'module registration failed (class version mismatch ' , (info at:2) printString , ')'
+ ] ifFalse:[
+ (self namesMatching:'*__sepInitCode__*' segment:'[tT?]' in:pathName) notNil ifTrue:[
+ msg := 'module not loaded (unknown error reason).'
+ ] ifFalse:[
+ msg := 'module not loaded (no _Init entry in object file ?).'
+ ]
+ ]
+ ].
+ ].
+ ].
+ ].
+ msg := 'ObjectFileLoader [info]: <1p>: <2p>' expandMacrosWith:pathNameOrFilename asFilename baseName with:msg.
+ Smalltalk isStandAloneApp ifTrue:[
+ msg errorPrintCR
+ ] ifFalse:[
+ Transcript showCR:msg
+ ].
].
isCModule ifFalse:[
- Smalltalk flushCachedClasses.
- Class flushSubclassInfo.
-
- (definitionClass notNil and:[definitionClass isLoaded]) ifTrue:[
- definitionClass supportedOnPlatform ifTrue:[
- definitionClass loadAllClassesAsAutoloaded:true.
- "/ load non-mandatory prerequisites
- definitionClass loadPreRequisitesAsAutoloaded:true.
- definitionClass projectIsLoaded:true.
- ].
- ].
- Smalltalk isInitialized ifTrue:[
- "really don't know, if and what has changed ...
- ... but assume, that new classes have been installed."
- Smalltalk changed:#postLoad.
- ].
+ Smalltalk flushCachedClasses.
+ Class flushSubclassInfo.
+
+ (definitionClass notNil and:[definitionClass isLoaded]) ifTrue:[
+ definitionClass supportedOnPlatform ifTrue:[
+ definitionClass loadAllClassesAsAutoloaded:true.
+ "/ load non-mandatory prerequisites
+ definitionClass loadPreRequisitesAsAutoloaded:true.
+ definitionClass projectIsLoaded:true.
+ ].
+ ].
+ Smalltalk isInitialized ifTrue:[
+ "really don't know, if and what has changed ...
+ ... but assume, that new classes have been installed."
+ Smalltalk changed:#postLoad.
+ ].
].
^ handle
@@ -1595,26 +1595,26 @@
initAddr notNil ifTrue:[^ initAddr].
(functionName startsWith:'lib') ifTrue:[
- className := functionName
+ className := functionName
] ifFalse:[
- "
- look for reverse abbreviation - slow, because abbrevs are recursively read
- "
- className := Smalltalk classNameForFile:functionName.
+ "
+ look for reverse abbreviation - slow, because abbrevs are recursively read
+ "
+ className := Smalltalk classNameForFile:functionName.
].
className notNil ifTrue:[
- initAddr := self getFunction:(className , suffix) from:handle.
- initAddr notNil ifTrue:[^ initAddr].
-
- initAddr := self getFunction:('_' , className , suffix) from:handle.
- initAddr isNil ifTrue:[
- "/
- "/ special for broken ultrix nlist
- "/ (will not find symbol with single underscore)
- "/ workaround: add another underscore and retry
- "/
- initAddr := self getFunction:('__' , className , suffix) from:handle.
- ].
+ initAddr := self getFunction:(className , suffix) from:handle.
+ initAddr notNil ifTrue:[^ initAddr].
+
+ initAddr := self getFunction:('_' , className , suffix) from:handle.
+ initAddr isNil ifTrue:[
+ "/
+ "/ special for broken ultrix nlist
+ "/ (will not find symbol with single underscore)
+ "/ workaround: add another underscore and retry
+ "/
+ initAddr := self getFunction:('__' , className , suffix) from:handle.
+ ].
].
^ initAddr
@@ -1745,47 +1745,47 @@
char *name;
if (__isStringLike(aString)) {
- name = (char *) __stringVal(aString);
- if (isFunction == false) {
- addr = dld_get_symbol(name);
- if (addr) {
- if (@global(Verbose) == true) {
- console_printf("addr of %s = %x\n", name, addr);
- }
- address = __MKUINT( addr );
- }
- } else {
- func = (void (*) ()) dld_get_func(name);
- if (func) {
- if (@global(Verbose) == true) {
- console_printf("addr of %s = %x\n", name, (INT)func);
- }
- if (dld_function_executable_p(name)) {
- address = __MKUINT( (INT)func );
- } else {
- char **undefNames;
- char **nm;
- int i;
-
- if (@global(Verbose) == true) {
- console_printf ("function %s not executable\n", name);
- dld_perror("not executable");
-
- console_printf("undefined:\n");
- nm = undefNames = dld_list_undefined_sym();
- for (i=dld_undefined_sym_count; i; i--) {
- console_printf(" %s\n", *nm++);
- }
- free(undefNames);
- }
- }
- } else {
- if (@global(Verbose) == true) {
- console_printf ("function %s not found\n", name);
- dld_perror("get_func");
- }
- }
- }
+ name = (char *) __stringVal(aString);
+ if (isFunction == false) {
+ addr = dld_get_symbol(name);
+ if (addr) {
+ if (@global(Verbose) == true) {
+ console_printf("addr of %s = %x\n", name, addr);
+ }
+ address = __MKUINT( addr );
+ }
+ } else {
+ func = (void (*) ()) dld_get_func(name);
+ if (func) {
+ if (@global(Verbose) == true) {
+ console_printf("addr of %s = %x\n", name, (INT)func);
+ }
+ if (dld_function_executable_p(name)) {
+ address = __MKUINT( (INT)func );
+ } else {
+ char **undefNames;
+ char **nm;
+ int i;
+
+ if (@global(Verbose) == true) {
+ console_printf ("function %s not executable\n", name);
+ dld_perror("not executable");
+
+ console_printf("undefined:\n");
+ nm = undefNames = dld_list_undefined_sym();
+ for (i=dld_undefined_sym_count; i; i--) {
+ console_printf(" %s\n", *nm++);
+ }
+ free(undefNames);
+ }
+ }
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf ("function %s not found\n", name);
+ dld_perror("get_func");
+ }
+ }
+ }
}
}
#endif /* GNU_DL */
@@ -1800,27 +1800,27 @@
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
# if __POINTER_SIZE__ == 8
- val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
+ val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
# else
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
# endif
- handle = (HMODULE)(val);
- if (__isStringLike(aString)) {
- if (@global(Verbose) == true)
- console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle);
- entry = GetProcAddress(handle, (char *) __stringVal(aString));
- if (entry != NULL) {
- addr = (void *)entry;
- if (@global(Verbose) == true) {
- console_printf("GetProcAddr %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
- }
- address = __MKUINT( (int)addr );
- } else {
- if (@global(Verbose) == true) {
- console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
- }
- }
- }
+ handle = (HMODULE)(val);
+ if (__isStringLike(aString)) {
+ if (@global(Verbose) == true)
+ console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)handle);
+ entry = GetProcAddress(handle, (char *) __stringVal(aString));
+ if (entry != NULL) {
+ addr = (void *)entry;
+ if (@global(Verbose) == true) {
+ console_printf("GetProcAddr %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
+ }
+ address = __MKUINT( (int)addr );
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
+ }
+ }
+ }
}
}
#endif
@@ -1834,29 +1834,29 @@
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
# if __POINTER_SIZE__ == 8
- val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
+ val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
# else
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
# endif
- handle = (void *)(val);
-
- if (__isStringLike(aString)) {
- if (@global(Verbose) == true)
- console_printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle);
- entry = NULL;
- get_image_symbol((image_id) handle, (char *) __stringVal(aString), B_SYMBOL_TYPE_TEXT, &entry);
- if (entry != NULL) {
- addr = (void *)entry;
- if (@global(Verbose) == true) {
- console_printf("get_image_symbol %s ok; addr = %x\n", __stringVal(aString), addr);
- }
- address = __MKUINT( (int)addr );
- } else {
- if (@global(Verbose) == true) {
- console_printf("get_image_symbol %s error\n", __stringVal(aString));
- }
- }
- }
+ handle = (void *)(val);
+
+ if (__isStringLike(aString)) {
+ if (@global(Verbose) == true)
+ console_printf("get sym <%s> handle = %x\n", __stringVal(aString), (int)handle);
+ entry = NULL;
+ get_image_symbol((image_id) handle, (char *) __stringVal(aString), B_SYMBOL_TYPE_TEXT, &entry);
+ if (entry != NULL) {
+ addr = (void *)entry;
+ if (@global(Verbose) == true) {
+ console_printf("get_image_symbol %s ok; addr = %x\n", __stringVal(aString), addr);
+ }
+ address = __MKUINT( (int)addr );
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("get_image_symbol %s error\n", __stringVal(aString));
+ }
+ }
+ }
}
}
#endif
@@ -1868,20 +1868,20 @@
INT val;
if (__isStringLike(aString)) {
- if (__isStringLike(sysHandle1)) {
- if (@global(Verbose) == true)
- console_printf("get sym <%s> handle = %x\n",
- __stringVal(aString), __stringVal(sysHandle1));
- addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString));
- if (addr) {
- if (@global(Verbose) == true)
- console_printf("addr = %x\n", addr);
- address = __MKUINT( (int)addr );
- } else {
- if (@global(Verbose) == true)
- console_printf("dl_getsymbol %s failed\n", __stringVal(aString));
- }
- }
+ if (__isStringLike(sysHandle1)) {
+ if (@global(Verbose) == true)
+ console_printf("get sym <%s> handle = %x\n",
+ __stringVal(aString), __stringVal(sysHandle1));
+ addr = dl_getsymbol(__stringVal(sysHandle1), __stringVal(aString));
+ if (addr) {
+ if (@global(Verbose) == true)
+ console_printf("addr = %x\n", addr);
+ address = __MKUINT( (int)addr );
+ } else {
+ if (@global(Verbose) == true)
+ console_printf("dl_getsymbol %s failed\n", __stringVal(aString));
+ }
+ }
}
}
#endif
@@ -1896,27 +1896,27 @@
if (__bothSmallInteger(low, hi)) {
# if __POINTER_SIZE__ == 8
- val = (__intVal(hi) << 32) + __intVal(low);
+ val = (__intVal(hi) << 32) + __intVal(low);
# else
- val = (__intVal(hi) << 16) + __intVal(low);
+ val = (__intVal(hi) << 16) + __intVal(low);
# endif
- h = (void *)(val);
- if (__isStringLike(aString)) {
- if (@global(Verbose) == true) {
- console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)h);
- }
- addr = dlsym(h, (char *) __stringVal(aString));
- if (addr) {
- if (@global(Verbose) == true) {
- console_printf("dlsym %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
- }
- address = __MKUINT( (INT)addr );
- } else {
- if (@global(Verbose) == true) {
- console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
- }
- }
- }
+ h = (void *)(val);
+ if (__isStringLike(aString)) {
+ if (@global(Verbose) == true) {
+ console_printf("get sym <%s> handle = %"_lx_"\n", __stringVal(aString), (INT)h);
+ }
+ addr = dlsym(h, (char *) __stringVal(aString));
+ if (addr) {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s ok; addr = %"_lx_"\n", __stringVal(aString), (INT)addr);
+ }
+ address = __MKUINT( (INT)addr );
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
+ }
+ }
+ }
}
}
#endif
@@ -1930,27 +1930,27 @@
if (__bothSmallInteger(low, hi)) {
# if __POINTER_SIZE__ == 8
- val = (__intVal(hi) << 32) + __intVal(low);
+ val = (__intVal(hi) << 32) + __intVal(low);
# else
- val = (_intVal(hi) << 16) + _intVal(low);
+ val = (_intVal(hi) << 16) + _intVal(low);
# endif
- h = (void *)(val);
- if (__isStringLike(aString)) {
- if (@global(Verbose) == true) {
- console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
- }
- ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr);
- if (ret != 0) {
- if (@global(Verbose) == true) {
- console_printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno);
- }
- } else {
- if (@global(Verbose) == true) {
- console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
- }
- address = __MKUINT( (INT)addr );
- }
- }
+ h = (void *)(val);
+ if (__isStringLike(aString)) {
+ if (@global(Verbose) == true) {
+ console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
+ }
+ ret = shl_findsym(h, __stringVal(aString), TYPE_UNDEFINED, &addr);
+ if (ret != 0) {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s error; errno=%d\n", __stringVal(aString), errno);
+ }
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
+ }
+ address = __MKUINT( (INT)addr );
+ }
+ }
}
}
#endif
@@ -1965,80 +1965,80 @@
OBJ low = sysHandle1, hi = sysHandle2;
char nameBuffer[256];
static struct funcDescriptor {
- unsigned vaddr;
- unsigned long2;
- unsigned long3;
+ unsigned vaddr;
+ unsigned long2;
+ unsigned long3;
} descriptor;
if (__bothSmallInteger(low, hi)
&& __isStringLike(aString) && __isStringLike(pathName)) {
# if __POINTER_SIZE__ == 8
- val = (__intVal(hi) << 32) + __intVal(low);
+ val = (__intVal(hi) << 32) + __intVal(low);
# else
- val = (__intVal(hi) << 16) + __intVal(low);
+ val = (__intVal(hi) << 16) + __intVal(low);
# endif
- h = (void *)(val);
-
- if (@global(Verbose) == true) {
- console_printf("get sym <%s> handle = %x path= %s\n",
- __stringVal(aString), h, __stringVal(pathName));
- }
+ h = (void *)(val);
+
+ if (@global(Verbose) == true) {
+ console_printf("get sym <%s> handle = %x path= %s\n",
+ __stringVal(aString), h, __stringVal(pathName));
+ }
#define USE_ENTRY
#ifdef USE_ENTRY
- /*
- * only works, if the entry-function is the Init function
- * (i.e. linked with -e _xxx_Init)
- */
- if (@global(Verbose) == true) {
- console_printf("returned handle as addr = %x\n", h);
- }
- address = __MKUINT( (int)(h) );
+ /*
+ * only works, if the entry-function is the Init function
+ * (i.e. linked with -e _xxx_Init)
+ */
+ if (@global(Verbose) == true) {
+ console_printf("returned handle as addr = %x\n", h);
+ }
+ address = __MKUINT( (int)(h) );
#else
# ifdef USE_DESCRIPTOR
- if (isFunction == true) {
+ if (isFunction == true) {
# else
- if (0) {
+ if (0) {
# endif
- nameBuffer[0] = '.';
- strcpy(nameBuffer+1, aString);
- nl[0].n_name = nameBuffer;
- } else {
- nl[0].n_name = __stringVal(aString);
- }
- nl[1].n_name = "";
-
- if (nlist(__stringVal(pathName), &nl) == -1) {
- if (@global(Verbose) == true) {
- console_printf("nlist error\n");
- }
- } else {
- addr = (void *)((unsigned)nl[0].n_value + (unsigned)h);
-
- if (isFunction == true) {
+ nameBuffer[0] = '.';
+ strcpy(nameBuffer+1, aString);
+ nl[0].n_name = nameBuffer;
+ } else {
+ nl[0].n_name = __stringVal(aString);
+ }
+ nl[1].n_name = "";
+
+ if (nlist(__stringVal(pathName), &nl) == -1) {
+ if (@global(Verbose) == true) {
+ console_printf("nlist error\n");
+ }
+ } else {
+ addr = (void *)((unsigned)nl[0].n_value + (unsigned)h);
+
+ if (isFunction == true) {
# ifdef USE_DESCRIPTOR
- console_printf("daddr = %x\n", addr);
- console_printf("daddr[0] = %x\n", ((long *)addr)[0]);
- console_printf("daddr[1] = %x\n", ((long *)addr)[1]);
- console_printf("daddr[2] = %x\n", ((long *)addr)[2]);
+ console_printf("daddr = %x\n", addr);
+ console_printf("daddr[0] = %x\n", ((long *)addr)[0]);
+ console_printf("daddr[1] = %x\n", ((long *)addr)[1]);
+ console_printf("daddr[2] = %x\n", ((long *)addr)[2]);
# endif
- }
-
- if (@global(Verbose) == true) {
- console_printf("value=%x section=%d type=%x sclass=%d\n",
- nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
- console_printf("vaddr = %x\n", addr);
- }
+ }
+
+ if (@global(Verbose) == true) {
+ console_printf("value=%x section=%d type=%x sclass=%d\n",
+ nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
+ console_printf("vaddr = %x\n", addr);
+ }
# ifdef DOES_NOT_WORK
- address = __MKUINT( (int)addr );
+ address = __MKUINT( (int)addr );
# else
- descriptor.vaddr = (unsigned) addr;
- descriptor.long2 = 0;
- descriptor.long3 = 0;
- address = __MKUINT( (int)(&descriptor) );
+ descriptor.vaddr = (unsigned) addr;
+ descriptor.long2 = 0;
+ descriptor.long3 = 0;
+ address = __MKUINT( (int)(&descriptor) );
# endif
- }
+ }
#endif /* don't USE_ENTRY */
}
}
@@ -2053,24 +2053,24 @@
OBJ low = sysHandle1, hi = sysHandle2;
if (__bothSmallInteger(low, hi)) {
- val = (_intVal(hi) << 16) + _intVal(low);
- h = (void *)(val);
- if (__isStringLike(aString)) {
- if (@global(Verbose) == true) {
- console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
- }
- addr = dlsym(h, __stringVal(aString));
- if (addr) {
- if (@global(Verbose) == true) {
- console_printf("addr = %x\n", addr);
- }
- address = __MKUINT( (int)addr );
- } else {
- if (@global(Verbose) == true) {
- console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
- }
- }
- }
+ val = (_intVal(hi) << 16) + _intVal(low);
+ h = (void *)(val);
+ if (__isStringLike(aString)) {
+ if (@global(Verbose) == true) {
+ console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
+ }
+ addr = dlsym(h, __stringVal(aString));
+ if (addr) {
+ if (@global(Verbose) == true) {
+ console_printf("addr = %x\n", addr);
+ }
+ address = __MKUINT( (int)addr );
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
+ }
+ }
+ }
}
}
#endif
@@ -2083,20 +2083,20 @@
NXStream *errOut;
if (__isStringLike(aString)) {
- if (@global(Verbose) == true) {
- console_printf("get sym <%s>\n", __stringVal(aString));
- }
- errOut = NXOpenFile(2, 2);
- result = rld_lookup(errOut,
- (char *) __stringVal(aString),
- &addr);
- NXClose(errOut);
- if (result) {
- if (@global(Verbose) == true) {
- console_printf("addr = %x\n", addr);
- }
- address = __MKUINT( (int)addr );
- }
+ if (@global(Verbose) == true) {
+ console_printf("get sym <%s>\n", __stringVal(aString));
+ }
+ errOut = NXOpenFile(2, 2);
+ result = rld_lookup(errOut,
+ (char *) __stringVal(aString),
+ &addr);
+ NXClose(errOut);
+ if (result) {
+ if (@global(Verbose) == true) {
+ console_printf("addr = %x\n", addr);
+ }
+ address = __MKUINT( (int)addr );
+ }
}
}
#endif
@@ -2126,28 +2126,28 @@
fileName := pathNameOrFilename asFilename.
suffixLen := 0.
self validBinaryExtensions do:[:suffix |
- suffixLen == 0 ifTrue:[
- (fileName hasSuffix:suffix) ifTrue:[
- suffixLen := suffix size + 1
- ]
- ]
+ suffixLen == 0 ifTrue:[
+ (fileName hasSuffix:suffix) ifTrue:[
+ suffixLen := suffix size + 1
+ ]
+ ]
].
name := fileName baseName.
suffixLen ~~ 0 ifTrue:[
- name := name copyButLast:suffixLen
+ name := name copyButLast:suffixLen
] ifFalse:[
- ('ObjectFileLoader [warning]: invalid binary object file suffix in: ',fileName name) infoPrintCR.
- name := fileName withoutSuffix baseName
+ ('ObjectFileLoader [warning]: invalid binary object file suffix in: ',fileName name) infoPrintCR.
+ name := fileName withoutSuffix baseName
].
^ name.
"
ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.so' (unix)
ObjectFileLoader initFunctionBasenameForFile:'libstx_libbasic.dll' (msdos)
- ObjectFileLoader initFunctionBasenameForFile:'demo.so'
- ObjectFileLoader initFunctionBasenameForFile:'demo.o'
- ObjectFileLoader initFunctionBasenameForFile:'demo.obj'
+ ObjectFileLoader initFunctionBasenameForFile:'demo.so'
+ ObjectFileLoader initFunctionBasenameForFile:'demo.o'
+ ObjectFileLoader initFunctionBasenameForFile:'demo.obj'
"
"Created: / 13.7.1996 / 00:01:54 / cg"
@@ -2196,10 +2196,10 @@
undefinedNames := self getListOfUndefinedSymbolsFrom:handle.
undefinedNames size > 0 ifTrue:[
- Transcript showCR:'ObjectFileLoader [info]: undefined:'.
- undefinedNames do:[:aName |
- Transcript showCR:' ' , aName
- ]
+ Transcript showCR:'ObjectFileLoader [info]: undefined:'.
+ undefinedNames do:[:aName |
+ Transcript showCR:' ' , aName
+ ]
].
"Modified: 18.5.1996 / 15:43:45 / cg"
@@ -2319,205 +2319,205 @@
savedOldClasses functions saveOldMethodsPerClass anyModulesToInitialize m|
PreviouslyLoadedObjects notNil ifTrue:[
- anyModulesToInitialize := false.
-
- PreviouslyLoadedObjects do:[:entry |
- |fileName handle cls sel|
-
- fileName := entry key.
- handle := entry value.
- handle moduleID:nil.
-
- handle isClassLibHandle ifTrue:[
- "/ ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR.
-
- "/
- "/ remember all byteCode methods (as added in the session)
- "/
- savedOldClasses := IdentitySet new.
- saveOldMethodsPerClass := IdentityDictionary new.
-
- handle classes do:[:eachClass |
- (eachClass notNil and:[eachClass ~~ 0]) ifTrue:[
- saveOldMethodsPerClass at:eachClass put:eachClass methodDictionary copy.
- savedOldClasses add:eachClass.
- ].
- ].
- "/
- "/ load the class binary
- "/
- handle := self loadObjectFile:fileName invokeInitializeMethods:false.
- handle notNil ifTrue:[
- anyModulesToInitialize := true
- ].
-
- "/ after reloading of the objectFile,
- "/ some of the changes made in the previous life have to be
- "/ redone here - otherwise, we will be left with the
- "/ state contained in the loaded objectModule - instead of
- "/ what we had when saving the image ...
-
-
- "/
- "/ re-remove removed methods
- "/ and re-change method categories
- "/
- savedOldClasses do:[:oldClass |
- |newClass oldMethods newMethodDict newMthd
- oldCat oldClassVarString oldClassCategory|
-
- newClass := Smalltalk classNamed:(oldClass name).
- newClass notNil ifTrue:[
- oldClassVarString := oldClass classVariableString.
- newClass classVariableString ~= oldClassVarString ifTrue:[
- "/ there is no need to recreate the variable
- "/ (its in the smalltalk dictionary)
- newClass setClassVariableString:oldClassVarString
- ].
- newClass isMeta ifFalse:[
- newClass setSharedPoolNames:(oldClass sharedPoolNames).
- oldClassCategory := oldClass category.
- newClass category ~= oldClassCategory ifTrue:[
- newClass setCategory:oldClassCategory
- ]
- ].
- oldMethods := saveOldMethodsPerClass at:oldClass.
- newMethodDict := newClass methodDictionary.
- oldMethods keysAndValuesDo:[:selector :oldMethod|
- oldMethod
- code:nil;
- mclass:self.
- oldMethod byteCode isNil ifTrue:[
- "a compiled method, load the new code (addresses may have been changed)"
- newMthd := newMethodDict at:selector ifAbsent:nil.
- newMthd notNil ifTrue:[
- oldMethod code:newMthd code.
- ] ifFalse:[
- ('ObjectFileLoader [warning]: ' , oldClass name , ' missing method: ', selector, '.') errorPrintCR.
- ].
- ].
- ].
- newClass setMethodDictionary:oldMethods.
- ].
- ].
-
- "/
- "/ validate old-classes vs. new classes.
- "/ and if things look ok, get rid of old stuff
- "/ and make instances become instances of the new class
- "/
+ anyModulesToInitialize := false.
+
+ PreviouslyLoadedObjects do:[:entry |
+ |fileName handle cls sel|
+
+ fileName := entry key.
+ handle := entry value.
+ handle moduleID:nil.
+
+ handle isClassLibHandle ifTrue:[
+ "/ ('ObjectFileLoader [info]: reloading classes in ' , fileName , ' ...') infoPrintCR.
+
+ "/
+ "/ remember all byteCode methods (as added in the session)
+ "/
+ savedOldClasses := IdentitySet new.
+ saveOldMethodsPerClass := IdentityDictionary new.
+
+ handle classes do:[:eachClass |
+ (eachClass notNil and:[eachClass ~~ 0]) ifTrue:[
+ saveOldMethodsPerClass at:eachClass put:eachClass methodDictionary copy.
+ savedOldClasses add:eachClass.
+ ].
+ ].
+ "/
+ "/ load the class binary
+ "/
+ handle := self loadObjectFile:fileName invokeInitializeMethods:false.
+ handle notNil ifTrue:[
+ anyModulesToInitialize := true
+ ].
+
+ "/ after reloading of the objectFile,
+ "/ some of the changes made in the previous life have to be
+ "/ redone here - otherwise, we will be left with the
+ "/ state contained in the loaded objectModule - instead of
+ "/ what we had when saving the image ...
+
+
+ "/
+ "/ re-remove removed methods
+ "/ and re-change method categories
+ "/
+ savedOldClasses do:[:oldClass |
+ |newClass oldMethods newMethodDict newMthd
+ oldCat oldClassVarString oldClassCategory|
+
+ newClass := Smalltalk classNamed:(oldClass name).
+ newClass notNil ifTrue:[
+ oldClassVarString := oldClass classVariableString.
+ newClass classVariableString ~= oldClassVarString ifTrue:[
+ "/ there is no need to recreate the variable
+ "/ (its in the smalltalk dictionary)
+ newClass setClassVariableString:oldClassVarString
+ ].
+ newClass isMeta ifFalse:[
+ newClass setSharedPoolNames:(oldClass sharedPoolNames).
+ oldClassCategory := oldClass category.
+ newClass category ~= oldClassCategory ifTrue:[
+ newClass setCategory:oldClassCategory
+ ]
+ ].
+ oldMethods := saveOldMethodsPerClass at:oldClass.
+ newMethodDict := newClass methodDictionary.
+ oldMethods keysAndValuesDo:[:selector :oldMethod|
+ oldMethod
+ code:nil;
+ mclass:self.
+ oldMethod byteCode isNil ifTrue:[
+ "a compiled method, load the new code (addresses may have been changed)"
+ newMthd := newMethodDict at:selector ifAbsent:nil.
+ newMthd notNil ifTrue:[
+ oldMethod code:newMthd code.
+ ] ifFalse:[
+ ('ObjectFileLoader [warning]: ' , oldClass name , ' missing method: ', selector, '.') errorPrintCR.
+ ].
+ ].
+ ].
+ newClass setMethodDictionary:oldMethods.
+ ].
+ ].
+
+ "/
+ "/ validate old-classes vs. new classes.
+ "/ and if things look ok, get rid of old stuff
+ "/ and make instances become instances of the new class
+ "/
"/ ('ObjectFileLoader [info]: migrating classes ...') infoPrintCR.
- savedOldClasses do:[:oldClass |
- |newClass oldCat oldCVars|
-
- newClass := Smalltalk classNamed:(oldClass name).
- newClass == oldClass ifTrue:[
+ savedOldClasses do:[:oldClass |
+ |newClass oldCat oldCVars|
+
+ newClass := Smalltalk classNamed:(oldClass name).
+ newClass == oldClass ifTrue:[
"/ ('ObjectFileLoader [info]: class ' , oldClass name , ' reloaded.') infoPrintCR.
- ] ifFalse:[
- (newClass isNil or:[newClass == oldClass]) ifTrue:[
- ('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR.
- ] ifFalse:[
+ ] ifFalse:[
+ (newClass isNil or:[newClass == oldClass]) ifTrue:[
+ ('ObjectFileLoader [warning]: reload of ' , oldClass name , ' seemed to fail.') errorPrintCR.
+ ] ifFalse:[
"/'oldSize: ' print. oldClass instSize print. ' (' print. oldClass instSize class name print. ') ' print.
"/'newSize: ' print. newClass instSize print. ' (' print. oldClass instSize class name print. ') ' printCR.
- oldClass instSize ~~ newClass instSize ifTrue:[
- ('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR.
- ] ifFalse:[
- oldClass class instSize ~~ newClass class instSize ifTrue:[
- ('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR.
- ] ifFalse:[
+ oldClass instSize ~~ newClass instSize ifTrue:[
+ ('ObjectFileLoader [warning]: ' , oldClass name , ' has changed its size.') errorPrintCR.
+ ] ifFalse:[
+ oldClass class instSize ~~ newClass class instSize ifTrue:[
+ ('ObjectFileLoader [warning]: ' , oldClass name , ' class has changed its size.') errorPrintCR.
+ ] ifFalse:[
"/ ('ObjectFileLoader [info]: migrating ' , oldClass name) infoPrintCR.
- (oldCat := oldClass category) ~= newClass category ifTrue:[
- newClass setCategory:oldCat.
- ].
- (oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[
- newClass setClassVariableString:oldCVars
- ].
- "/ copy over the oldClasses class-instVars
- (Class instSize + 1) to:(oldClass class instSize) do:[:idx |
- newClass instVarAt:idx put:(oldClass instVarAt:idx)
- ].
- oldClass becomeSameAs:newClass
+ (oldCat := oldClass category) ~= newClass category ifTrue:[
+ newClass setCategory:oldCat.
+ ].
+ (oldCVars := oldClass classVariableString) ~= newClass classVariableString ifTrue:[
+ newClass setClassVariableString:oldCVars
+ ].
+ "/ copy over the oldClasses class-instVars
+ (Class instSize + 1) to:(oldClass class instSize) do:[:idx |
+ newClass instVarAt:idx put:(oldClass instVarAt:idx)
+ ].
+ oldClass becomeSameAs:newClass
"/ oldClass become:newClass
- ]
- ]
- ]
- ]
- ]
-
- ] ifFalse:[
- handle isMethodHandle ifTrue:[
- oldDummyMethod := handle method.
- (oldDummyMethod isMethod) ifFalse:[
- ('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR
- ] ifTrue:[
- ('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR.
- who := oldDummyMethod who.
- newHandle := self loadMethodObjectFile:fileName.
- newHandle isNil ifTrue:[
- ('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR.
- handle moduleID:nil.
- ] ifFalse:[
- m := newHandle method.
- oldDummyMethod sourceFilename notNil ifTrue:[
- m sourceFilename:(oldDummyMethod sourceFilename)
- position:(oldDummyMethod sourcePosition).
- ] ifFalse:[
- m source:(oldDummyMethod source).
- ].
- m setPackage:(oldDummyMethod package).
- who notNil ifTrue:[
- cls := who methodClass.
- sel := who methodSelector.
- m == (cls compiledMethodAt:sel) ifFalse:[
- 'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR.
- ] ifTrue:[
+ ]
+ ]
+ ]
+ ]
+ ]
+
+ ] ifFalse:[
+ handle isMethodHandle ifTrue:[
+ oldDummyMethod := handle method.
+ (oldDummyMethod isMethod) ifFalse:[
+ ('ObjectFileLoader [info]: ignore obsolete (already collected) method in ' , fileName) infoPrintCR
+ ] ifTrue:[
+ ('ObjectFileLoader [info]: reloading method in ' , fileName , ' ...') infoPrintCR.
+ who := oldDummyMethod who.
+ newHandle := self loadMethodObjectFile:fileName.
+ newHandle isNil ifTrue:[
+ ('ObjectFileLoader [warning]: failed to reload method in ' , fileName , ' ...') errorPrintCR.
+ handle moduleID:nil.
+ ] ifFalse:[
+ m := newHandle method.
+ oldDummyMethod sourceFilename notNil ifTrue:[
+ m sourceFilename:(oldDummyMethod sourceFilename)
+ position:(oldDummyMethod sourcePosition).
+ ] ifFalse:[
+ m source:(oldDummyMethod source).
+ ].
+ m setPackage:(oldDummyMethod package).
+ who notNil ifTrue:[
+ cls := who methodClass.
+ sel := who methodSelector.
+ m == (cls compiledMethodAt:sel) ifFalse:[
+ 'ObjectFileLoader [warning]: oops - loaded method installed wrong' errorPrintCR.
+ ] ifTrue:[
"/ cls changed:#methodDictionary with:(Array with:sel with:oldDummyMethod).
- ]
- ].
- ]
- ]
- ] ifFalse:[
- handle isFunctionObjectHandle ifTrue:[
- functions := handle functions.
- functions isEmpty ifTrue:[
- ('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR
- ] ifFalse:[
- newHandle := self loadDynamicObject:fileName.
- newHandle isNil ifTrue:[
- ('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR.
- handle moduleID:nil.
- ] ifFalse:[
- ('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR.
- functions do:[:eachFunction | |addr|
- addr := newHandle getFunctionAddress:(eachFunction name) into:eachFunction.
- addr isNil ifTrue:[
- ('ObjectFileLoader [info]: function: ''' , eachFunction name , ''' no longer present.') errorPrintCR.
- eachFunction invalidate.
- ] ifFalse:[
- eachFunction setModuleHandle:newHandle.
- ('ObjectFileLoader [info]: rebound function: ''' , eachFunction name , '''.') infoPrintCR.
- ]
- ].
- handle becomeSameAs:newHandle. "/ the old handle is now void
- ]
- ]
- ] ifFalse:[
- ('ObjectFileLoader [info]: ignore invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR.
- ]
- ]
- ]
- ].
- PreviouslyLoadedObjects := nil.
-
- "/ now, as we hopefully have all loaded,
- "/ send #reinitializeAfterLoad to each of them
- anyModulesToInitialize ifTrue:[
- AbortOperationRequest catch:[
- self moduleInit:4 forceOld:false interruptable:true.
- ]
- ]
+ ]
+ ].
+ ]
+ ]
+ ] ifFalse:[
+ handle isFunctionObjectHandle ifTrue:[
+ functions := handle functions.
+ functions isEmpty ifTrue:[
+ ('ObjectFileLoader [info]: ignore obsolete (unreferenced) functions in ' , fileName) infoPrintCR
+ ] ifFalse:[
+ newHandle := self loadDynamicObject:fileName.
+ newHandle isNil ifTrue:[
+ ('ObjectFileLoader [warning]: failed to reload ' , fileName , ' ...') errorPrintCR.
+ handle moduleID:nil.
+ ] ifFalse:[
+ ('ObjectFileLoader [info]: reloading ' , fileName , ' ...') infoPrintCR.
+ functions do:[:eachFunction | |addr|
+ addr := newHandle getFunctionAddress:(eachFunction name) into:eachFunction.
+ addr isNil ifTrue:[
+ ('ObjectFileLoader [info]: function: ''' , eachFunction name , ''' no longer present.') errorPrintCR.
+ eachFunction invalidate.
+ ] ifFalse:[
+ eachFunction setModuleHandle:newHandle.
+ ('ObjectFileLoader [info]: rebound function: ''' , eachFunction name , '''.') infoPrintCR.
+ ]
+ ].
+ handle becomeSameAs:newHandle. "/ the old handle is now void
+ ]
+ ]
+ ] ifFalse:[
+ ('ObjectFileLoader [info]: ignore invalid (obsolete) objectFile handle: ' , handle printString) infoPrintCR.
+ ]
+ ]
+ ]
+ ].
+ PreviouslyLoadedObjects := nil.
+
+ "/ now, as we hopefully have all loaded,
+ "/ send #reinitializeAfterLoad to each of them
+ anyModulesToInitialize ifTrue:[
+ AbortOperationRequest catch:[
+ self moduleInit:4 forceOld:false interruptable:true.
+ ]
+ ]
]
"Modified: / 18-01-2011 / 20:42:57 / cg"
@@ -2629,108 +2629,107 @@
osType := OperatingSystem getOSType.
osType = #win32 ifTrue:[
- self activityNotification:'generating shared object'.
-
- ParserFlags linkArgs isNil ifTrue:[
- ld := self linkCommand , ' ' , baseFileName , '.obj'.
- ld := ld
- , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
- , ' /OUT:' , baseFileName , '.dll '
+ self activityNotification:'generating shared object'.
+ ParserFlags linkArgs isNil ifTrue:[
+ ld := self linkCommand , ' ' , baseFileName , '.obj'.
+ ld := ld
+ , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL'
+ , ' /OUT:' , baseFileName , '.dll '
"/ , ' /DEF:' , baseFileName , '.def'.
- ] ifFalse:[
+ ] ifFalse:[
"/ libDir := ParserFlags libDirectory.
"/ (libDir notNil and:[libDir asFilename exists]) ifFalse:[
- ParserFlags useBorlandC ifTrue:[
- libDirBasename := 'lib\bc'
- ] ifFalse:[
- ParserFlags useVisualC ifTrue:[
- libDirBasename := 'lib\vc'
- ] ifFalse:[
- (ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[
- libDirBasename := 'lib\mingw'
- ] ifFalse:[
- libDirBasename := 'lib\vc'
- ]
- ]
- ].
- homeDir := Smalltalk packagePath detect:[:p | (p asFilename / 'stx' / libDirBasename) exists] ifNone:nil.
- homeDir notNil ifTrue:[
- libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName
- ].
- libDir isNil ifTrue:[
- "/ some fallback
- libDir := #( '..'
- '..\..'
- '..\..\..'
- '..\..\stx'
- '..\..\..\stx'
- ) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil.
-
- libDir isNil ifTrue:[
- LastError := errorMessage := 'could not locate directory where .lib files are (',libDirBasename,')'.
- ObjectFileLoadError raiseRequestErrorString:errorMessage.
- ^ nil
- ].
- ].
+ ParserFlags useBorlandC ifTrue:[
+ libDirBasename := 'lib\bc'
+ ] ifFalse:[
+ ParserFlags useVisualC ifTrue:[
+ libDirBasename := 'lib\vc'
+ ] ifFalse:[
+ (ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[
+ libDirBasename := 'lib\mingw'
+ ] ifFalse:[
+ libDirBasename := 'lib\vc'
+ ]
+ ]
+ ].
+ homeDir := Smalltalk packagePath detect:[:p | (p asFilename / 'stx' / libDirBasename) exists] ifNone:nil.
+ homeDir notNil ifTrue:[
+ libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName
+ ].
+ libDir isNil ifTrue:[
+ "/ some fallback
+ libDir := #( '..'
+ '..\..'
+ '..\..\..'
+ '..\..\stx'
+ '..\..\..\stx'
+ ) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil.
+
+ libDir isNil ifTrue:[
+ LastError := errorMessage := 'could not locate directory where .lib files are (',libDirBasename,')'.
+ ObjectFileLoadError raiseRequestErrorString:errorMessage.
+ ^ nil
+ ].
+ ].
"/ ].
- ParserFlags useBorlandC ifTrue:[
- ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
- ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
- ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
- ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
- ld := ld , ' ',libDir,'\cs32i.lib,,'.
- ] ifFalse:[
- ParserFlags useVisualC ifTrue:[
- "/ todo: fix for correct link libs
- ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
- ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
- ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
- ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
- ld := ld , ' ',libDir,'\cs32i.lib,,'.
- ] ifFalse:[
- (ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[
- ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
- ld := ld , ' -shared -o ',baseFileName,'.dll '.
- ld := ld , baseFileName,'.obj '.
- ld := ld , libDir,'\librun.lib '.
- ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
- ] ifFalse:[
- ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'.
- LastError := 'for dynamic objects, only borlandC is (currently) supported'.
- ^ nil
- ]
- ]
- ]
- ].
-
- outfile := (baseFileName , '.out').
- (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[
- Transcript showCR:('executing: ',ld).
- ].
-
- ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
- ok ifFalse:[
- output := (baseFileName , '.out') asFilename contentsOfEntireFile.
- Transcript showCR:output; endEntry.
- Transcript showCR:'Failed linkCommand:'.
- Transcript showCR:ld.
- Transcript showCR:'ParserFlags are:'.
- Transcript showCR:ParserFlags.
- ].
-
- #('.obj' '.out' '.tds' '.ilc' '.ild'
- '.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix|
- (baseFileName , eachSuffix) asFilename delete.
- ].
-
- ok ifFalse:[
- LastError := output.
- "/ ObjectFileLoadError raiseRequestErrorString:'link failed'.
- ^ nil
- ].
- oFileName := (baseFileName , self sharedLibraryExtension) asFilename name.
- ^ oFileName
+ ParserFlags useBorlandC ifTrue:[
+ ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
+ ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
+ ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
+ ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
+ ld := ld , ' ',libDir,'\cs32i.lib,,'.
+ ] ifFalse:[
+ ParserFlags useVisualC ifTrue:[
+ "/ todo: fix for correct link libs
+ ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
+ ld := ld , ' c0d32.obj ' , baseFileName , '.obj '.
+ ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '.
+ ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
+ ld := ld , ' ',libDir,'\cs32i.lib,,'.
+ ] ifFalse:[
+ (ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[
+ ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName).
+ ld := ld , ' -shared -o ',baseFileName,'.dll '.
+ ld := ld , baseFileName,'.obj '.
+ ld := ld , libDir,'\librun.lib '.
+ ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ).
+ ] ifFalse:[
+ ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'.
+ LastError := 'for dynamic objects, only borlandC is (currently) supported'.
+ ^ nil
+ ]
+ ]
+ ]
+ ].
+
+ outfile := (baseFileName , '.out').
+ (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[
+ Transcript showCR:('executing: ',ld).
+ ].
+
+ ok := OperatingSystem executeCommand:(ld , ' >' , outfile).
+ ok ifFalse:[
+ output := (baseFileName , '.out') asFilename contentsOfEntireFile.
+ Transcript showCR:output; endEntry.
+ Transcript showCR:'Failed linkCommand:'.
+ Transcript showCR:ld.
+ Transcript showCR:'ParserFlags are:'.
+ Transcript showCR:ParserFlags.
+ ].
+
+ #('.obj' '.out' '.tds' '.ilc' '.ild'
+ '.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix|
+ (baseFileName , eachSuffix) asFilename delete.
+ ].
+
+ ok ifFalse:[
+ LastError := output.
+ "/ ObjectFileLoadError raiseRequestErrorString:'link failed'.
+ ^ nil
+ ].
+ oFileName := (baseFileName , self sharedLibraryExtension) asFilename name.
+ ^ oFileName
].
"/ UNIX systems
@@ -2741,114 +2740,113 @@
fmt := ObjectFileLoader loadableBinaryObjectFormat.
(fmt == #elf
or:[ fmt == #macho ]) ifTrue:[
- "
- link it to a shared object with 'ld -shared'
- Currently, we support 32-bit objects only.
- "
- needSharedObject := true.
- ld := self linkCommand ? 'cc'.
- ldArg := self linkSharedArgs.
- ldArg isNil ifTrue:[
- "/ some default
- ExternalAddress pointerSize == 4 ifTrue:[
- ldArg := '-m32 -shared'.
- ] ifFalse:[
- ldArg := '--shared'.
- ]
- ]
+ "
+ link it to a shared object with 'ld -shared'
+ "
+ needSharedObject := true.
+ ld := self linkCommand ? 'cc'.
+ ldArg := self linkSharedArgs.
+ ldArg isNil ifTrue:[
+ "/ some default
+ ExternalAddress pointerSize == 4 ifTrue:[
+ ldArg := '-m32 -shared'.
+ ] ifFalse:[
+ ldArg := '--shared'.
+ ]
+ ]
].
osType = #irix ifTrue:[
- "
- link it to a shared object with 'ld -shared'
- "
- needSharedObject := true.
- ldArg := self linkSharedArgs ? '-shared'.
+ "
+ link it to a shared object with 'ld -shared'
+ "
+ needSharedObject := true.
+ ldArg := self linkSharedArgs ? '-shared'.
].
osType = #'sys5_4' ifTrue:[
- "
- link it to a shared object with 'ld -G'
- "
- needSharedObject := true.
- ldArg := self linkSharedArgs ? '-G'.
+ "
+ link it to a shared object with 'ld -G'
+ "
+ needSharedObject := true.
+ ldArg := self linkSharedArgs ? '-G'.
].
osType = #solaris ifTrue:[
- "
- link it to a shared object with 'ld -G -B dynamic'
- "
- needSharedObject := true.
- ldArg := self linkSharedArgs ? '-G -Bdynamic'.
+ "
+ link it to a shared object with 'ld -G -B dynamic'
+ "
+ needSharedObject := true.
+ ldArg := self linkSharedArgs ? '-G -Bdynamic'.
].
osType = #hpux ifTrue:[
- "
- link it to a shared object with 'ld -b -B immediate'
- "
- needSharedObject := true.
- ldArg := self linkSharedArgs ? '-b -B immediate'.
+ "
+ link it to a shared object with 'ld -b -B immediate'
+ "
+ needSharedObject := true.
+ ldArg := self linkSharedArgs ? '-b -B immediate'.
].
osType = #aix ifTrue:[
- self activityNotification:'create export file'.
-
- "/ create an exports file.
- expFileName := './' , baseFileName , '.exp'.
- [
- expFile := expFileName asFilename writeStream.
- expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
- expFile cr.
- expFile nextPutAll:'_' , baseFileName , '_Init'.
- expFile close.
- ] on:FileStream openErrorSignal do:[:ex| "do nothing"].
-
- 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 nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension).
+ expFile cr.
+ expFile nextPutAll:'_' , baseFileName , '_Init'.
+ expFile close.
+ ] on:FileStream openErrorSignal do:[:ex| "do nothing"].
+
+ 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 , ' ', (ParserFlags linkArgs ? '') ,
- ' -o ' , soFileName , ' ' , oFileName , ' ',
- ((ParserFlags searchedLibraries ? #()) asStringCollection asStringWith: $ ).
-
- (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[
- Transcript showCR:('linking with: ',ld).
- ].
- ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1').
-
- ok ifFalse:[
- output := 'errorOutput' asFilename contentsOfEntireFile.
- Transcript showCR:'linker error message:'.
- Transcript showCR:output.
- Transcript showCR:'linker command:'.
- Transcript showCR:ld; 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 , ' ', (ParserFlags linkArgs ? '') ,
+ ' -o ' , soFileName , ' ' , oFileName , ' ',
+ ((ParserFlags searchedLibraries ? #()) asStringCollection asStringWith: $ ).
+
+ (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[
+ Transcript showCR:('linking with: ',ld).
+ ].
+ ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1').
+
+ ok ifFalse:[
+ output := 'errorOutput' asFilename contentsOfEntireFile.
+ Transcript showCR:'linker error message:'.
+ Transcript showCR:output.
+ Transcript showCR:'linker command:'.
+ Transcript showCR:ld; endEntry.
+ ].
+
+ OperatingSystem removeFile:oFileName.
+ expFileName notNil ifTrue:[
+ OperatingSystem removeFile:expFileName
+ ].
+ ^ soFileName.
].
"
@@ -3065,26 +3063,26 @@
if (! __isArray(anInfoBuffer)
|| (__arraySize(anInfoBuffer) < 3)) {
- RETURN(nil);
+ RETURN(nil);
}
#ifdef GNU_DL
{
if (__isStringLike(pathName)) {
- if (dld_link(__stringVal(pathName))) {
- if (@global(Verbose) == true) {
- console_printf ("link file %s failed\n", __stringVal(pathName));
- }
- if (@global(ErrorPrinting) == true) {
- dld_perror("ObjectFileLoader - DLD error cant link");
- }
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING("DLD error");
- RETURN ( nil );
- }
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
- __STORE(anInfoBuffer, pathName);
- RETURN ( anInfoBuffer );
+ if (dld_link(__stringVal(pathName))) {
+ if (@global(Verbose) == true) {
+ console_printf ("link file %s failed\n", __stringVal(pathName));
+ }
+ if (@global(ErrorPrinting) == true) {
+ dld_perror("ObjectFileLoader - DLD error cant link");
+ }
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING("DLD error");
+ RETURN ( nil );
+ }
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
+ __STORE(anInfoBuffer, pathName);
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -3096,52 +3094,52 @@
int err;
if (__isStringLike(pathName)) {
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
- console_fflush(stderr);
- }
- //
- // LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also
- // in the directory of the loaded library, if an absolute path to
- // the library has been provided.
- // Note: this does not work for redirected library symbols, since they are
- // resolved ad symbol lookup time and not at library load time
- //
- handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
- console_fflush(stderr);
- }
- if (handle == NULL) {
- char *msg;
-
- err = GetLastError();
- if ((@global(ErrorPrinting) == true)
- || (@global(Verbose) == true)) {
- console_fprintf (stderr,
- "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n",
- __stringVal(pathName), err);
- }
- @global(LastError) = @symbol(loadError);;
- @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
- switch (err) {
- case ERROR_BAD_FORMAT:
- msg = "LoadLibrary error - bad format";
- default:
- msg = "LoadLibrary error";
- break;
- }
- @global(LinkErrorMessage) = __MKSTRING(msg);
- RETURN ( nil );
- }
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
+ console_fflush(stderr);
+ }
+ //
+ // LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also
+ // in the directory of the loaded library, if an absolute path to
+ // the library has been provided.
+ // Note: this does not work for redirected library symbols, since they are
+ // resolved ad symbol lookup time and not at library load time
+ //
+ handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
+ console_fflush(stderr);
+ }
+ if (handle == NULL) {
+ char *msg;
+
+ err = GetLastError();
+ if ((@global(ErrorPrinting) == true)
+ || (@global(Verbose) == true)) {
+ console_fprintf (stderr,
+ "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n",
+ __stringVal(pathName), err);
+ }
+ @global(LastError) = @symbol(loadError);;
+ @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
+ switch (err) {
+ case ERROR_BAD_FORMAT:
+ msg = "LoadLibrary error - bad format";
+ default:
+ msg = "LoadLibrary error";
+ break;
+ }
+ @global(LinkErrorMessage) = __MKSTRING(msg);
+ RETURN ( nil );
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFFL );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFFL );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
# endif
- RETURN ( anInfoBuffer );
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -3153,29 +3151,29 @@
int err;
if (__isStringLike(pathName)) {
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: loading : %s...\n", __stringVal(pathName));
- console_fflush(stderr);
- }
- handle = load_add_on(__stringVal(pathName));
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
- console_fflush(stderr);
- }
- if (handle == NULL) {
- char *msg;
-
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING("unknown error");
- RETURN ( nil );
- }
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [info]: loading : %s...\n", __stringVal(pathName));
+ console_fflush(stderr);
+ }
+ handle = load_add_on(__stringVal(pathName));
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [info]: handle: %x\n", handle);
+ console_fflush(stderr);
+ }
+ if (handle == NULL) {
+ char *msg;
+
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING("unknown error");
+ RETURN ( nil );
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
- RETURN ( anInfoBuffer );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ RETURN ( anInfoBuffer );
# endif
}
RETURN ( nil );
@@ -3189,21 +3187,21 @@
OBJ tmpName;
if (__isStringLike(pathName)) {
- if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
- if (@global(Verbose) == true) {
- console_printf ("link file %s failed\n", __stringVal(pathName));
- }
- @global(LinkErrorMessage) = __MKSTRING("dl_load error");
- RETURN ( nil );
- }
- /*
- * returns the name of the temporary ld-file
- * use that as handle ...
- */
- tmpName = __MKSTRING(ldname);
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
- __STORE(anInfoBuffer, tmpName);
- RETURN ( anInfoBuffer );
+ if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
+ if (@global(Verbose) == true) {
+ console_printf ("link file %s failed\n", __stringVal(pathName));
+ }
+ @global(LinkErrorMessage) = __MKSTRING("dl_load error");
+ RETURN ( nil );
+ }
+ /*
+ * returns the name of the temporary ld-file
+ * use that as handle ...
+ */
+ tmpName = __MKSTRING(ldname);
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
+ __STORE(anInfoBuffer, tmpName);
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -3216,53 +3214,53 @@
extern errno;
if (__isStringLike(pathName)) {
- objName = __stringVal(pathName);
-
- if (__isStringLike(@global(LibPath))) {
- libPath = __stringVal(@global(LibPath));
- } else {
- libPath = (char *)0;
- }
- if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
- if (@global(Verbose) == true) {
- char *messages[64];
- int i;
-
- console_fprintf (stderr,
- "ObjectFileLoader [info]: load file %s failed errno=%d\n",
- objName, errno);
-
- switch (errno) {
- case ENOEXEC:
- console_fprintf(stderr, " load messages:\n");
- loadquery(L_GETMESSAGES, messages, sizeof(messages));
- for (i=0; messages[i]; i++) {
- console_fprintf(stderr, " %s\n", messages[i]);
- }
- break;
- }
- } else {
- if (@global(ErrorPrinting) == true) {
- console_fprintf (stderr,
- "ObjectFileLoader [warning]: load file %s failed errno=%d\n",
- objName, errno);
- }
- }
- @global(LinkErrorMessage) = __MKSTRING("load error");
- RETURN ( nil );
- }
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle);
- }
+ objName = __stringVal(pathName);
+
+ if (__isStringLike(@global(LibPath))) {
+ libPath = __stringVal(@global(LibPath));
+ } else {
+ libPath = (char *)0;
+ }
+ if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
+ if (@global(Verbose) == true) {
+ char *messages[64];
+ int i;
+
+ console_fprintf (stderr,
+ "ObjectFileLoader [info]: load file %s failed errno=%d\n",
+ objName, errno);
+
+ switch (errno) {
+ case ENOEXEC:
+ console_fprintf(stderr, " load messages:\n");
+ loadquery(L_GETMESSAGES, messages, sizeof(messages));
+ for (i=0; messages[i]; i++) {
+ console_fprintf(stderr, " %s\n", messages[i]);
+ }
+ break;
+ }
+ } else {
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf (stderr,
+ "ObjectFileLoader [warning]: load file %s failed errno=%d\n",
+ objName, errno);
+ }
+ }
+ @global(LinkErrorMessage) = __MKSTRING("load error");
+ RETURN ( nil );
+ }
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle);
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
# endif
- RETURN (anInfoBuffer);
+ RETURN (anInfoBuffer);
}
RETURN ( nil );
}
@@ -3276,35 +3274,35 @@
char *errMsg;
if ((pathName == nil) || __isStringLike(pathName)) {
- INT lowHandle, hiHandle;
-
- handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW);
-
- if (! handle) {
- errMsg = (char *) dlerror();
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
- console_fprintf(stderr, " <%s>\n", errMsg);
- }
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING(errMsg);
- RETURN (nil);
- }
-
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
- }
+ INT lowHandle, hiHandle;
+
+ handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW);
+
+ if (! handle) {
+ errMsg = (char *) dlerror();
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
+ console_fprintf(stderr, " <%s>\n", errMsg);
+ }
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING(errMsg);
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
+ }
#if __POINTER_SIZE__ == 8
- lowHandle = (INT)handle & 0xFFFFFFFFL;
- hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
+ lowHandle = (INT)handle & 0xFFFFFFFFL;
+ hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
#else
- lowHandle = (INT)handle & 0xFFFF;
- hiHandle = ((INT)handle >> 16) & 0xFFFF;
+ lowHandle = (INT)handle & 0xFFFF;
+ hiHandle = ((INT)handle >> 16) & 0xFFFF;
#endif
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
- RETURN (anInfoBuffer);
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
+ RETURN (anInfoBuffer);
}
}
#endif
@@ -3317,49 +3315,49 @@
char *errMsg;
if (__isStringLike(pathName)) {
- handle = (void *)shl_load(__stringVal(pathName),
- BIND_IMMEDIATE, 0L /* address */);
-
- if (! handle) {
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName));
- }
- @global(LastError) = @symbol(linkError);
- switch (errno) {
- case ENOEXEC:
- errMsg = "not a shared library";
- break;
- case ENOSYM:
- errMsg = "undefined symbols";
- break;
- case ENOMEM:
- errMsg = "out of memory";
- break;
- case ENOENT:
- errMsg = "non existing library";
- break;
- case EACCES:
- errMsg = "permission denied";
- break;
- default:
- errMsg = "unspecified error";
- break;
- }
- @global(LinkErrorMessage) = __MKSTRING(errMsg);
- RETURN (nil);
- }
-
- if (@global(Verbose) == true) {
- console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
- }
+ handle = (void *)shl_load(__stringVal(pathName),
+ BIND_IMMEDIATE, 0L /* address */);
+
+ if (! handle) {
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName));
+ }
+ @global(LastError) = @symbol(linkError);
+ switch (errno) {
+ case ENOEXEC:
+ errMsg = "not a shared library";
+ break;
+ case ENOSYM:
+ errMsg = "undefined symbols";
+ break;
+ case ENOMEM:
+ errMsg = "out of memory";
+ break;
+ case ENOENT:
+ errMsg = "non existing library";
+ break;
+ case EACCES:
+ errMsg = "permission denied";
+ break;
+ default:
+ errMsg = "unspecified error";
+ break;
+ }
+ @global(LinkErrorMessage) = __MKSTRING(errMsg);
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true) {
+ console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF);
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
- RETURN (anInfoBuffer);
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF);
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
# endif
}
}
@@ -3371,28 +3369,28 @@
void *handle;
if ((pathName == nil) || __isStringLike(pathName)) {
- if (pathName == nil)
- handle = dlopen((char *)0, 1);
- else
- handle = dlopen(__stringVal(pathName), 1);
-
- if (! handle) {
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "dlopen %s error: <%s>\n",
- __stringVal(pathName), dlerror());
- }
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING("dlopen error");
- RETURN (nil);
- }
-
- if (@global(Verbose) == true) {
- console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
- }
-
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
- RETURN (anInfoBuffer);
+ if (pathName == nil)
+ handle = dlopen((char *)0, 1);
+ else
+ handle = dlopen(__stringVal(pathName), 1);
+
+ if (! handle) {
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "dlopen %s error: <%s>\n",
+ __stringVal(pathName), dlerror());
+ }
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING("dlopen error");
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true) {
+ console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
+ }
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
}
}
#endif
@@ -3404,29 +3402,29 @@
NXStream *errOut;
if (__isStringLike(pathName)) {
- files[0] = (char *) __stringVal(pathName);
- files[1] = (char *) 0;
- errOut = NXOpenFile(2, 2);
- result = rld_load(errOut,
- (struct mach_header **)0,
- files,
- (char *)0);
- NXClose(errOut);
- if (! result) {
- @global(LinkErrorMessage) = __MKSTRING("rld_load error");
- @global(LastError) = @symbol(linkError);
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
- }
- RETURN (nil);
- }
-
- if (@global(Verbose) == true)
- console_printf("rld_load %s ok\n", __stringVal(pathName));
-
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
- __STORE(anInfoBuffer, pathName);
- RETURN ( anInfoBuffer );
+ files[0] = (char *) __stringVal(pathName);
+ files[1] = (char *) 0;
+ errOut = NXOpenFile(2, 2);
+ result = rld_load(errOut,
+ (struct mach_header **)0,
+ files,
+ (char *)0);
+ NXClose(errOut);
+ if (! result) {
+ @global(LinkErrorMessage) = __MKSTRING("rld_load error");
+ @global(LastError) = @symbol(linkError);
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
+ }
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true)
+ console_printf("rld_load %s ok\n", __stringVal(pathName));
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
+ __STORE(anInfoBuffer, pathName);
+ RETURN ( anInfoBuffer );
}
}
#endif
@@ -3463,13 +3461,17 @@
#endif
#ifdef WIN_DL
- int val;
+ INT val;
HINSTANCE handle;
int err;
jmp_buf exitJmpBuf;
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
+# if __POINTER_SIZE__ == 8
+ val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
+# else
val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+# endif
handle = (HINSTANCE)(val);
if (setjmp(exitJmpBuf)) {
@@ -3746,52 +3748,52 @@
"Is there a shared library (.dll or .so) ?"
shLibName := aPackageId asPackageId libraryName asFilename
- withSuffix:self sharedLibrarySuffix.
+ withSuffix:self sharedLibrarySuffix.
exeDir := OperatingSystem pathOfSTXExecutable asFilename directory.
binaryClassLibraryFilename := exeDir / shLibName.
binaryClassLibraryFilename exists ifFalse:[
- exeDir baseName = 'bin' ifTrue:[
- binaryClassLibraryFilename := exeDir directory / 'lib' / shLibName.
- ].
- binaryClassLibraryFilename exists ifFalse:[
- binaryClassLibraryFilename := exeDir directory / 'plugin' / shLibName.
- binaryClassLibraryFilename exists ifFalse:[
+ exeDir baseName = 'bin' ifTrue:[
+ binaryClassLibraryFilename := exeDir directory / 'lib' / shLibName.
+ ].
+ binaryClassLibraryFilename exists ifFalse:[
+ binaryClassLibraryFilename := exeDir directory / 'plugin' / shLibName.
+ binaryClassLibraryFilename exists ifFalse:[
"/ binaryClassLibraryFilename := Filename currentDirectory / shLibName.
"/ binaryClassLibraryFilename exists ifFalse:[
- packageDirOrNil notNil ifTrue:[
- binaryClassLibraryFilename := packageDirOrNil / shLibName.
- binaryClassLibraryFilename exists ifFalse:[
- "/ mhmh - is this a good idea ? (temporary kludge)
- ExternalAddress pointerSize == 4 ifTrue:[
- binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName.
- binaryClassLibraryFilename exists ifFalse:[
- binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName.
- ]
- ] ifFalse:[
- binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName.
- ].
- ]
- ]
+ packageDirOrNil notNil ifTrue:[
+ binaryClassLibraryFilename := packageDirOrNil / shLibName.
+ binaryClassLibraryFilename exists ifFalse:[
+ "/ mhmh - is this a good idea ? (temporary kludge)
+ ExternalAddress pointerSize == 4 ifTrue:[
+ binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName.
+ binaryClassLibraryFilename exists ifFalse:[
+ binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName.
+ ]
+ ] ifFalse:[
+ binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName.
+ ].
+ ]
+ ]
"/ ].
- ].
- ].
- packageDirOrNil notNil ifTrue:[
- binaryClassLibraryFilename exists ifFalse:[
- "/ look in package directory
- binaryClassLibraryFilename := packageDirOrNil / shLibName.
- binaryClassLibraryFilename exists ifFalse:[
- ExternalAddress pointerSize == 4 ifTrue:[
- binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName.
- binaryClassLibraryFilename exists ifFalse:[
- binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName.
- ]
- ] ifFalse:[
- binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName.
- ].
- ].
- ].
- ].
+ ].
+ ].
+ packageDirOrNil notNil ifTrue:[
+ binaryClassLibraryFilename exists ifFalse:[
+ "/ look in package directory
+ binaryClassLibraryFilename := packageDirOrNil / shLibName.
+ binaryClassLibraryFilename exists ifFalse:[
+ ExternalAddress pointerSize == 4 ifTrue:[
+ binaryClassLibraryFilename := packageDirOrNil / 'objbc' / shLibName.
+ binaryClassLibraryFilename exists ifFalse:[
+ binaryClassLibraryFilename := packageDirOrNil / 'objvc' / shLibName.
+ ]
+ ] ifFalse:[
+ binaryClassLibraryFilename := packageDirOrNil / 'objmingw' / shLibName.
+ ].
+ ].
+ ].
+ ].
].
^ binaryClassLibraryFilename
!
@@ -4206,112 +4208,112 @@
"
need 4 passes to init: 0: let module register itself & create its pools/globals
- 0b check if modules superclasses are all loaded
- 1: let it get var-refs to other pools/globals
- 2: let it install install class, methods and literals
- 3: let it send #initialize to its class object
+ 0b check if modules superclasses are all loaded
+ 1: let it get var-refs to other pools/globals
+ 2: let it install install class, methods and literals
+ 3: let it send #initialize to its class object
"
Verbose ifTrue:[
- 'start' errorPrintCR
+ 'start' errorPrintCR
].
[
- stillTrying := false.
-
- "/
- "/ let it register itself
- "/ and define its globals
- "/
- Verbose ifTrue:[
- 'phase 0 (module registration) ...' errorPrintCR
- ].
- self
- saveCallInitFunctionAt:initAddr
- in:nil
- specialInit:true
- forceOld:true
- interruptable:false
- argument:0
- identifyAs:handle
- returnsObject:false.
-
- "/
- "/ check if superclasses are present
- "/
- info := self loadStatusFor:className.
- status := info at:1.
- badClassName := info at:2.
-
- Verbose ifTrue:[
- '... info is ' errorPrint. info errorPrintCR
- ].
-
- (status ~~ #ok) ifTrue:[
- (status == #missingClass) ifTrue:[
- ('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR.
- ^ info
- ].
- (status == #versionMismatch) ifTrue:[
- ('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR.
- ^ info
- ].
- (status == #unregisteredSuperclass) ifTrue:[
- ('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR.
- ^ info
- ].
- (status == #tryAgain) ifTrue:[
- "/ tryAgain:
- "/ must retry after initialization, to initialize
- "/ sub-subclasses of autoloaded classes
- "/ (sigh - class objects are created in phase 3,
- "/ so we must first complete the initialization cycle,
- "/ then do all again, for remaining modules)
- stillTrying := true.
- 'ObjectFileLoader [info]: retry registration of: ' infoPrint.
- (className ? 'a classLib') infoPrint. ' after init' infoPrintCR.
- ] ifFalse:[
- 'ObjectFileLoader [error]: load failed: ' infoPrint. className infoPrintCR.
- ^ Array with:#loadFailed with:nil
- ].
- ].
-
- Smalltalk flushCachedClasses.
- Class flushSubclassInfo.
- "/
- "/ remaining initialization
- "/
-
- "/ module exports: declare module-globals & symbols ...
- Verbose ifTrue:[
- 'phase 1 (resolve globals) ...' errorPrintCR
- ].
- self moduleInit:1 forceOld:true interruptable:false.
-
- "/ module-imports: resolve globals ...
- "/ create methods & install ...
- Verbose ifTrue:[
- 'phase 2 (create objects) ...' errorPrintCR
- ].
- self moduleInit:2 forceOld:true interruptable:false.
-
- Verbose ifTrue:[
- 'stillTrying is ' errorPrint. stillTrying errorPrintCR
- ].
+ stillTrying := false.
+
+ "/
+ "/ let it register itself
+ "/ and define its globals
+ "/
+ Verbose ifTrue:[
+ 'phase 0 (module registration) ...' errorPrintCR
+ ].
+ self
+ saveCallInitFunctionAt:initAddr
+ in:nil
+ specialInit:true
+ forceOld:true
+ interruptable:false
+ argument:0
+ identifyAs:handle
+ returnsObject:false.
+
+ "/
+ "/ check if superclasses are present
+ "/
+ info := self loadStatusFor:className.
+ status := info at:1.
+ badClassName := info at:2.
+
+ Verbose ifTrue:[
+ '... info is ' errorPrint. info errorPrintCR
+ ].
+
+ (status ~~ #ok) ifTrue:[
+ (status == #missingClass) ifTrue:[
+ ('ObjectFileLoader [error]: load failed - missing class: ' , badClassName) infoPrintCR.
+ ^ info
+ ].
+ (status == #versionMismatch) ifTrue:[
+ ('ObjectFileLoader [error]: load failed - version mismatch: ' , badClassName) infoPrintCR.
+ ^ info
+ ].
+ (status == #unregisteredSuperclass) ifTrue:[
+ ('ObjectFileLoader [error]: load failed - unregistered: ' , badClassName) infoPrintCR.
+ ^ info
+ ].
+ (status == #tryAgain) ifTrue:[
+ "/ tryAgain:
+ "/ must retry after initialization, to initialize
+ "/ sub-subclasses of autoloaded classes
+ "/ (sigh - class objects are created in phase 3,
+ "/ so we must first complete the initialization cycle,
+ "/ then do all again, for remaining modules)
+ stillTrying := true.
+ 'ObjectFileLoader [info]: retry registration of: ' infoPrint.
+ (className ? 'a classLib') infoPrint. ' after init' infoPrintCR.
+ ] ifFalse:[
+ 'ObjectFileLoader [error]: load failed: ' infoPrint. className infoPrintCR.
+ ^ Array with:#loadFailed with:nil
+ ].
+ ].
+
+ Smalltalk flushCachedClasses.
+ Class flushSubclassInfo.
+ "/
+ "/ remaining initialization
+ "/
+
+ "/ module exports: declare module-globals & symbols ...
+ Verbose ifTrue:[
+ 'phase 1 (resolve globals) ...' errorPrintCR
+ ].
+ self moduleInit:1 forceOld:true interruptable:false.
+
+ "/ module-imports: resolve globals ...
+ "/ create methods & install ...
+ Verbose ifTrue:[
+ 'phase 2 (create objects) ...' errorPrintCR
+ ].
+ self moduleInit:2 forceOld:true interruptable:false.
+
+ Verbose ifTrue:[
+ 'stillTrying is ' errorPrint. stillTrying errorPrintCR
+ ].
] doWhile:[stillTrying].
Verbose ifTrue:[
- 'end' errorPrintCR
+ 'end' errorPrintCR
].
ObjectMemory flushCaches.
invokeInitializeMethods ifTrue:[
- Verbose ifTrue:[
- 'phase 3 (send #initialize) ...' errorPrintCR
- ].
- "/ initialize ...
- self moduleInit:3 forceOld:false interruptable:true.
+ Verbose ifTrue:[
+ 'phase 3 (send #initialize) ...' errorPrintCR
+ ].
+ "/ initialize ...
+ self moduleInit:3 forceOld:false interruptable:true.
].
"/ ask objectMemory for the classes we have just loaded
@@ -4320,25 +4322,25 @@
infoCollection := ObjectMemory binaryModuleInfo.
info := infoCollection at:handle moduleID ifAbsent:nil.
info isNil ifTrue:[
- "/ mhmh registration failed -
- 'ObjectFileLoader [error]: registration failed: ' infoPrint.
- (className ? 'some classLib') infoPrintCR.
- ^ Array with:#registrationFailed with:nil
+ "/ mhmh registration failed -
+ 'ObjectFileLoader [error]: registration failed: ' infoPrint.
+ (className ? 'some classLib') infoPrintCR.
+ ^ Array with:#registrationFailed with:nil
].
classNames := info classNames.
classNames notEmptyOrNil ifTrue:[
- classes := OrderedCollection new:classNames size.
- classNames do:[:eachClassName | |class|
- class := Smalltalk classNamed:eachClassName.
- class notNil ifTrue:[
- classes add:class.
- ].
- ].
+ classes := OrderedCollection new:classNames size.
+ classNames do:[:eachClassName | |class|
+ class := Smalltalk classNamed:eachClassName.
+ class notNil ifTrue:[
+ classes add:class.
+ ].
+ ].
].
classes notEmptyOrNil ifTrue:[
- classes := classes asArray.
- classes := classes , (classes collect:[:aClass | aClass class]).
+ classes := classes asArray.
+ classes := classes , (classes collect:[:aClass | aClass class]).
].
handle classes:classes.
@@ -4574,11 +4576,11 @@
!ObjectFileLoader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.358 2015-03-05 12:15:04 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.358 2015-03-05 12:15:04 cg Exp $'
+ ^ '$Header$'
! !