In Renesas/Mitsubishi M32R Family based system, linker puts initialized global variables in section ROM_D. At run-time these globals variables need to be copied to section D of RAM. This copying can be described in 'C' language because linker automatically generates the labels which indicate the start and end address of each section. For example, label __TOP_ROM_D is generated to specify the start address of initialized global variables in ROM.
PLEASE CORRECT ME IF I'M WRONG. First I'll extern these labels as follows:
extern unsigned char __TOP_D; /* Starting address of initialized global variables in RAM */
extern unsigned char __TOP_ROM_D; /* starting address of initialized global variables in ROM */
extern unsigned char __END_D; /* Ending address of intialized global variable in RAM */
Then, I'll copy from ROM to RAM as follows:
memcpy(__TOP_D, __TOP_ROM_D, __END_D - __TOP_D);
Please use attach link to refer to linker manual for more information. In particular, see sections 5.1 and 5.2.3 and Figures 5.1 and 5.2.