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.

Why when adding XDCTools HeapStd a new, hidden section is created?

Other Parts Discussed in Thread: SYSBIOS

Hello,

I am using Code Composer Studio version 5.5.00077, C6000 Bios version 6.35.4.50, C6000 Compiler version 7.4.11, and C6000 XDCTools version 3.25.4.88.  The IDE is running under Windows 7

My project is set up to use separate configuration project.

When I edit the configuration, and try to add HeapStd heap (under XDCTools->Memory Management->Heaps, right-click on HeapStd and select "Use HeapStd", the first item on the menu), development tools "automagically" add a new memory segment for me.   This memory segment is called  ".sysmem".  I can see it in the map file, but it does not show up in the configuration.   Here is an excerpt from my map file:

******************************************************************************
               TMS320C6x Linker PC v7.4.11                     
******************************************************************************
>> Linked Tue Nov 04 18:38:43 2014

OUTPUT FILE NAME:   <test.out>
ENTRY POINT SYMBOL: "_c_int00"  address: 8000a1a0


MEMORY CONFIGURATION

         name            origin    length      used     unused   attr    fill
----------------------  --------  ---------  --------  --------  ----  --------
  IRAM                  10800000   00020000  00000000  00020000  RW X
  L1DSRAM               10f04000   0000c000  00000000  0000c000  RW  
  SRAM                  42000000   00200000  00000000  00200000  RWIX
  DDR2                  80000000   08000000  0001bc68  07fe4398  RWIX


SEGMENT ALLOCATION MAP

run origin  load origin   length   init length attrs members
----------  ----------- ---------- ----------- ----- -------
80000000    80000000    0000d0a0   0000d0a0    r-x
  80000000    80000000    0000d0a0   0000d0a0    r-x .text
8000d0a0    8000d0a0    00008c10   00000000    rw-
  8000d0a0    8000d0a0    00008c10   00000000    rw- .far
80015cb0    80015cb0    0000233c   0000233c    r--
  80015cb0    80015cb0    0000233c   0000233c    r-- .const
80017ff0    80017ff0    00003000   00000000    rw-
  80017ff0    80017ff0    00002000   00000000    rw- .stack
  80019ff0    80019ff0    00001000   00000000    rw- .sysmem
8001aff0    8001aff0    0000056c   0000056c    rw-
  8001aff0    8001aff0    0000056c   0000056c    rw- .fardata
8001b560    8001b560    00000120   00000000    rw-
  8001b560    8001b560    00000120   00000000    rw- .cio
8001b800    8001b800    000005f0   000005f0    r-x
  8001b800    8001b800    00000200   00000200    r-x .vecs
  8001ba00    8001ba00    000003f0   000003f0    r-- .cinit


The side effect of this extra segment is somewhat mysterious.  Before adding HeapStd, memory allocations for malloc() and calloc() occured from SysBios HeapMem.  This heap was also automagically created, but was at least shown in the configuration editor when "Show Configuration Results" button was selected.  It was explicitly marked by the tiny lock icon, and usually has a name of the form "Instance#(number)".  I was able to observe and monitor this heap from the ROV, therefore having a debuggable system.

After I added HeapStd, the system automagically switched to using the hidded ".sysmem" segment (or a heap within it) for all malloc() and calloc() allocations.  This occurred even though I did not create any heaps of type HeapStd, just added the module.  This turned out to be somewhat wicked, since ".sysmem" does not show up in the ROV during debugging, and I spent a bit of time crawling over the configuration file and the map file before I spotted it, and realized that this is where allocations were made from.  It looks like the size of ".sysmem" is controlled by Heap Size parameter shown on Program configuration screen (xdc->cfg->Program in Configuration Results tree).

This behavior is somewhat unexpected, and, what is worse, it prevents me from monitor memory use with ROV.

I'd like to understand better what has happened, and whether it is safe to use HeapStd (at this time I switched to using HeapMem for all cases where I need to use malloc() and free()). 

Any explanations and clarifications would be very welcome.

Thank you in advance,


Dmitry.

  • Here is the project that can be used to demonstrate this issue:

    0654.test.zip

  • Dmitry,

    Thanks for all the details with your question, and for the example project.

    The .sysmem section comes in when you choose to use HeapStd, and the native malloc/free from the runtime support library.  There are a few mentions of this section in the compiler user guide (http://www.ti.com/lit/ug/spru187v/spru187v.pdf).

    Even though you haven’t done an explicit malloc, there may be some small amount of allocation done by the runtime at startup (e.g., for atexit() registrations).  And to support these boot time allocations, the .sysmem section will get allocated, even though you are not explicitly making any malloc calls from your application yet.

    And this section doesn’t show up in the configuration tool or in ROV, because it is not one of the SYS/BIOS or XDCTools components.  It would be nice to have this, but support for viewing the runtime library-generated section has not been implemented (and I don’t think there are any plans for this). 

    Hope this helps clarify.

    Is there a reason you don't want to continue to use HeapMem for malloc/free?

    Thanks,
    Scott

  • Scott,


    Thank you very much for your response.

    We initially wanted to use XDCTools and HeapStd because they appeared to be more portable and more "generic", higher-level solutions.


    Seeing as it is, we are sticking with HeapMem.

    Best Regards,


    Dmitry.