ObjectFileLoader.st
changeset 97 3b0d380771e9
parent 96 ae3b3d960476
child 98 ccc7f9389a8e
--- a/ObjectFileLoader.st	Tue Jun 27 04:17:58 1995 +0200
+++ b/ObjectFileLoader.st	Mon Jul 03 04:38:59 1995 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
 	     All Rights Reserved
 
-$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.26 1995-06-27 02:17:26 claus Exp $
+$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.27 1995-07-03 02:38:34 claus Exp $
 '!
 
 !ObjectFileLoader class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.26 1995-06-27 02:17:26 claus Exp $
+$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.27 1995-07-03 02:38:34 claus Exp $
 "
 !
 
@@ -104,6 +104,11 @@
 # define HAS_DL
 #endif
 
+#ifdef aix
+# define AIX_DL
+# define HAS_DL
+#endif
+
 /*
  * but GNU_DL overwrites this - its better
  */
@@ -173,6 +178,9 @@
 #  endif
 #endif
 
+#ifdef AIX_DL
+# include <nlist.h>
+#endif
 %}
 ! !
 
@@ -1115,12 +1123,12 @@
     if (__isString(pathName)) {
 	if (__isArray(aBuffer)
 	 && (_arraySize(aBuffer) == 2)) {;
-            if ( (handle = load(_stringVal(pathName), 0, 0)) == 0 ) {
-                if (ObjectFileLoader_Verbose == true) {
-                    printf ("link file %s failed\n", _stringVal(pathName));
-                }
-                RETURN ( nil );
-            }
+	    if ( (handle = load(_stringVal(pathName), 0, 0)) == 0 ) {
+		if (ObjectFileLoader_Verbose == true) {
+		    printf ("link file %s failed\n", _stringVal(pathName));
+		}
+		RETURN ( nil );
+	    }
 	    if (ObjectFileLoader_Verbose == true)
 		printf("load %s handle = %x\n", _stringVal(pathName), handle);
 
@@ -1289,19 +1297,19 @@
 #endif
 
 #ifdef AIX_DL
-    int *handle;
+    int *h;
     int val;
 
     if (__bothSmallInteger(low, hi)) {
-        val = (_intVal(hi) << 16) + _intVal(low);
-        handle = (int *)(val);
-        if (ObjectFileLoader_Verbose == true)
-            printf("unload handle = %x\n", h);
-        if (unload(h) != 0) {
-            fprintf(stderr, "unload failed with:<%s>\n", dlerror());
-            RETURN (false);
-        }
-        RETURN (true);
+	val = (_intVal(hi) << 16) + _intVal(low);
+	h = (int *)(val);
+	if (ObjectFileLoader_Verbose == true)
+	    printf("unload handle = %x\n", h);
+	if ( unload(h) != 0) {
+	    fprintf(stderr, "unload failed\n");
+	    RETURN (false);
+	}
+	RETURN (true);
     }
 #endif
 
@@ -1515,33 +1523,35 @@
     void *h;
     void *addr;
     int val;
-    n_list nl[2];
+    struct nlist nl[2];
 
     if (__isArray(handle)) {
-        low = _ArrayInstPtr(handle)->a_element[0];
-        hi = _ArrayInstPtr(handle)->a_element[1];
-        fileName = _ArrayInstPtr(handle)->a_element[2];
+	low = _ArrayInstPtr(handle)->a_element[0];
+	hi = _ArrayInstPtr(handle)->a_element[1];
+	fileName = _ArrayInstPtr(handle)->a_element[2];
     } else {
-        low = hi = nil;
+	low = hi = nil;
     }
 
     if (__bothSmallInteger(low, hi)
      && __isString(fileName)) {
-        val = (_intVal(hi) << 16) + _intVal(low);
-        h = (void *)(val);
-        if (__isString(aString)) {
-            if (ObjectFileLoader_Verbose == true)
-                printf("get sym <%s> handle = %x file = %s\n", 
+	val = (_intVal(hi) << 16) + _intVal(low);
+	h = (void *)(val);
+	if (__isString(aString)) {
+	    if (ObjectFileLoader_Verbose == true)
+		printf("get sym <%s> handle = %x file = %s\n", 
 			_stringVal(aString), h, _stringVal(fileName));
 
-	    nl[0]._n._n_name = _stringVal(aString);
-	    nl[1]._n._n_name = "";
+	    nl[0].n_name = _stringVal(aString);
+	    nl[1].n_name = "";
 
 	    if (nlist(_stringVal(fileName), &nl) == -1) {
-                if (ObjectFileLoader_Verbose == true)
-                    printf("nlist error\n");
+		if (ObjectFileLoader_Verbose == true)
+		    printf("nlist error\n");
 	    } else {
-		.....
+		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);
+		printf("not yet implemented\n");
 	    }
 	}
     }
@@ -1691,6 +1701,7 @@
 performModuleInitAt:initAddr
     "
      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
@@ -1698,6 +1709,10 @@
 
     |status badClassName|
 
+    "/
+    "/ let it register itself
+    "/ and define its globals
+    "/
     Verbose ifTrue:[
 	Transcript showCr:'phase 0 ...'
     ].
@@ -1707,6 +1722,9 @@
 	 interruptable:false
 	 argument:0.
 
+    "/
+    "/ check if superclasses are present
+    "/
     (status := self loadStatus) == 0 ifFalse:[
 	badClassName := self classNameThatFailed.
 	status == -1 ifTrue:[
@@ -1723,6 +1741,9 @@
 	^ Array with:#loadFailed
     ].
 
+    "/
+    "/ remaining initialization
+    "/
     Verbose ifTrue:[
 	Transcript showCr:'phase 1 ...'
     ].