D on Windows Phone

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 1 05:23:18 PDT 2015


On 01/07/15 10:06, Dan Olson wrote:

> The private APIs being called by osx_tls.c like
> dyld_enumerate_tlv_storage() are overriden for iOS by using [1].  I can
> change all dyld prefixes in theadLocalVariable.c to something else and
> remove all code not needed.

Right, I forgot that you have implemented those functions yourself. But 
removing the "dyld" prefix might be a good idea.

> That would leave a call to private API
> dyld_register_image_state_change_handler() in threadLocalVariables.c,
> but it looks to me like it could be rewritten to use
> _dyld_register_func_for_add_image().  Tried it and seems to work.

_dyld_register_func_for_add_image won't work for dynamic libraries. 
There's no API to unregister the callback. So, if 
_dyld_register_func_for_add_image is called from a dynamic library then 
the library is unloaded. The next call to any of the "dl" functions, 
i.e. "dlopen" will crash.

dyld_register_image_state_change_handler works because it pins the 
dynamic library, if I recall correctly. It won't unload it.

_dyld_register_func_for_add_image is already used by druntime, perhaps 
it doesn't matter. I think bitwise is working on adding support for 
dynamic libraries on OS X. On Linux the compiler is generating a 
function that behave as the C function with the attribute 
__attribute__((constructor)). Perhaps that can be used.

Otherwise perhaps look at the implementation of
dyld_register_image_state_change_handler and see if you can manually pin 
the dynamic library.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list