7 #include <atalk/util.h>
13 #include <mach-o/dyld.h>
15 void *mod_open(const char *path)
17 NSObjectFileImage file;
19 if (NSCreateObjectFileImageFromFile(path, &file) !=
20 NSObjectFileImageSuccess)
22 return NSLinkModule(file, path, TRUE);
25 void *mod_symbol(void *module, const char *name)
30 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
32 strcpy(underscore, "_");
33 strcat(underscore, name);
34 symbol = NSLookupAndBindSymbol(underscore);
37 return NSAddressOfSymbol(symbol);
40 void mod_close(void *module)
42 NSUnLinkModule(module, FALSE);
48 #ifdef DLSYM_PREPEND_UNDERSCORE
51 void *mod_symbol(void *module, const char *name)
59 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
62 strcpy(underscore, "_");
63 strcat(underscore, name);
64 symbol = dlsym(module, underscore);
69 #endif /* DLSYM_PREPEND_UNDERSCORE */