|Non-Confidential||PDF version||ARM 100073_0608_00_en|
|Home > The ARM C and C++ Libraries > Tailoring the C library to a new execution environment > C++ initialization, construction and destruction|
The C++ standard places certain requirements on the construction and destruction of objects with static storage duration. The static constructors are executed before main(), the destructors are called after the program exits.
The library must ensure that all the static constructors within a translation unit are called in the order of declaration, and the static destructors are called in reverse order of declaration. There is no way to determine the initialization order between translation units.
Each translation unit containing static constructors has an initialization function. This
function calls the static constructors for the translation unit, and registers the static
destructors with a call to
__aeabi_atexit(). Function-local static objects with destructors
also register their destructors using
The location of the per translation unit initialization function is stored in an
.init_array section. At link time the
.init_array sections must be collated together into a
.init_array section. The linker will generate an error if this is not
The library routine
__cpp_initialize_aeabi_ is called from the C library startup code
__cpp_initialize_aeabi_ walks through the
calling each function in turn.
cxa_finalize() which calls the static destructors