Кстати, вот что keil пишет в своём руководстве How to prevent uninitialized data from being initialized to zero
ARM Compiler toolchain v4.1 for µVision Using the Compiler
Home > Compiler Coding Practices > How to prevent uninitialized data from being initialized to zero
How to prevent uninitialized data from being initialized to zero
The ANSI C specification states that static data that is not explicitly initialized, is to be initialized to zero. Therefore, by default, the compiler puts both zero-initialized and uninitialized data into the same ZI data section, which is populated with zeroes at runtime by the C library initialization code.
You can prevent uninitialized data from being initialized to zero by placing that data in a different section. This can be achieved using #pragma arm section.
Example 19. Retaining uninitialized data using #pragma arm section
#pragma arm section zidata = “non_initialized”
int i, j; // uninitialized data in non_initialized section (without the pragma,
would be in .bss section by default)
#pragma arm section zidata // back to default (.bss section)
int k = 0, l = 0; // zero-initialized data in .bss section
The non_initialized section is then placed into its own UNINIT execution region:
LOAD_1 0x0
{
EXEC_1 +0
{
* (+RO)
* (+RW)
* (+ZI) ; ZI data gets initialized to zero
}
EXEC_2 +0 UNINIT
{
* (non_init) ; ZI data does not get initialized to zero
}
}