SPRU514Z July 2001 – October 2023 SM320F28335-EP
This section applies to applications that use the COFF ABI only.
Some global variables must have initial values assigned to them before a C/C++ program starts running. The process of retrieving these variables' data and initializing the variables with the data is called autoinitialization.
The compiler builds tables in a special section called .cinit that contains data for initializing global and static variables. Each compiled module contains these initialization tables. The linker combines them into a single table (a single .cinit section). The boot routine or a loader uses this table to initialize all the system variables.
In ANSI/ISO C, global and static variables that are not explicitly initialized must be set to 0 before program execution. The C/C++ compiler does not perform any preinitialization of uninitialized variables. Explicitly initialize any variable that must have an initial value of 0.
The easiest method is to have a loader clear the .ebss or .bss section before the program starts running. Another method is to set a fill value of 0 in the linker control map for the .ebss or .bss section.
You cannot use these methods with code that is burned into ROM.
Global variables are either autoinitialized at run time or at load time; see Section 7.10.3.2 and Section 7.10.3.3. Also see Section 6.13.