X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fppc-darwin-dlshim.c;h=c6c16f35f642e4e28bb06a8060573ad452b7c4bd;hb=3b3086ad5ad36a66302e1e6c5b7c8246c7963462;hp=9187ef233489a854abde43b4c6541e436c9af763;hpb=b7cfa0e5e726c2037ba2c6cb32406ff7e9764dd2;p=sbcl.git diff --git a/src/runtime/ppc-darwin-dlshim.c b/src/runtime/ppc-darwin-dlshim.c index 9187ef2..c6c16f3 100644 --- a/src/runtime/ppc-darwin-dlshim.c +++ b/src/runtime/ppc-darwin-dlshim.c @@ -19,6 +19,7 @@ #include #include #include +#include "ppc-darwin-dlshim.h" /* Darwin does not define the standard ELF * dlopen/dlclose/dlsym/dlerror interface to shared libraries, so this @@ -30,12 +31,9 @@ static char dl_self; /* I'm going to abuse this */ -#define RTLD_LAZY 1 -#define RTLD_NOW 2 -#define RTLD_GLOBAL 0x100 - static int callback_count; static struct mach_header* last_header; +static int last_was_error = 0; void dlshim_image_callback(struct mach_header* ptr, unsigned long phooey) { @@ -157,8 +155,17 @@ const char* dlerror() if (!errbuf) { errbuf = (char*) malloc(256*sizeof(char)); } - snprintf(errbuf, 255, "%s in %s: %d %d", c, d, a, b); - return errbuf; + if (!(c || d)) { + last_was_error = 0; + snprintf(errbuf, 255, "%s in %s: %d %d", c, d, a, b); + return errbuf; + } else if (last_was_error) { + last_was_error = 0; + snprintf(errbuf, 255, "Can't find symbol"); + return errbuf; + } + last_was_error = 0; + return NULL; } void* dlsym(void* handle, char* symbol) @@ -169,6 +176,7 @@ void* dlsym(void* handle, char* symbol) retsym = NSLookupAndBindSymbol(symbol); return NSAddressOfSymbol(retsym); } else { + last_was_error = 1; return NULL; } } else { @@ -177,6 +185,7 @@ void* dlsym(void* handle, char* symbol) retsym = NSLookupSymbolInImage(handle, symbol, 0); return NSAddressOfSymbol(retsym); } else { + last_was_error = 1; return NULL; } }