3 #include <atalk/util.h>
9 #include <mach-o/dyld.h>
11 void *mod_open(const char *path)
13 NSObjectFileImage file;
15 if (NSCreateObjectFileImageFromFile(path, &file) !=
16 NSObjectFileImageSuccess)
18 return NSLinkModule(file, path, TRUE);
21 void *mod_symbol(void *module, const char *name)
26 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
28 strcpy(underscore, "_");
29 strcat(underscore, name);
30 symbol = NSLookupAndBindSymbol(underscore);
33 return NSAddressOfSymbol(symbol);
36 void mod_close(void *module)
38 NSUnLinkModule(module, FALSE);
44 #ifdef DLSYM_PREPEND_UNDERSCORE
47 void *mod_symbol(void *module, const char *name)
55 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
58 strcpy(underscore, "_");
59 strcat(underscore, name);
60 symbol = dlsym(module, underscore);
65 #endif /* DLSYM_PREPEND_UNDERSCORE */