I'm working with an ARM Cortex-M4 using the TI CGT tools. I'm working with a large set of legacy code that has a lot of global initialized data that is never changed at run time and would otherwise be marked as "const". The issue is that there are so many globals, we are looking to use a section pragma "SET_DATA_SECTION("mysect") on whole files to relocate its structures to FLASH at link time in order to save precious RAM. Yes, I know the propper fix is to add the const attibute to each global object, but there are so many of them, we are trying to save some effort.
So we have some code like such:
#pragma SET_DATA_SECTION("mysect") int var1 = 2; int var2 = 4; int var3 = 5; ...etc...
Next in our linker script I tried something like:
SECTIONS { ... mysect : LOAD = FLASH_CODE ... }
This does not seem to work, and after reviewing the following Wiki pages, I could not find a solution:
What I need to have the linker do is put the constant data into FLASH when the *.out file is loaded, yet I need to make sure that it is not initialized like a .data section would be in the C run time startup.
Thoughts?
Stuart