This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Function with __attribute__ ((constructor)) not placed in .ctors section
- From: Kalle Olavi Niemitalo <kon at iki dot fi>
- To: msciboor <msciboor at googlemail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 28 Jul 2012 20:19:59 +0300
- Subject: Re: Function with __attribute__ ((constructor)) not placed in .ctors section
- Keywords: .ctors,.init_array,ld,binutils
- References: <CAKNG34Ycp-mw7LKZvqHC=wMC68tp=VTpNWVRnWwBGaktdeZtHg@mail.gmail.com>
msciboor <msciboor@googlemail.com> writes:
> I read through Internet that .ctors section is used to hold pointers
> to functions with __attribute__ ((constructor)). However when I
> compile my program with function with __attribute__ ((constructor)),
> then .ctors section is empty and this function is invoked directly
> from __libc_csu_init function instead of __do_global_ctors_aux. Was it
> changed lately?
Debian gcc-4.6 4.6.3-8 does place the pointer in .ctors, but ld
of binutils 2.22-6.1 then moves it to .init_array. Perhaps the
same happens in your test with 4.6.3-1ubuntu5. Mentioned in
<http://sources.redhat.com/bugzilla/show_bug.cgi?id=12910>.
Debian gcc-4.7 4.7.1-2 places the pointer directly in .init_array.
Implemented in <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770>.