--- a/ObjectFileLoader.st Thu Nov 05 15:52:36 2009 +0100
+++ b/ObjectFileLoader.st Thu Nov 05 17:25:27 2009 +0100
@@ -1585,48 +1585,48 @@
unsigned long addr;
char *name;
- if (__isString(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");
- }
- }
- }
+ 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");
+ }
+ }
+ }
}
}
#endif /* GNU_DL */
@@ -1640,24 +1640,24 @@
HMODULE handle;
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
- handle = (HMODULE)(val);
- if (__isString(aString)) {
- if (@global(Verbose) == true)
- console_printf("get sym <%s> handle = %x\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 = %x\n", __stringVal(aString), addr);
- }
- address = __MKUINT( (int)addr );
- } else {
- if (@global(Verbose) == true) {
- console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
- }
- }
- }
+ val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ handle = (HMODULE)(val);
+ if (__isStringLike(aString)) {
+ if (@global(Verbose) == true)
+ console_printf("get sym <%s> handle = %x\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 = %x\n", __stringVal(aString), addr);
+ }
+ address = __MKUINT( (int)addr );
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("GetProcAddr %s error: %x\n", __stringVal(aString), GetLastError());
+ }
+ }
+ }
}
}
#endif
@@ -1670,26 +1670,26 @@
void *handle;
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
- handle = (void *)(val);
-
- if (__isString(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));
- }
- }
- }
+ val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ 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
@@ -1700,21 +1700,21 @@
void *addr;
INT val;
- if (__isString(aString)) {
- if (__isString(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(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
@@ -1729,27 +1729,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 (__isString(aString)) {
- if (@global(Verbose) == true) {
- console_printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
- }
- addr = dlsym(h, (char *) __stringVal(aString));
- if (addr) {
- if (@global(Verbose) == true) {
- console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), 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 = %x\n", __stringVal(aString), h);
+ }
+ addr = dlsym(h, (char *) __stringVal(aString));
+ if (addr) {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s ok; addr = %x\n", __stringVal(aString), addr);
+ }
+ address = __MKUINT( (INT)addr );
+ } else {
+ if (@global(Verbose) == true) {
+ console_printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
+ }
+ }
+ }
}
}
#endif
@@ -1762,24 +1762,24 @@
OBJ low = sysHandle1, hi = sysHandle2;
if (__bothSmallInteger(low, hi)) {
- val = (_intVal(hi) << 16) + _intVal(low);
- h = (void *)(val);
- if (__isString(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 );
- }
- }
+ 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);
+ }
+ 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
@@ -1794,76 +1794,76 @@
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)
- && __isString(aString) && __isString(pathName)) {
- val = (__intVal(hi) << 16) + __intVal(low);
- h = (void *)(val);
-
- if (@global(Verbose) == true) {
- console_printf("get sym <%s> handle = %x path= %s\n",
- __stringVal(aString), h, __stringVal(pathName));
- }
+ && __isStringLike(aString) && __isStringLike(pathName)) {
+ val = (__intVal(hi) << 16) + __intVal(low);
+ 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 /* dont USE_ENTRY */
}
}
@@ -1878,24 +1878,24 @@
OBJ low = sysHandle1, hi = sysHandle2;
if (__bothSmallInteger(low, hi)) {
- val = (_intVal(hi) << 16) + _intVal(low);
- h = (void *)(val);
- if (__isString(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
@@ -1907,21 +1907,21 @@
long result;
NXStream *errOut;
- if (__isString(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 (__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 );
+ }
}
}
#endif
@@ -2842,26 +2842,26 @@
if (! __isArray(anInfoBuffer)
|| (__arraySize(anInfoBuffer) < 3)) {
- RETURN(nil);
+ RETURN(nil);
}
#ifdef GNU_DL
{
- if (__isString(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 (__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 );
}
RETURN ( nil );
}
@@ -2872,41 +2872,41 @@
HINSTANCE handle;
int err;
- if (__isString(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 (__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 );
}
RETURN ( nil );
}
@@ -2917,26 +2917,26 @@
void *handle;
int err;
- if (__isString(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 (__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 );
}
RETURN ( nil );
}
@@ -2948,22 +2948,22 @@
char *ldname;
OBJ tmpName;
- if (__isString(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 (__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 );
}
RETURN ( nil );
}
@@ -2975,49 +2975,49 @@
int *handle;
extern errno;
- if (__isString(pathName)) {
- objName = __stringVal(pathName);
-
- if (__isString(@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);
+ 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);
}
RETURN ( nil );
}
@@ -3030,36 +3030,36 @@
char *nm;
char *errMsg;
- if ((pathName == nil) || __isString(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);
- }
+ 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);
+ }
#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
@@ -3071,46 +3071,46 @@
char *nm;
char *errMsg;
- if (__isString(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);
+ 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);
}
}
#endif
@@ -3120,29 +3120,29 @@
{
void *handle;
- if ((pathName == nil) || __isString(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) || __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);
}
}
#endif
@@ -3153,30 +3153,30 @@
char *files[2];
NXStream *errOut;
- if (__isString(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 );
+ 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 );
}
}
#endif
@@ -3199,15 +3199,15 @@
%{ /* CALLSUNLIMITEDSTACK(noWIN32) */
#ifdef GNU_DL
- if (__isString(sysHandle1)) {
- if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) {
- if (@global(Verbose) == true) {
- console_printf ("unlink file %s failed\n", __stringVal(sysHandle1));
- dld_perror("cant unlink");
- }
- RETURN (false);
- }
- RETURN (true);
+ if (__isStringLike(sysHandle1)) {
+ if (dld_unlink_by_file(__stringVal(sysHandle1), 1)) {
+ if (@global(Verbose) == true) {
+ console_printf ("unlink file %s failed\n", __stringVal(sysHandle1));
+ dld_perror("cant unlink");
+ }
+ RETURN (false);
+ }
+ RETURN (true);
}
RETURN (false);
#endif
@@ -3219,27 +3219,27 @@
jmp_buf exitJmpBuf;
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
- handle = (HINSTANCE)(val);
+ val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ handle = (HINSTANCE)(val);
if (setjmp(exitJmpBuf)) {
- __setAtExitLongJmp(exitJmpBuf);
- if (FreeLibrary(handle) != TRUE) {
- __setAtExitLongJmp(0);
- err = GetLastError();
- if (@global(Verbose) == true) {
- console_fprintf (stderr,
- "ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n",
- __stringVal(sysHandle1), err);
- }
- @global(LastErrorNumber) = __WIN32_ERR(err);
- RETURN (false);
- }
+ __setAtExitLongJmp(exitJmpBuf);
+ if (FreeLibrary(handle) != TRUE) {
+ __setAtExitLongJmp(0);
+ err = GetLastError();
+ if (@global(Verbose) == true) {
+ console_fprintf (stderr,
+ "ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n",
+ __stringVal(sysHandle1), err);
+ }
+ @global(LastErrorNumber) = __WIN32_ERR(err);
+ RETURN (false);
+ }
} else {
- __setAtExitLongJmp(0);
- console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
+ __setAtExitLongJmp(0);
+ console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
}
- RETURN (true);
+ RETURN (true);
}
RETURN (false);
#endif
@@ -3251,22 +3251,22 @@
jmp_buf exitJmpBuf;
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
- handle = (HINSTANCE)(val);
-
- if (setjmp(exitJmpBuf)) {
- __setAtExitLongJmp(exitJmpBuf);
- ok = unload_add_on((image_id) handle);
- __setAtExitLongJmp(0);
- if (ok != 0) {
- @global(LastErrorNumber) = __MKSMALLINT(ok);
- RETURN (false);
- }
- } else {
- __setAtExitLongJmp(0);
- console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
- }
- RETURN (true);
+ val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ handle = (HINSTANCE)(val);
+
+ if (setjmp(exitJmpBuf)) {
+ __setAtExitLongJmp(exitJmpBuf);
+ ok = unload_add_on((image_id) handle);
+ __setAtExitLongJmp(0);
+ if (ok != 0) {
+ @global(LastErrorNumber) = __MKSMALLINT(ok);
+ RETURN (false);
+ }
+ } else {
+ __setAtExitLongJmp(0);
+ console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
+ }
+ RETURN (true);
}
RETURN (false);
#endif
@@ -3279,18 +3279,18 @@
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 (@global(Verbose) == true)
- console_printf("close handle = %x\n", h);
- if (dlclose(h) != 0) {
- console_fprintf(stderr, "dlclose failed with:<%s>\n", dlerror());
- RETURN (false);
- }
- RETURN (true);
+ h = (void *)(val);
+ if (@global(Verbose) == true)
+ console_printf("close handle = %x\n", h);
+ if (dlclose(h) != 0) {
+ console_fprintf(stderr, "dlclose failed with:<%s>\n", dlerror());
+ RETURN (false);
+ }
+ RETURN (true);
}
}
#endif
@@ -3302,13 +3302,13 @@
OBJ low = sysHandle1, hi = sysHandle2;
if (__bothSmallInteger(low, hi)) {
- val = (_intVal(hi) << 16) + _intVal(low);
- h = (void *)(val);
- if (@global(Verbose) == true) {
- console_printf("close handle = %x\n", h);
- }
- dlclose(h);
- RETURN (true);
+ val = (_intVal(hi) << 16) + _intVal(low);
+ h = (void *)(val);
+ if (@global(Verbose) == true) {
+ console_printf("close handle = %x\n", h);
+ }
+ dlclose(h);
+ RETURN (true);
}
}
#endif
@@ -3320,13 +3320,13 @@
OBJ low = sysHandle1, hi = sysHandle2;
if (__bothSmallInteger(low, hi)) {
- val = (_intVal(hi) << 16) + _intVal(low);
- h = (void *)(val);
- if (@global(Verbose) == true) {
- console_printf("unload handle = %x\n", h);
- }
- shl_unload(h);
- RETURN (true);
+ val = (_intVal(hi) << 16) + _intVal(low);
+ h = (void *)(val);
+ if (@global(Verbose) == true) {
+ console_printf("unload handle = %x\n", h);
+ }
+ shl_unload(h);
+ RETURN (true);
}
}
#endif
@@ -3338,16 +3338,16 @@
OBJ low = sysHandle1, hi = sysHandle2;
if (__bothSmallInteger(low, hi)) {
- val = (_intVal(hi) << 16) + _intVal(low);
- h = (int *)(val);
- if (@global(Verbose) == true) {
- console_printf("unload handle = %x\n", h);
- }
- if ( unload(h) != 0) {
- console_fprintf(stderr, "unload failed\n");
- RETURN (false);
- }
- RETURN (true);
+ val = (_intVal(hi) << 16) + _intVal(low);
+ h = (int *)(val);
+ if (@global(Verbose) == true) {
+ console_printf("unload handle = %x\n", h);
+ }
+ if ( unload(h) != 0) {
+ console_fprintf(stderr, "unload failed\n");
+ RETURN (false);
+ }
+ RETURN (true);
}
}
#endif
@@ -4091,7 +4091,11 @@
!ObjectFileLoader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.273 2009-06-12 12:39:49 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.274 2009-11-05 16:25:27 stefan Exp $'
+!
+
+version_CVS
+ ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.274 2009-11-05 16:25:27 stefan Exp $'
! !
ObjectFileLoader initialize!