What is the difference between the Data and BSS sections?
BSS refers to uninitialized global and static objects and Data refers to initialized global and static objects. Both BSS and Data usually refer to RAM objects. The .bss and .ubsct (zero page BSS) sections are used to reserve space for uninitialized global and static objects (variables) which will be zero upon entering main. The .data and .bsct (zero page data) sections are used to reserve space for initialized global and static objects. If automatic data initialization is used, the linker relocates the .data and .bsct images and locates them in ROM to be copied back into RAM at startup. See the section Automatic Data initialization in the User’s manual for details.
unsigned char var; // 8 bit variable uninitialized variable allocated into the .bss section.
static int svar; // 16 bit static uninitialized variable allocated into the .bss section.
unsigned char var2 = 25; // 8 bit initialized variable allocated into the .data section.
static unsigned int svar2 = 3; // 16 bit initialized variable allocated into the .data section.