• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Runtime-linking of frameworks with variable paths, & replacing local symbols
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: which pages of the file are in the cache
  • Next by Date: Re: 64-bit Mac OS X kernel
  • Previous by thread: Re: 64-bit Mac OS X kernel
  • Next by thread: CFFileDescriptor fd leak?
  • Index(es):
    • Date
    • Thread