This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: calling function in .init and .fini gives problem


"mohanlal jangir" <mohanlaljangir@hotmail.com> writes:

> Thanks for your replies. Attributes "constructor" and "destructor" works
> very well. Does it mean attribute "constructor" puts the given data in .init
> section (similarly for destructor and .fini)? And why it does not work when
> I try to put the data by specifying __section__(".init")?

The runtime library expects the .init and .fini sections, and the
closely related .ctors and .dtors sections, to contain certain
specific things.  When you use __attribute__((constructor)), the
compiler puts the correct things in these sections.  When you use
__attribute__((section(".init"))), the function body gets dumped into
the .init section, which is decidedly the _wrong_ thing to put there.
Hence, attribute constructor works and attribute section ".init"
doesn't.

zw


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