LD: Cannot add content to ctors section

H.J. Lu hjl.tools@gmail.com
Wed May 20 13:05:02 GMT 2020


On Wed, May 20, 2020 at 5:50 AM Ben Hirschberg <bhirschb@cyberarmor.io> wrote:
>
> It is not working, because Alpine container images are using musl-libc. The dynamic loader in musl doesn't call the functions in ".init_array", it delegates this requirement to C runtime (crt0.o). It works in case of Alpine executable which was linked against musl's crt0, because musl's crt0 calls ".init_array" functions.
>
> In my project I have a shared object which is loaded into a Go application. Go application does not use crt0.o and does not call ".init_array" functions. They say that it is ok, because this is the responsibility of the dynamic loader. (see this discussion if you're interested https://github.com/golang/go/issues/28909)
>
> I want to do a workaround this issue and put my static constructors into ".ctros" section because it is supported across the board.

You should file a bug report against musl-libc.  If it doesn't support
.init_array in a shared object,
it is pretty much broken and shouldn't be used at all.

-- 
H.J.


More information about the Binutils mailing list