/* We found two symbols for the same name in two different modules */ static NSModule multiple(NSSymbol s, NSModule om, NSModule nm) { NSModule ret = nm; log_debug("Symbol \"%s\" found in modules \"%s\" and \"%s\" (using %s)", NSNameOfSymbol(s), NSNameOfModule(om), NSNameOfModule(nm), NSNameOfModule(ret)); return (ret); }
NSModule multipleErrorHandler(NSSymbol s, NSModule old, NSModule newmod) { /* XXX ** This results in substantial leaking of memory... Should free one ** module, maybe? */ fprintf(stderr, "%s: Symbol `%s' found in `%s' and `%s'", __FILE__, NSNameOfSymbol(s), NSNameOfModule(old), NSNameOfModule(newmod)); return(newmod); }
/* Get the address for a specifed symbol */ void *dso_symbol(dso_handle hdl, const char *nam) { NSSymbol sym = NULL; NSModule mod = NULL; char *und = NULL; void *add = NULL; int x = 0; /* Check parameters */ if (hdl == NULL) { log_error("Invalid library handler specified"); return (NULL); } if (nam == NULL) { log_error("Invalid symbol name specified"); return (NULL); } /* Process the correct name (add a _ before the name) */ while (nam[x] != '\0') x++; und = (char *)malloc(sizeof(char) * (x + 2)); while (x >= 0) und[x + 1] = nam[x--]; und[0] = '_'; /* Find the symbol */ sym = NSLookupAndBindSymbol(und); free(und); if (sym == NULL) return (NULL); /* Dump some debugging output since this part is shaky */ mod = NSModuleForSymbol(sym); add = NSAddressOfSymbol(sym); log_debug("Symbol \"%s\" found in module \"%s\" at address \"0x%08X\"", NSNameOfSymbol(sym), NSNameOfModule(mod), add); /* We want to return the address of the symbol */ return (add); }
static NSModule dlMultiple(NSSymbol s, NSModule oldModule, NSModule newModule) { dprintf((stderr, "dyld: %s: %s previously defined in %s, new definition in %s\n", NSNameOfSymbol(s), NSNameOfModule(oldModule), NSNameOfModule(newModule))); return newModule; }
ap_private_extern NSModule multiple_symbol_handler (NSSymbol s, NSModule old, NSModule new) { /* * Since we can't unload symbols, we're going to run into this * every time we reload a module. Workaround here is to just * rebind to the new symbol, and forget about the old one. * This is crummy, because it's basically a memory leak. */ #ifdef DEBUG ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, NULL, "dyld found a multiply defined symbol %s in modules:\n" "%s\n%s\n", NSNameOfSymbol(s), NSNameOfModule(old), NSNameOfModule(new)); #endif return(new); } ap_private_extern void linkEdit_symbol_handler (NSLinkEditErrors c, int errorNumber, const char *fileName, const char *errorString) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, NULL, "dyld errors during link edit for file %s\n%s\n", fileName, errorString); abort(); }