[Issue 20220] pragma(crt_constructor) does not work with clang 9

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 13 01:01:04 UTC 2019


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

kinke <kinke at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net

--- Comment #6 from kinke <kinke at gmx.net> ---
(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.

--


More information about the Digitalmars-d-bugs mailing list