This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Unexpected behavior regarding linking sections
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: felix-binutils at fefe dot de
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 11 Dec 2018 08:27:21 -0800
- Subject: Re: Unexpected behavior regarding linking sections
- References: <20181211152750.GA19360@qarx.de>
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.