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.

Data Variables Grouped in .common Section in CCS for ARM



I'm using CCS's ARM compiler tools v5.1.9 and I am trying to analyze the memory usage of an application using the compiler-generated map file. In the map file there are several data variables grouped together in a .common section. In the source code these variables are located in several different files and every variable is static. Not all static variables are organized like this, I'm not sure how the compiler decides which variables are grouped in the common section and which are kept with their object file. I searched in my linker's command file and did not find any instances of the string "common".

Is there any way to specify to the compiler to keep these variables in their respective object file and to not group them in a common section?

  • I presume you overall goal is ...

    Samuel said:
    to analyze the memory usage of an application

    A basic process of the linker is collecting together input sections from multiple object files and libraries into an output section.  This process is not unique to common variables.  More details on this topic are in this wiki article.  

    To analyze memory usage, use the utility sectti from the cg_xml package.  That is a command line utility you invoke on the final .out file.  It looks something like this ...

    % armofd -x final.out | sectti
    Reading from stdin ...
    
    ************************************************************
    REPORT FOR FILE: final.out
    ************************************************************
                    Name : Size (dec)  Size (hex)  Type   Load Addr   Run Addr
    -------------------- : ----------  ----------  ----   ----------  ----------
                   .text :      12692  0x00003194  CODE   0x00000020  0x00000020
                  .const :        257  0x00000101  DATA   0x000036b0  0x000036b0
                   .data :        816  0x00000330  UDATA  0x000031b8  0x000031b8
                    .bss :        456  0x000001c8  UDATA  0x000034e8  0x000034e8
                  .cinit :        208  0x000000d0  DATA   0x000047b8  0x000047b8
                  .stack :       2048  0x00000800  UDATA  0x000037b4  0x000037b4
                 .sysmem :       2048  0x00000800  UDATA  0x00003fb8  0x00003fb8
    
    ------------------------------------------------------------
    Totals by section type
    ------------------------------------------------------------
      Uninitialized Data :       5368  0x000014f8
        Initialized Data :        465  0x000001d1
                    Code :      12692  0x00003194
    

    Thanks and regards,

    -George

  • Is there anything wrong with using the map file to analyze the memory usage?

    Thanks for referring me to the cg_xml_package, but I'm looking for more details than this tool appears to provide. Specifically I want to know the exact memory usage, code, const, and data, for any specific file, not just for the whole application. I don't see any examples to do this in any of the links you provided. In addition, it would be nice to know which variables belong to which object files. I also don't see any examples of doing this either in any of the links you provided.

    Thanks,
    Samuel
  • Samuel said:
    Is there anything wrong with using the map file to analyze the memory usage?

    No.  Just expect that an output section will contain contributions from many object files and libraries.

    If you plan to do this automatically, I highly suggest you process the XML form of the linker map file that is produced with the linker option --xml_link_info.  Examples of processing that file can be found in the \map directory of the cg_xml installation.

    Samuel said:
    I want to know the exact memory usage, code, const, and data, for any specific file, not just for the whole application.

    You can apply sectti to individual object files and libraries.  However, this can be misleading.  The linker uses only the library members it needs.  Parts of object files can be discarded.  So looking at the final executable is the best way to see actual memory usage.

    Samuel said:
    it would be nice to know which variables belong to which object files

    Use the names utility armnm.  Like sectti, it can be used on object files or the final executable.  Read about it in the ARM assembly tools manual.

    Thanks and regards,

    -George