[D-runtime] druntime ModuleInfo discovery without bracketing segments

Johannes Pfau johannespfau at googlemail.com
Mon Jun 17 05:52:28 PDT 2013


Am 17.06.2013 14:45, schrieb Johannes Pfau:
> Am 14.06.2013 14:58, schrieb David Nadlinger:
>> Thus, I thought about using a scheme where there is one global (C
>> runtime) ctor per module just like there is in the old one. Instead of
>> setting up the _Dmodule_ref chain directly, it would call the
>> equivalent of _d_dso_registry. If a DSO info record (struct DSO in
>> sections_linux) has not been initialized for the given image yet, the
>> function would set it up, and in any case add the passed ModuleInfo*
>> to a pointer array in the record.
>>
> Instead of emitting one constructor per module you could also create a 
> special object file with that constructor, then always link against 
> that object file when compiling a shared library.
>
> This is also what gcc -shared does: It links in crtbeginS.o and 
> crtendS.o.
>
Of course then you couldn't access all ModuleInfos... sorry for the noise.

It could actually be implemented similar to crtbeginS.o and crtendS.o 
which are used to run the global c constructors though, but then it's 
platform specific again.

-- 
Johannes Pfau



More information about the D-runtime mailing list