ObjectFileLoader.st
changeset 589 ee0cc3ae769a
parent 587 5250b6d10925
child 590 7c158fe9b754
--- a/ObjectFileLoader.st	Thu Jul 24 10:51:05 1997 +0200
+++ b/ObjectFileLoader.st	Thu Jul 24 17:31:12 1997 +0200
@@ -937,6 +937,8 @@
 
     SearchedLibraries notNil ifTrue:[
         (self hasUndefinedSymbolsIn:handle) ifTrue:[
+    	    self initializeLoader.
+
             SearchedLibraries do:[:libName |
                 (self hasUndefinedSymbolsIn:handle) ifTrue:[
                     Transcript showCR:'   ... trying ' , libName , ' to resolve undefined symbols ...'.
@@ -2128,6 +2130,8 @@
         ].
     ].
 
+    self initializeLoader.
+
     "/
     "/ the 1st two entries are system dependent;
     "/ entry 3 is the pathName
@@ -2233,6 +2237,36 @@
     "Modified: 10.1.1997 / 17:58:23 / cg"
 !
 
+initializeLoader
+    "initialize dynamic loader if required"
+ 
+    |stxName stxPathName|
+
+    stxPathName := OperatingSystem pathOfSTXExecutable.
+%{
+#ifdef GNU_DL
+  {
+    static alreadyInitialized = 0;
+    extern dld_ignore_redefinitions;
+
+    if (! alreadyInitialized) {
+	alreadyInitialized = 1;
+
+	if (ObjectFileLoader_Verbose == true) {
+	    printf ("dld_init(%s)\n", __stringVal(stxPathName));
+	}
+	/*
+	 * dld requires the running executables name,
+	 * to resolve symbols.
+	 */
+	(void) dld_init (__stringVal(stxPathName));
+	dld_ignore_redefinitions = 1;
+    }
+  }
+#endif
+%}.
+!
+
 primLoadDynamicObject:pathName into:anInfoBuffer
     "load an object-file (map into my address space).
      Return an OS-handle (whatever that is) - where some space
@@ -2251,16 +2285,6 @@
 
 #ifdef GNU_DL
   {
-    static firstCall = 1;
-    extern char *__myName__;
-    extern dld_ignore_redefinitions;
-
-    if (firstCall) {
-	firstCall = 0;
-	(void) dld_init (__myName__);
-	dld_ignore_redefinitions = 1;
-    }
-
     if (__isString(pathName)) {
 	if (dld_link(__stringVal(pathName))) {
 	    if (ObjectFileLoader_Verbose == true) {
@@ -2334,7 +2358,6 @@
 
 #ifdef AIX_DL
   {
-    extern char *__myName__;
     char *objName, *libPath;
     int *handle;
     extern errno;
@@ -3225,6 +3248,6 @@
 !ObjectFileLoader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.143 1997-07-22 16:17:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.144 1997-07-24 15:31:12 cg Exp $'
 ! !
 ObjectFileLoader initialize!