Altera_Forum
Honored Contributor
21 years agoC++ global constructors not being called
We are using version 1.0.0 build 393 of the Nios II IDE and bringing up an application under uClinux. The problem du jour is that it appears the constructors for globally defined C++ objects are not being invoked at startup.
From the GNU documentation and various documentation fragments gleaned from the web, it appears that, for ELF binaries, the constructors show up in a segment named .ctor and are preceded by a label __CTOR_LIST__, and they are supposed to be all called before main is invoked (possibly by the _init() function). Another fragment indicates that there should be a pair of .o files, crtbegin.o and crtend.o, which are sandwiched around the application and between crti.o and crtn.o, but they don't appear to exist anywhere. The .ctor (and .dtor for global destructors) do not show up in ELF object post-link, and the label __CTOR_LIST__ doesn't exist. Has anyone else had this problem? If so, how did you fix it?