24Fermer26
PpHdLe 20/04/2010 à 22:03
christop (./24) :

Which is it? Are initialized global variables put in the .data section, and is the .data section in RAM or FlashROM?

If an initialized global variable is in RAM, where is its initialized value stored? Would I have to write startup code to copy the initial values from FlashROM to the appropriate locations in RAM?
On the other hand, if the .data section is stored in FlashROM, are there plans to add an option to the linker to put it in RAM, like with BSS?


They are put in .data section which is stored in flash for a FlashOS target (Mainly for historical reasons where .text and .data sections where more or less used to store code).
Because of the fact that we are talking about a Flash Os which should assume that the RAM is not initialized when it boots and its job to initialize everything,
I don't think it is possible to initialize a value stored in .data for a flash os, in a simple way; and I even don't know if it has a meaning.
Even if we put an option to put the .data section in RAM, it won't work without the help of the written OS so what can we do?
Maybe duplicating the data in RAM and in flash, and let the OS initialize it with the requested values at startup by exporting additional symbols by the linker?
For me, the simpler thing is to write an initialize function which initializes the variables to their values at startup, which is a more elegant design too.