Runtime-linking of frameworks with variable paths, & replacing local symbols
Runtime-linking of frameworks with variable paths, & replacing local symbols
- Subject: Runtime-linking of frameworks with variable paths, & replacing local symbols
- From: Jonathan del Strother <email@hidden>
- Date: Thu, 20 Aug 2009 12:58:36 +0100
Heya,
I'm loading a framework whose path isn't known until after my
executable launches. I'm weak linking against the framework, and its
exported functions are marked as weak_import.
After loading the framework with dlopen() (or simply -[NSBundle
load]), I can call objective-c methods in the framework fine. The
trouble comes when I try and call its C functions, where it starts
descending into dyld_stub_ craziness, followed by a crash :
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
#0 0x00000000 in ?? ()
#1 0x000031dd in main (argc=1, argv=0xbffff2f8) at
/Users/jon/Developer/encoder/encodermain.m:151
I can look up the functions one at a time using dlsym(), and assign
them to local function pointers, and calling those then works ok, but
obviously calling the original framework function still crashes. eg -
if my framework exports "void FooBar();" :
void (*myFooBar)();
myFooBar = dlsym(framework, "FooBar");
myFooBar(); // works fine
FooBar(); // Crashes with dyld craziness
Is there any way of replacing all references to FooBar in my
executable with the newly looked up symbol address, or am I stuck with
only being able to call through to the framework via local function
pointers?
Or is there a better way of accomplishing this?
-Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden