[D-runtime] druntime ModuleInfo discovery without bracketing segments

David Nadlinger code at klickverbot.at
Sun Sep 1 11:26:01 PDT 2013


On Thu, Aug 29, 2013 at 11:29 PM, David Nadlinger <code at klickverbot.at> wrote:
> In any case, what precise kind of "hidden" are you experimenting with?
> STV_HIDDEN? I couldn't quite get things to work here, do you maybe
> have an example patch/asm file/…?

Okay, turns out I just made a stupid mistake; I got the basic
mechanism to work with LLVM, even though strictly speaking I might be
relying on undefined behavior.

The only thing I couldn't quite reuse from your (Martin's) solution is
the trick of using a comdat .ctors.* section to make sure the
compiler-generated ctor calling _d_dso_registry is only called once,
as I couldn't get LLVM to mark the section for a weak variable as
comdat if a custom section name is specified. One way around this
might be using (LLVM-) module-level inline asm (though that might
again cause problems w.r.t. bitcode-level module linking), but I think
it should be possible to just use a (hidden) global boolean flag to
ensure the ctor/dtor is only run once.

Now I just need to find the time to actually implement the change
(i.e. the change to ModuleInfo emission plus the _d_dso_registry
calls) in LDC, but I think I'll wait with that until the DLL-related
dust has settled on the DMD side of things.

David


More information about the D-runtime mailing list