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.

Compiler: F280049: Need to get image size



Tool/software: TI C/C++ Compiler

Hi,

I need for the TI compiler/linker to provide the size of the build code image.

I guess this can be done by placing the 'proper' line in the linker command file (.cmd file).

I need for my code to be able to read it's own code size, so I imagine that this can be done by, in the linker file, creating a 'variable' e.g image_size to be placed (in a section) at an absolute place

and for the linker command file to set image_size = total size of the image.

Pls advise

Regards

Martin Rohde

  • There is a way to do it. It is straightforward, though there are a few steps to it.

    First, understand which output sections in your program contain code. To understand what I mean by that, please read the first part of the article Linker Command File Primer.

    Next, make some changes in the linker command file. For every output section that contains code, use the SIZE operator to assign the size of that section to a symbol. Learn about the SIZE operator by searching the C2000 assembly tools manual for the sub-chapter titled Address and Dimension Operators.  Then, towards the end the file, add all those symbols together and assign to another symbol. This symbol can be referred to from your program.

    Here are some example lines for the linker command file changes …

    #ifdef __TI_COMPILER_VERSION__
       #if __TI_COMPILER_VERSION__ >= 15009000
        .TI.ramfunc : {} > RAML0,      PAGE = 0, SIZE(ramfunc_size)
       #else
       ramfuncs         : > RAML0,     PAGE = 0, SIZE(ramfunc_size)
       #endif
    #endif   
    
       .text            : > RAML1,     PAGE = 0, SIZE(text_size)
    
    /* Many lines later */
    
    total_code_size = text_size + ramfunc_size;

    To understand how to use a linker created symbol from C code, please search the C2000 assembly tools manual for the sub-chapter titled Using Linker Symbols in C/C++ Applications.

    Thanks and regards,

    -George