May 29, 2015
On Fri, 29 May 2015 14:05:10 -0400, Jacob Carlborg <doob@me.com> wrote:

> On 2015-05-29 18:45, bitwise wrote:
>
>> I'm going to test it out this weekend, but if I do get the wrong
>> address, I think I can add a symbol with "__attribute__ ((visibility
>> ("hidden")))" and use dladdr on that instead. I don't think hidden
>> symbols should collide.
>
> Doesn't "dlopen" open the current image if "null" is passed?

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.

This works for sure in terms of getting "a" mach_header*, but I still have to check if visibility(hidden) allows each shared lib to have it's own copy of "_symbol":

__attribute__ ((visibility("hidden"))) static int _symbol = 1;
Dl_info info;
if(dladdr(&symbol, &info))
    const struct mach_header* myHeader = cast(const struct mach_header*)info.dli_fbase


https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dladdr.3.html

  Bit
May 30, 2015
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.

-- 
/Jacob Carlborg
May 30, 2015
On Sat, 30 May 2015 05:06:34 -0400, Jacob Carlborg <doob@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
December 26, 2021
On Saturday, 30 May 2015 at 13:56:31 UTC, bitwise wrote:
> On Sat, 30 May 2015 05:06:34 -0400, Jacob Carlborg <doob@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/

> 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


Hi,
This was implemented ?
I am trying to load,call and unload multiple shared libs/dlls which are written in dlang on Linux , macOS and windows.

December 27, 2021
On Sunday, 26 December 2021 at 12:18:45 UTC, Peter wrote:
> Hi,
> This was implemented ?
> I am trying to load,call and unload multiple shared libs/dlls which are written in dlang on Linux , macOS and windows.

Hello,

See the example here in:
https://github.com/AuburnSounds/Dplug/blob/master/examples/distort/dub.json#L13

Those are the flags you need to pass to D compiler to have shared libraries in Linux, macOS and windows, in a way that they can be copied to another system.
Within those libraries, it's easiest not to use the D runtime (https://github.com/AuburnSounds/Dplug/wiki/Working-in-a-@nogc-environment) and then you are in a restricted D subset. You _might_ be able to initialize the D runtime but it can be tricky.
1 2 3 4 5
Next ›   Last »