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.

CGT 7.2.0B2 Linker Problem with Assigning Symbols at Link Time

With previous versions of the Code Generation Tools on CCS previous to 5, I have been able to include lines such as

_new_symbol = .;

into a link cmd file to make addresses visible to my application source code.

However now when I try it with the 7.2.0B2 version of the tools I get an error message, for instance the following fragment of a link cmd file:

SECTIONS
{
    .text       >       IRAM

    _HeapBase = .;
    .IRAM$heap    > IRAM
    _HeapLimit = .;
    .stack      >       IRAM
    .args       >       IRAM

 
    GROUP
    {
            
            .neardata   /* Move .bss after .neardata and .rodata.  ELF allows */
            .rodata     /* uninitialized data to follow initialized data in a */
            .bss        /* single segment. This order facilitates a single    */
                        /* segment for the near DP sections.                  */
    }>IRAM

    .cinit      >       IRAM
    .cio        >       IRAM
    .const      >       IRAM
    .data       >       IRAM
    .switch     >       IRAM
    .sysmem     >       IRAM
    .far        >       IRAM
    .fardata    >       IRAM
    .ppinfo     >       IRAM
    .ppdata     >       IRAM, palign(32) /* Work-around kelvin bug */
    
    EMIFA_CE3_SPACE        >         EMIFA_CE3
    EXTERNAL_MEMORY0     >         DDR2     
    PCIConfig             >         PCI_CONFIG
    EMIFAConfig         >         EMIFA_CONFIG
    DDR2Config             >        DDR2_CONFIG
}

give me

"../lnk.cmd", line 21: error: expecting output section, GROUP, or UNION instead    of "="
"../lnk.cmd", line 23: error: expecting output section, GROUP, or UNION instead    of "="

line 21 being "    _HeapBase = .;"

& line 23 being "    _HeapLimit = .;"

Has the syntax of the assignment statement changed? 

BR

Paul

  • Change this ...

    Paul Bray said:
       _HeapBase = .;
        .IRAM$heap    > IRAM
        _HeapLimit = .;

    to ...

       .IRAM$heap    > IRAM, START(_HeapBase), END(_HeapLimit)
    

    Thanks and regards,

    -George

  • Hi George,

    The linker is happy with that, but when I try to reference the symbols in my source code I get a new error:
      For instance:

    "relocation type is static base-relative, but references symbol "_HeapBase" defined in section ".IRAM$heap"; references to section ".IRAM$heap" are not relative to any static base, so this relocation cannot be performed (type = 'R_C60BASE' (80),"

    From code fragment:

        {
            extern char HeapBase;
            extern char HeapLimit;

            printf("\n\n 0x%08x:0x%08x", &HeapBase, &HeapLimit);
            
        }

    Is it possible to get the addresses in my code, I'm sure I've done this with older versions of the CGTs?

    Regards


    Paul

  • Interestingly the linker is happy with this:

         DUMMY_SDRAM_SECTION1: {
            _HeapBase1 = .;
         } > IRAM
        .IRAM$heap    >         IRAM, START(_HeapBase), END(_HeapLimit)
         DUMMY_SDRAM_SECTION2: {
            _HeapLimit1 = .;
         } > IRAM

    so the symbol = .; syntax is useable.

    I still see the relocation cannot be performed warnings though when I try to find the addresses.

  • You need to use far:

        extern far char HeapBase;
        extern far char HeapLimit;

  • That does solve my outstanding problem.  Fairly obvious I guess.

    Thanks George and Archaeologist.

    Regards

    Paul