This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Would it be possible to automatically direct all of the constants in a particular file to a section that is not .const?
In a particular file, I want the compiler put the constants into a new section called .const2 while still putting the constants in the rest of the project into .const as it normally does.
Please note, I want to do this without manually placing the constants in a struct/variable and placing them in a new location with pragma. This method is tedious, error-prone and can easily brick my boards when trying to upgrade in the field using a serial port with a legacy tool.
Any suggestions?
Are you willing to do it in the linker command file? Add an entry to the SECTIONS directive modeled on:
special_constants { filename.obj(.const) } > SPECIAL_MEMORY
For more background on this syntax, please see this wiki article.
Thanks and regards,
-George