Tool/software: TI C/C++ Compiler
As part of my work with MathWorks Embedded Coder and Polyspace software verification tools, I often have questions related to the effects of warm-start vs. cold-start on global variable initialization. Here is an example:
int globA = 2;
int globB; % default to zero by ANSI C standard
int globC; % default to zero by ANSI C standard
int main() {
globC = 5;
return 0;
}
It is clear to me that globC will be properly initialized in all cases since it is explicitly initialized in the main. However, for the other two it is less clear. Based on the TMS320C2x Compiler User's Guide, I understand that the _c_int0() function copies all of the explicitly initialized data from .cinit to .bss during the boot process assuming that the linker has option -c to auto-initialize at run-time. This means that a warm start which relaunches from _c_int0() will initialize globA with the -c link option.
In section 5.7 of the Guide, we are told how you can use the linker command file to explicitly initialize the .bss section to zero. With the linker zeroing .bss and with option -c, I assume this will result in initialization at both warm and cold start for globB. Without the linker zeroing, there is only initialization for globB if provided by the loader and it would only be for a cold start.
Finally, with the linker using the -cr option, there would only ever be cold start initialization for globB and globC. This situation removes the mechanism for warm start initialization.
Is this understanding correct? Where can I find more resources on this behavior?