loading multiple modules in MacOS X
Robby Griffin <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.hugs.bugs |
|---|---|
| Message-ID | <[email protected]> |
The dlsym() replacement for MacOS X doesn't use its "handle" parameter, so it has no hope of always finding the proper initModule function from among multiple modules. I noticed this when trying the graphics library, which loads two modules; the second one fails with unknown primitive references. The attached patch works on my MacOS X 10.2 system, but I'm not sure how compatible this is with other dyld implementations. --Robby
dyld_patch.txt
(text/plain, 545 B)
diff -ur hugs98-Dec2001/src/machdep.c hugs98-Dec2001-patched/src/machdep.c
--- hugs98-Dec2001/src/machdep.c Fri Dec 14 13:00:49 2001
+++ hugs98-Dec2001-patched/src/machdep.c Tue Oct 29 12:17:35 2002
@@ -1751,10 +1751,9 @@
void* dlsym( void* handle, char* symbol ) {
void* addr;
- if( NSIsSymbolNameDefined( symbol ) )
- addr = NSAddressOfSymbol( NSLookupAndBindSymbol( symbol ) );
- else
- addr = NULL;
+ addr = NSLookupSymbolInModule( handle, symbol );
+ if( addr )
+ addr = NSAddressOfSymbol( addr );
return addr;
}