gcc crtbegin crtend
For what purpose 开发者_JS百科does gcc use crtbegin.o and crtend.o ?
Those files contain the code to handle C++ global constructors and destructors.
You need check the 'nm' output of the crtbegin, crtend and other crtxxx files to understand it properly.
These files contains code for constructors(initialization routines) and destructors(termination routines). These constructors and destructors are not be confused with C++ global Constructors/Destructors. These routines are called before the actual start("main") of the program.
The linker builds 2 list of functions CTOR_LIST(startup-time routines) and DTOR_LIST(exit-time routines) to be executed.
Refer: https://gcc.gnu.org/onlinedocs/gccint/Initialization.html
精彩评论