shared libs for OSX

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Sat May 30 06:56:31 PDT 2015


On Sat, 30 May 2015 05:06:34 -0400, Jacob Carlborg <doob at me.com> wrote:

> On 2015-05-30 01:03, bitwise wrote:
>
>> No, it opens the image for the main program, even if called from  a
>> shared lib.
>>
>>> And that void* which is returned is actually a "mach_header*", if I
>>> recall correctly.
>>
>> Not sure if this is true.
>
> I see, it was mostly a guess.
>

Not sure how accurate this code[1] is, but it seems dlopen returns a  
pointer to the image itself, which has a function
machHeader();

http://www.opensource.apple.com/source/dyld/dyld-353.2.1/src/dyldAPIs.cpp

dlopen returns magic numbers(RTLD_MAIN_ONLY or RTLD_DEFAULT) if you pass  
null, and sometimes it "|"s a 1 with the image pointer. So we can't really  
use it to get at the header.

   Bit


More information about the Digitalmars-d mailing list