This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unexpected behavior regarding linking sections


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]