The Startup File

The startup file sets up the C/C++ environment before the MCU runs your program. It is written in ARM Cortex assembly, and normally there is no need to change it except for modifying the interrupt vector table. It performs the following tasks before calling your main function:

 

     Initialize the top of stack to the top of the SRAM space

     Copy initialized values of the global variables from flash memory copies to the SRAM locations

     Zero out uninitialized global variable per C/C++ requirements

 

It may also contain the interrupt vector table. There is no particular reason for this, except that since a startup file is always part of a C/C++ project, it is therefore a convenient place to put the interrupt vectors.

 

Indeed, projects created by using the new project wizard File->New->Project…, including ones created by the JumpStart API wizard, have startup files that include interrupt vector tables.

 

For C++ projects, a GCC library function __libc_init_array must be called prior to when main is called, to initialize global constructors. In JumpStart C++ wizard-generated projects, this is done by including the following lines in the startup.s file:

 

#ifdef _ARMGNUCPP

    bl    __libc_init_array

#endif

 

And, in the compiler options for C++ projects, the following option is added:

image

 

 

So, the call to __libc_init_array is only made for C++ projects.