Microcontroller Memory Allocation – Linker Script and Data Allocation

bootloadermemorymicrocontrollerrom;

I know that .data will be in the RAM, but I came across article that says during boot of an micro-controller the initial value of variables is stored in the ROM and then the boot-loader copy the initial values of variables from ROM to RAM, Is this true!?

Best Answer

Ask yourself how could the system work if it isn't true?

In most implementations, the .data segment is for initialized data, where .bss is for data that is set to zero. You can't count on RAM being set to anything at all on power-up, so the processor has to zero out the .bss segment and initialize .data.

Usually this is done by storing an image of the start-up value of the .data segment in ROM, and copying it to the correct location in RAM on startup.