Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Dynamic Code Unloading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic Code Unloading



On May 4, 2005, at 11:58 PM, Timothy J. Wood wrote:
On May 3, 2005, at 5:59 PM, Greg Parker wrote:
Tiger has a rewritten dyld that provides better image notification hooks for the Objective-C runtime. objc4-266 uses these hooks instead of the old dyld_register_func mechanism, but Tiger's dyld doesn't send the unload notification yet.

Can we depend on this ourselves -- is there public API/docs for this new section?


// Special section containing a function pointer that dyld will call
// when it loads new images.
LAZY_PIC_FUNCTION_STUB(__objc_notify_images)
.data
.section __DATA,__image_notify
.long L__objc_notify_images$stub


It looks like this code won't build, though (at least not on Tiger, maybe on Darwin) since objc-runtime.m has:

    #include <mach-o/dyld_gdb.h>

and there is no such header on my machine. Hopefully this is an oversight and this file was supposed to be included to replace the stuff in dyld_debug.h that got deprecated.

The file is available from opensource.apple.com in the dyld project. The part you need for objc4 is:


enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1 };

struct dyld_image_info {
const struct mach_header* imageLoadAddress; /* base address image is mapped into */
const char* imageFilePath; /* path dyld used to load the image */
uintptr_t imageFileModDate; /* time_t of image file */


/* if stat().st_mtime of imageFilePath does not match imageFileModDate, */
/* then file has been modified since dyld loaded it */
};


typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]);


I wouldn't use this mechanism on any code that needs to run on 10.5. Right now, it's only intended for gdb and objc4.



-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Dynamic Code Unloading (From: Spencer Nielsen <email@hidden>)
 >Re: Dynamic Code Unloading (From: Greg Parker <email@hidden>)
 >Re: Dynamic Code Unloading (From: "Timothy J. Wood" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.