https://issues.dlang.org/show_bug.cgi?id=20220

kinke <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #6 from kinke <[email protected]> ---
(In reply to Ernesto Castellotti from comment #3)
> However I found the way to solve, DMD adds the .ctors section to the elf for
> crt_constructor, I discovered that using .init_array the problem does not
> happen

Yes, that's it, DMD emits the c/dtors into the .{c,d}tors sections in the
object files (LDC uses .{init,fini}_array by default for Linux). Quoting an LLD
maintainer from https://gitter.im/ldc-developers/main:

> Most Linux distributions configure glibc with NO_CTORS_DTORS_SECTIONS 
> nowadays.
> csu/init-first.c:_init just doesn't run __libc_global_ctors (which runs
> __CTOR_LIST__ hooks). The builtin linker script of GNU ld and gold's default
> --ctors-in-init-array place .ctors input sections to .init_array

So this apparently only works in most cases due to the GNU linkers mapping the
object file sections to differently named binary sections by default. LLD
doesn't have such an option, so DMD should probably just switch to the 'modern'
section names.

--

Reply via email to