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.

Sizing link section with global variable

Hi,


I'm trying to implement a redundancy mechanism in RAM.
For that, I use several identical memory sections, and duplicate data from the first one to the others.

With the TI compiler, I'm unable to define the sections to the appropriate size as I want to.
I usally affect my variables to the first section, then have the linker create the mirrors at the same size as it has dynamically allocated for the first one.
According to linker datasheet, I need to create holes in the mirror sections ( that I would size with the expression . += size )
which would give something like this:

   ZONE1_SECTION :  { *(ZONE1_SECTION) } > RAM, RUN_SIZE( Zone1Size )
   ZONE2_SECTION :  { . += Zone1Size } > RAM

Unfortunately, that kind of tries gives me an error, saying my Zone1Size variable is used in ZONE2_SECTION before it is initialized.

This means the variable created by the linker has a section-limited scope.
However the linker datasheet (SLAU131I) states that linker "expressions can contain global symbols". So i'm wondering if there is a way to declare the Zone1Size symbol at a global level and then use it successfully. I understand that the SIZE operator already produces a symbol that is global for my C code, still it is not understood by the next linker section.

If anyone has an idea to go around that problem...

  • There is no method to make the size of one output section match the size of another.  You can use global variables as operands in expressions, but only if those variables are well defined.  That is not the case with Zone1Size.  Zone1Size does not become well defined until all the ZONE1_SECTION input sections have been seen.  And that cannot be determined until all the files have been processed.

    Thanks and regards,

    -George