--- a/ObjectFileLoader.st Mon Jul 05 17:15:54 2010 +0200
+++ b/ObjectFileLoader.st Tue Jul 06 15:56:32 2010 +0200
@@ -2869,26 +2869,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 );
}
@@ -2900,40 +2900,47 @@
int err;
if (__isStringLike(pathName)) {
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
- console_fflush(stderr);
- }
- handle = LoadLibrary(__stringVal(pathName));
- 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 );
- }
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
- RETURN ( anInfoBuffer );
+ 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 );
+ }
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -2945,25 +2952,25 @@
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 );
- }
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
- RETURN ( anInfoBuffer );
+ 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 );
+ }
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -2976,21 +2983,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 );
}
@@ -3003,48 +3010,48 @@
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);
- }
-
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
- RETURN (anInfoBuffer);
+ 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);
+ }
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
}
RETURN ( nil );
}
@@ -3058,35 +3065,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 = %x\n", __stringVal(pathName), 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 = %x\n", __stringVal(pathName), 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
@@ -3099,45 +3106,45 @@
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 = %x\n", __stringVal(pathName), handle);
- }
-
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF);
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
- RETURN (anInfoBuffer);
+ 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 = %x\n", __stringVal(pathName), handle);
+ }
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF);
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
}
}
#endif
@@ -3148,28 +3155,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 = %x\n", __stringVal(pathName), 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 = %x\n", __stringVal(pathName), handle);
+ }
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
}
}
#endif
@@ -3181,29 +3188,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
@@ -4135,11 +4142,11 @@
!ObjectFileLoader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.283 2010-05-11 10:03:28 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.284 2010-07-06 13:56:32 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.283 2010-05-11 10:03:28 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.284 2010-07-06 13:56:32 stefan Exp $'
! !
ObjectFileLoader initialize!