D-Programming-Language/dmd — pull request #1043 by dawgfoto (2012-07-11 11:23:32+00:00)
Title: new runtime registration for executables and shared libraries

- Put ModuleInfos and EH tables in bracketed sections. This
works because the linker will preserve the order of first
occurence for non-standard sections. Use local zero sized
symbols as brackets to refer to the start and end.

- Pass ModuleInfos along with EH tables to a new druntime
function _d_dso_registry. We output a function, a ctor
entry, a dtor entry and a local data record in a COMDAT
section group. The linker will merge multiple occurences
per executable/shared library, thus resulting in only one
registration.

- We can't create brackets for .bss, .data, .tbss and .tdata
as these sections are already known to the linker. Thus it
would merge input sections in link order. Creating custom
input sections for those is not desirable because COMDAT
through section prefixes (.data.TypeInfo) won't get merged
into a single output section. The needed segments can be
obtained by reading the program headers.

- Until REQUIRE_DSO_REGISTRY is set in elfobj.c any
generated object remains compatible with the old mechanism
that uses global bracket symbols.