--- a/ObjFLoader.st Mon Aug 22 14:48:13 1994 +0200
+++ b/ObjFLoader.st Mon Aug 22 14:48:28 1994 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.8 1994-08-11 21:41:26 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.9 1994-08-22 12:48:28 claus Exp $
'!
%{
@@ -118,7 +118,7 @@
version
"
-$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.8 1994-08-11 21:41:26 claus Exp $
+$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.9 1994-08-22 12:48:28 claus Exp $
"
!
@@ -651,52 +651,76 @@
loadObjectFile:aFileName
"load an object file (.o-file) into the image;
- the class name is not needed (multiple definitions may be in the file)."
+ the class name is not needed (multiple definitions may be in the file).
+ Return false on error, true if ok."
|handle initAddr symName className newClass list initNames|
handle := self openDynamicObject:aFileName.
handle isNil ifTrue:[
Transcript showCr:('openDynamic: ',aFileName,' failed.').
- ^ nil
+ ^ false
].
className := OperatingSystem baseNameOf:aFileName.
(className endsWith:'.o') ifTrue:[
className := className copyTo:(className size - 2)
+ ] ifFalse:[
+ (className endsWith:'.obj') ifTrue:[
+ className := className copyTo:(className size - 4)
+ ] ifFalse:[
+ (className endsWith:'.so') ifTrue:[
+ className := className copyTo:(className size - 3)
+ ]
+ ]
].
"
- look for init-function(s)
+ look for explicit init function
"
- initNames := self namesMatching:'*_Init' segment:'[tT]' in:aFileName.
- initNames do:[:aName |
- initAddr := self getFunction:aName from:handle.
- initAddr isNil ifTrue:[
- (aName startsWith:'_') ifTrue:[
- initAddr := self getFunction:(aName copyFrom:2) from:handle.
+ initAddr := self getFunction:(className , '_Init') from:handle.
+ initAddr isNil ifTrue:[
+ initAddr := self getFunction:('_' , className , '_Init') from:handle.
+ ].
+ initAddr notNil ifTrue:[
+ self callInitFunctionAt:initAddr.
+ ] ifFalse:[
+ "
+ look for init-function(s)
+ "
+ initNames := self namesMatching:'*_Init' segment:'[tT]' in:aFileName.
+ 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).
- ^ nil
+ initAddr isNil ifTrue:[
+ Transcript showCr:('no symbol: ',aName,' in ',aFileName).
+ ^ nil
+ ].
+ Verbose ifTrue:[
+ Transcript showCr:'calling init at:' , (initAddr printStringRadix:16)
+ ].
+ self callInitFunctionAt:initAddr.
].
- Verbose ifTrue:[
- Transcript showCr:'calling init at:' , (initAddr printStringRadix:16)
- ].
- self callInitFunctionAt:initAddr.
].
- (Symbol hasInterned:className) ifTrue:[
- newClass := Smalltalk at:className asSymbol ifAbsent:[nil].
- newClass notNil ifTrue:[
- newClass initialize.
- "force cache flush"
- Smalltalk at:className asSymbol put:newClass.
- Smalltalk changed.
- ].
- ].
- ^ newClass
+"/ (Symbol hasInterned:className) ifTrue:[
+"/ newClass := Smalltalk at:className asSymbol ifAbsent:[nil].
+"/ newClass notNil ifTrue:[
+"/ newClass initialize.
+"/ "force cache flush"
+"/ Smalltalk at:className asSymbol put:newClass.
+"/ ].
+"/ ].
+
+ "
+ really dont know, if it has changed ...
+ "
+ Smalltalk changed.
+ ^ true
!
loadCPlusPlusObjectFile:aFileName
@@ -1324,19 +1348,23 @@
callInitFunctionAt:initAddr
"
- need 3 passes to init: 1: create my pools
- 2: get var-refs to other pools
- 3: install class, methods and literals
+ need 4 passes to init: 0: create my pools
+ 1: get var-refs to other pools
+ 2: install class, methods and literals
+ 3: send #initialize to class
"
self callFunctionAt:initAddr forceOld:true arg:0.
self callFunctionAt:initAddr forceOld:true arg:1.
self callFunctionAt:initAddr forceOld:true arg:2.
+ self callFunctionAt:initAddr forceOld:false arg:3.
!
callFunctionAt:address forceOld:forceOld arg:argument
"call a function at address - this is very dangerous.
This is needed to call the classes init-function after loading in a
- class-object file. Dont use in your programs."
+ class-object file. ForceOld (if true) will have the memory manager
+ allocate things in oldSpace instead of newSpace.
+ DANGER: Internal. Dont use in your programs."
|low hi lowAddr hiAddr|
@@ -1365,11 +1393,11 @@
_immediateInterrupt = 1;
if (forceOld == true) {
- prevSpace = allocForceSpace(OLDSPACE);
- (*addr)(arg);
- allocForceSpace(prevSpace);
+ prevSpace = __allocForceSpace(OLDSPACE);
+ (*addr)(arg COMMA_CON);
+ __allocForceSpace(prevSpace);
} else {
- (*addr)(arg);
+ (*addr)(arg COMMA_CON);
}
_immediateInterrupt = savInt;