What does rt/sections_elf_shared.d do? (Porting dmd to musl)

Yuxuan Shui yshuiv7 at gmail.com
Sun Dec 17 12:45:58 UTC 2017


I'm trying to get dmd and phobos working with musl. Right now I 
have a bootstrapped compiler built with musl, which seems to work 
fine. However user applications will segmentation fault before 
even reaches main.

I investigated a bit. Looks like musl is not happy with how 
druntime uses dlopen related functions. When a D library loads, 
it tries to call _d_dso_registry, which will try to get a handle 
of the library using dlopen. Meaning dlopen will be called on the 
library itself while it's still loading. This seems to break 
musl. Although this might also be a bug on musl side: it tries to 
call init functions even when RTLD_NOLOAD is passed to dlopen.

However, going through sections_elf_shared.d, it makes me feel 
it's doing some magic tricks with dl functions, but I don't know 
what for?

If my understand is correct, it's used to register TLS storage to 
GC. If that's the case, there must be simpler ways to do that.


More information about the Digitalmars-d mailing list