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.

CCS/TMS320C6678: How project setting "place each function in a separate subsection" optimizes memory usage

Part Number: TMS320C6678

Tool/software: Code Composer Studio

Hi

By enabling the setting "place each function in a separate subsection", I can observe that functions in one single source file are allocated separate memory segments and the total memory allocated to each source file can either increase or decrease. However, it seems the total size of the project can be reduced.

I understand that some memory is optimized by removing unused functions but for my case, the size of removed functions only 20 bytes while I got in total 416 more bytes.

Can anyone provide any explanation or related documents on how reorganizing functions  optimizes memory usage?

The reason I ask this question is that I found functions missing in .map file after I enable the setting but I confirmed these missing functions are actually used in the project.

Thanks in advance

Regards

Siyuan

  • Siyuan Feng said:
    the size of removed functions only 20 bytes while I got in total 416 more bytes.

    I think I can tell you what happened if I can see your linker command file.  Please attach it to your next post.  So the forum will accept it, add the file extension .txt to it.

    Siyuan Feng said:
    I found functions missing in .map file after I enable the setting but I confirmed these missing functions are actually used in the project.

    If you are missing functions, then you will get error messages when you link.  I presume you did not see any error messages.  So, I cannot explain this.

    Thanks and regards,

    -George

  • Dear George

    George Mock said:

    If you are missing functions, then you will get error messages when you link.  I presume you did not see any error messages.  So, I cannot explain this.

    Thanks and regards,

    The functions are just missing in the .map file but the functionality is still there. I suspect they may be merged to the function which calls them but the size of preceding functions does not increase.

    George Mock said:
    I think I can tell you what happened if I can see your linker command file.  Please attach it to your next post.  So the forum will accept it, add the file extension .txt to it.

    Please find the attached file.

    Thanks

    user_linker.txt
    /*
     * Do not modify this file; it is automatically generated from the template
     * linkcmd.xdt in the ti.targets.elf package and will be overwritten.
     */
    
    /*
     * put '"'s around paths because, without this, the linker
     * considers '-' as minus operator, not a file name character.
     */
    
    SECTIONS
    {
    	.oca_code: load >> OCALOCAL
    	{
    		-l"Core_WCL.lib"(.text)
    		-l"OCAUtil.lib"(.text)
    		-l"EasiCtrl.lib"(.text)
    	}
    	.oca_data: load >> OCALOCAL
    	{
    		-l"Core_WCL.lib"(.near)
    		-l"Core_WCL.lib"(.far)
    		-l"Core_WCL.lib"(.neardata)
    		-l"Core_WCL.lib"(.fardata)
    		-l"OCAUtil.lib"(.near)
    		-l"OCAUtil.lib"(.far)
    		-l"OCAUtil.lib"(.neardata)
    		-l"OCAUtil.lib"(.fardata)
    		-l"EasiCtrl.lib"(.near)
    		-l"EasiCtrl.lib"(.far)
    		-l"EasiCtrl.lib"(.neardata)
    		-l"EasiCtrl.lib"(.fardata)
    	}
    	.oca_shared: load >> OCASHARED
    	.oca_ext: load >> OCAEXT
    }
    
    /*SECTIONS
    {
    	.oca_code: load >> OCALOCAL
    	{
    		-l"RTMLib.lib"(.text)
    		-l"OCAUtil.lib"(.text)
    		-l"RTMLib.lib"(.switch)
    		-l"OCAUtil.lib"(.switch)
    	}
    	.oca_data: load >> OCALOCAL
    	{
    		-l"RTMLib.lib"(.near)
    		-l"OCAUtil.lib"(.near)
    		-l"RTMLib.lib"(.far)
    		-l"OCAUtil.lib"(.far)
    		-l"RTMLib.lib"(.neardata)
    		-l"RTMLib.lib"(.fardata)
    		-l"OCAUtil.lib"(.neardata)
    		-l"OCAUtil.lib"(.fardata)
    	}
    	.oca_shared: load >> OCASHARED
    	.oca_ext: load >> OCAEXT
    }*/

  • Unfortunately, I'm still unsure about why your code got smaller.

    I'd appreciate if you would send me more data to analyze.  This data will include a list of all the functions and their sizes.  It is easy to generate this data with the object file display utility ofd6x.  The compiler option which puts each function into a separate subsection is --gen_func_subsections.  Build your project two times.  Once with that option, and once without it.  Each time, gather the data with a command similar to  ...

    ofd6x --func_info final_executable_file.out > function_data.txt

    The data in the file function_data.txt is in comma separated values (CSV) format.  It can be loaded into Excel, or otherwise processed, to work out what changed between the two builds.

    Attach both of the data files to your next post.

    Thanks and regards,

    -George

  • Thanks for your help but I cannot pass the files to you.

    I will try to find some ways to resolve it.

    Thanks

    Regards

    Siyuan