LD: Cannot add content to ctors section
Alan Modra
amodra@gmail.com
Thu May 21 04:57:52 GMT 2020
On Wed, May 20, 2020 at 09:15:42AM +0000, Ben Hirschberg wrote:
> Hi!
>
> I have a setup (Alpine Linux with Go executables) where I cannot rely on contents of ".init_array" to be called, but ".ctors" are called by musl-libc's loader.
>
> I am trying to add my constructors (C or ASM) to the ".ctors" section, but after linking my shared object they seem to be moved to ".init_array" (however in Alpine the ".ctors" section stays in the final image but it is empty)
>
> Why is this happening? Can make my array stay in ".ctors" section?
There is a binutils configure option --disable-initfini-array that may
help in building a linker that should not map .ctors to .init_array.
Whether this all still works is another question.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list