• 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
Re: Loading/Unloading a Cocoa-using framework from a CFM application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading/Unloading a Cocoa-using framework from a CFM application


  • Subject: Re: Loading/Unloading a Cocoa-using framework from a CFM application
  • From: Florent Pillet <email@hidden>
  • Date: Thu, 22 Apr 2004 21:47:32 +0200

objc: cannot unmap an image containing ObjC data

I searched for that and actually found some code from Darwin online (objc-runtime.m) and a cursory glance seems to indicate that some things are being initialized when the library is loaded but that they aren't cleaned up when it's unloaded. Is there some code I could add to clean things up so the framework can unload cleanly?

I have the exact same problem (interesting timing) with a CFM application calling a CFM piece of code which in turn loads my Mach-O bundle (actually a Palm HotSync conduit as a Mach-O bundle, loaded by a stub CFM conduit I wrote for the only purpose of firing the real Mach-O one). I discovered that you can't unload a bundle using the Objective-C runtime, though it doesn't seem to cause a problem when HotSync is done with the conduit, it simply goes away.

Yesterday Bob Ippolito posted an interesting message describing the various forms of Mach-O object files and their constraints. Here is is for refererence, note the info about unloading Obj-C code in MH_BUNDLE:

Well on OS X you have various kinds of Mach-O object files, the most important are the following:

MH_EXECUTE
Represents the executable code and data for a single process. CAN NOT be linked to with ld. Can NOT be loaded dynamically UNLESS it is replacing an entire existing process (execve, etc.). These usually have no extension, are marked "+x" in the filesystem, and live in the Contents/MacOS/ folder of a bundle. These are the output of ld with no special flags, or with the -execute flag.

MH_DYLIB
MH_EXECUTABLE, MH_BUNDLE, and MH_DYLIB may link to these with ld. CAN NOT be removed from a process once loaded, but CAN be loaded dynamically (via dyld incantations, NSBundle, etc). These usually have a .dylib extension if they're independent, but have no extension if they are part of a framework. Sometimes they have other extensions (.so, .jnilib, etc.). These are the output of ld with the -dylib flag (or the -dynamic option in libtool).

MH_BUNDLE
CAN NOT be linked to with ld. May only be loaded at runtime (via CFBundle, NSBundle, or dyld incantations). CAN be loaded and unloaded (if it does not use the Objective C runtime, anyway) dynamically. These usually have a .bundle or .so extension, or may be in a plug-in bundle. Has a bunch of special ld flags such as the new -undefined dynamic_lookup or -bundle_loader. These are the output of ld with the -bundle flag.

Please read the man pages for dyld, ld, and Apple's Mach-O Runtime Architecture and UNIX Porting Guide for more information. You may also choose to read the dyld source (part of Darwin) or at least the headers in /usr/include/mach-o/ if you want more enlightenment.

-bob

Hope this helps,
Florent

--
Florent Pillet, Code Segment email@hidden
Developer tools and end-user products for Palm OS & Mac OS X
ICQ: 117292463 http://perso.wanadoo.fr/fpillet
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Loading/Unloading a Cocoa-using framework from a CFM application (From: David Elliott <email@hidden>)

  • Prev by Date: Re: Newbie: Cannot use object as a parameter to a method
  • Next by Date: Re: Newbie: Cannot use object as a parameter to a method
  • Previous by thread: Re: Loading/Unloading a Cocoa-using framework from a CFM application
  • Next by thread: Re: Newbie: Cannot use object as a parameter to a method -- SOLVED
  • Index(es):
    • Date
    • Thread