On Wed, 14 Dec 2011 11:51:13 +0100, Walter Bright <newshou...@digitalmars.com> wrote:

On 12/14/2011 2:17 AM, Martin Nowak wrote:
If the compiler generated static constructors and destructors ala C++ that would then be used to register the sections, that could hook into the existing C++ support code and not require special linker scripts and special object files.

I partly agree and will give that approach another try.
The huge drawback is that a shared library is self-contained w.r.t.
module construction, TLS and EH. When doing this on a per object base
the overhead increases with the number of linked objects and guaranteeing
ordered initialization becomes non-trivial.

Yeah, I thought of that after I posted it.

I think I finally found a feasible solution.
It is possible to create a section group consisting of
a constructor/destructor referencing entries in .ctors/.dtors
and probably related data. The will be treated as one combined
COMDAT and subsequently get merged to a unique instance of each.

Reply via email to