Unexpected behavior regarding linking sections
H.J. Lu
hjl.tools@gmail.com
Tue Dec 11 16:28:00 GMT 2018
On Tue, Dec 11, 2018 at 7:28 AM Felix von Leitner
<felix-binutils@fefe.de> wrote:
>
> This is about my libc handling code for ctors and dtors.
> In the startup code, I do this:
>
> .section .ctors,"aw"
> .global __CTOR_LIST__
> __CTOR_LIST__:
>
> .section .dtors,"aw"
> .global __DTOR_LIST__
> __DTOR_LIST__:
>
> Then, after all the other code, I do this:
>
> .section .ctors,"aw"
> .global __CTOR_END__
> __CTOR_END__:
>
> .section .dtors,"aw"
> .global __DTOR_END__
> __DTOR_END__:
>
> And the handling code looks like this:
>
> funcptr* f;
> funcptr* m=__CTOR_END__<__DTOR_LIST__ ? __CTOR_END__ : __DTOR_LIST__;
> for (f=__CTOR_LIST__; f<m; ++f) (*f)();
>
You should drop dtors/ctors and use init_array/fini_array instead.
--
H.J.
More information about the Binutils
mailing list