You should be calling NSLinkEditError if nssymbol is null to check why.
As far as I can make out this doesn't apply to errors from
NSLookupSymbolInModule. Anyhow it doesn't report any errors..
I've condensed the problem down to a small standalone program and tried
it with underscores/no underscores in both linking and runtime and
still no luck. I'd appreciate it if someone could find some time to
give things a once over.
Thanks,
Sean
/* Test program for dyld loading problem */
/* Usage / Compilation. */
/* The path to the bundle is hard coded so might need a tweak first -
see below */
/* ld -r -u _MD5 -o elib.o */
/* cc -bundle -flat_namespace -undefined suppress -o elibcrypto.so
elib.o -lcrypto */
/* cc -o test test.c */
/* ./test */
/* returns "NSLookupSymbolInModule failed 0" */
int main (int argc, const char * argv[]) {
NSObjectFileImage ofile;
NSModule handle = NULL;
NSSymbol nssymbol;
int dyld_result = NSObjectFileImageSuccess;
char *dlname = "/Users/sean/working/dyld_test/elibcrypto.so";
/* First try to load bundle */
dyld_result = NSCreateObjectFileImageFromFile(dlname, &ofile);
if (dyld_result != NSObjectFileImageSuccess) {
printf("NSCreateObjectFileImageFromFile() failed");
return 0;
}
/* Then link it */
handle = NSLinkModule(ofile, dlname,
NSLINKMODULE_OPTION_RETURN_ON_ERROR
| NSLINKMODULE_OPTION_PRIVATE
| NSLINKMODULE_OPTION_BINDNOW);
if (handle == NULL) {
printf("NSLinkModule failed");
return 0;
}
/* Then try to find a symbol */
nssymbol = NSLookupSymbolInModule(handle,"_MD5");
if (nssymbol == NULL) {
/* NSLinkEditError() doesn't appear to apply to NSLookupSymbol but
anyway.. */
NSLinkEditErrors c;
int errorNumber;
const char *fileName;
const char *errorString;
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
printf("NSLookupSymbolInModule failed %d \r\n", errorNumber);
return 0;
}
printf("Success");
return 0;
}
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.