Working LDC iOS (iPhone) on github

Jacob Carlborg doob at me.com
Sun Feb 16 06:17:07 PST 2014


On Sunday, 16 February 2014 at 13:19:00 UTC, David Nadlinger 
wrote:

> Sorry, yes, I just intended to write "special section".
>
> But as a side note, Darwin's dyld is more or less alone in 
> offering
> that functionality. On other OSes, DMD still uses bracketed 
> sections
> for various tasks.

Yes, exactly. But where talking iOS and OS X here ;)

> I was thinking about that as well, yes. In theory, it should be
> possible to adapt the code in LLVM without too much of a hassle 
> (I
> don't think there would be any problems with x86-specific 
> relocations
> or so), but as I said, I haven't looked into how the TLS 
> sections are
> emitted when writing to Mach-O at all.
>
> Another thing to keep in mind would be that we probably can't 
> use some
> of the APIs due to App Store restrictions…

_dyld_register_func_for_add_image and other similar functions are 
documented here [1], which I assume means they are public API and 
are allowed to be used (I have not read the App Store license). 
But LDC already uses a function to iterate TLS data on OS X in 
the runtime (if its still is used) which not documented. Phobos 
also uses _NSGetEnviron which is not documented. The first could 
be replaced with some of these functions [1]. The second could 
perhaps be replaced with a C main function accepting the 
environment variables as a third parameter.

BTW, the _dyld_register_func_for_add_image is not safe to use 
with dynamic libraries, since it's not possible to unregister the 
callback. There is another undocumented function that can be used 
instead.

[1] 
https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html

--
/Jacob Carlborg



More information about the digitalmars-d-ldc mailing list