I would like to put initial values of global variables in ROM section, and then, relocate their addresses and copy their values to RAM (so it can be edited by the program).
My linker script SECTIONS:
/* code */.text :{ __text_start = .; *(.text) __text_end = .;} > ROM/* Initialized global and static variables */.data : AT ( __text_end ){ __data_start = . ; *(.data); __data_end = . ; } > RAM
My Boot ROM code:
int global_var = 0xAAA;void main(){ global_var = 0xBBB;}
The problem: The initial value 0xAAA
is located at RAM
address in the compiled bin file instead of ROM
How can I define initial .data values in ROM, and then relocate their address to RAM?
Thank you for your help