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.

How do I break up the .const section?

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

  • My friend,

    You sir, are dynamic and magical. I will test this now and if it does what I poorly described above, I will click the "Verify Answer" so hard that I will need to replace parts on my desk.
  • Yup, that did it.

    10/10

    special_constants
    * 0 002028a8 00000154
    002028a8 000000e0 BootLoader_M3.obj (.const:WildBill)
    00202988 00000074 BootLoader_M3.obj (.const:LoaderConst)