Another weird LLVM mystery solved!
So, I was porting LDC to FreeBSD/aarch64, wondering why global constructors (you know, the before-main() code you can make in C using an __attribute__ thingy) arenβt runningβ¦ but only when the executable is linked with LLD. Turns out:
.init_arrayis the only supported way to do constructors on AArch64- and everything in general is moving towards
.init_arrayβ but the default in LLVM is still to emit.ctors - clang has code to enable
.init_arraywhen appropriate, ldc did not - and the reason it all worked fine with bfd and gold is that these linkers SILENTLY convert
.ctorsto.init_array. For PERFORMANCE REASONS.