If I had my way

Martin Nowak dawg at dawgfoto.de
Tue Dec 13 06:19:31 PST 2011


On Tue, 13 Dec 2011 14:12:43 +0100, Jacob Carlborg <doob at me.com> wrote:

> On 2011-12-13 13:12, Martin Nowak wrote:
>> On Sat, 10 Dec 2011 22:32:17 +0100, Walter Bright
>> <newshound2 at digitalmars.com> wrote:
>>
>>> On 12/10/2011 12:53 PM, maarten van damme wrote:
>>>> Could also someone shed some light on creating shared library's on
>>>> linux? there
>>>> was some news about -fPIC beeing fixed but no real confirmation.
>>>
>>> Turns out there was a bug where EBX was not set correctly when calling
>>> a function that existed in a shared library. This bug was fixed. So
>>> we're ready to try again at creating a shared library with dmd.
>>>
>>
>> On x86-64 the PIC code is working fine, but there were some relocation
>> issues left.
>> https://github.com/dawgfoto/dmd/commits/SharedElf
>>
>> I'm looking into wiring things up with the runtime,
>> but it requires quite some changes.
>>
>> One thing I don't have a good answer too is how to handle registration
>> of a shared library loaded during runtime. Apparently we don't want
>> to synchronize all threads whenever a library gets loaded/unloaded.
>>
>> martin
>
> On Mac OS X there's a function available for that,  
> "_dyld_register_func_for_add_image". I don't know if there's something  
> similar available on Linux and FreeBSD.
>
> http://developer.apple.com/library/mac/#documentation/developertools/Reference/MachOReference/Reference/reference.html
>

This can be done by __attribute__ ((constructor)) or by adding a function
pointer to the .init section.
But the issue is initialization for already running threads.


More information about the Digitalmars-d mailing list