I am building GCC 3.2 for target=sparclet-aout. Though there is no issue with C however the C++ global objects are not getting initialized. I have posted a mail to libstdc++ mailing list and have tried all that was suggested. http://gcc.gnu.org/ml/libstdc++/2005-04/msg00238.html
I have tried every solution from whatever documents I found on the net. But it does not work for me. After all this I got down to breaking the problem into a compiler/linker (or my understanding) issue. After the analysis I have learned that when we put some global objects in C++ source files, there comes a function like __GLOBAL__I_FirstGlobalVariableInFile in object file. This function actually do the initialization of the corresponding global object and also contain calls to constructors of other global objects in the file. Now, it's the job of linker to accumulate all __GLOBAL__I_<> symbols from all .o into an array (of function pointers). The linker should (as per docs) create a symbol named __CTOR_LIST__ that should point to starting of the array. (In my __main I'm processing __CTOR_LIST__). However in the final executable __CTOR_LIST__ is not created at all! Though the __GLOBAL__I_<> symbols are linked into the final executable gracefully. (Yes I have added CONSTRUCTORS command to my linker script) For finding out the reason I searched in the linker's source and found out that the structure "struct bfd_link_callbacks" in bfdlink.h holds a set of callback functions which have their definitions in ldmain.c. One of these functions named "constructor_callback" in ldmain.c is called for the initialization of global objects, this function in turn call some other funtion e.g. "ldctor_add_set_entry" for the initialization purpose. To know if I'm at right place I added printf in the function "constructor_callback" and build/installed the linker again. However linking again does not execute the my printf and hence the corresponding function. I'm a newbee in GCC and other GNU build tools. Please advise where to look for the problem. I have been struggling to make the global objects for quite some time. Any help would be highly appreciated. Configuration: I used the following commands for cross building gcc $configure -target=sparclet-aout -prefix=/home/spratap/WorkArea/tools --enable-languages=c,c++ $make all LANGUAGES="c c++" $make install LANGUAGES="c c++" Thanks in advance. Regards, Satendra ********************** Legal Disclaimer **************************** "This email may contain confidential and privileged material for the sole use of the intended recipient. Any unauthorized review, use or distribution by others is strictly prohibited. If you have received the message in error, please advise the sender by reply email and delete the message. Thank you." **********************************************************************