Ideas for runtime loading of shared libraries.
Martin Nowak
dawg at dawgfoto.de
Tue Jan 3 10:31:59 PST 2012
On Tue, 03 Jan 2012 18:56:56 +0100, Jacob Carlborg <doob at me.com> wrote:
> On 2012-01-03 18:27, Sean Kelly wrote:
>> The trick seems to be mapping in TLS (on OSX anyway) and running static
>> crore at the right time. Are there other issues as well?
>
> TLS has at least been an issue to me when trying to implement support
> for dynamic libraries on Mac OS X. I have no idea how the
> ___tls_get_addr function should be implemented to support dynamic
> libraries, especially not since we're rolling our own implementation and
> there's no documentation to follow.
>
> I don't think there's any problems with the static constructors.
>
> I've posted about my problems before at the DMD internals mailing list:
>
> http://dfeed.kimsufi.thecybershadow.net/discussion/post/F2166CBA-4F77-49F7-9949-9F3666C12840@me.com
>
Without support from the OS (TLS segment register)
and none of the linker (module index as dynamic TLS relocations)
any implementation will be severely flawed/inefficient.
As a workaround you could determine the library that called
__tls_get_addr by the return address, e.g. through
__builtin_return_address(0),
and a search it among the .text ranges of all loaded libraries.
More information about the Digitalmars-d
mailing list