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.

Specifying section location in CCS4

CCS4.2

SYS/BIOS 6.31.02.23

XDCtools 3.20.07.86

 

In a SYS/BIOS project, how do I force the linker to generate the output sections from my code in the order that I specify?

For example, I want the following sections to be in contiguous memory order:

  .text:_c_int00

  .text

  .cinit

  ...

  .data

 

The default settings place the segments in a different order.  I can put every setting into it's own memory section, but that relies on me to continually change my sections sizes and addersses as I develop the code.

 

I've tried some of the options as described in sections 5.3.1 and 5.3.2 in the Bios_User_Guide without much luck.

When I exclude the sections with by adding a Program.sectionsExclude = "*" to the CFG file I get similar results.

 

Thanks,

  Peter Steinberg

  • Peter,
    when you specify Program.sectionsExclude, you are supposed to supply section allocations in your own linker command file or in a template file specified by Program.sectionsTemplate (http://rtsc.eclipse.org/cdoc-tip/xdc/cfg/Program.html#sections.Template). Have you done that?
    BTW, the regular expression for all sections is Program.sectionsExclude = ".*"

    Once you have supplied your section allocation ordering the sections the way you want it, the linker should allocate the sections in the order you listed them. I haven't tried it, but I have found this in the linker docs (SPRU 186S):

    7.7.2 Reducing Memory Fragmentation
    The linker's allocation algorithm attempts to minimize memory fragmentation. This allows memory to be used more efficiently and increases the probability that your program will fit into memory. The algorithm comprises these steps:
    1. Each output section for which you have supplied a specific binding address is placed in memory at that address.
    2. Each output section that is included in a specific, named memory range or that has memory attribute restrictions is allocated. Each output section is placed into the first available space within the named area, considering alignment where necessary.
    3. Any remaining sections are allocated in the order in which they are defined. Sections not defined in a SECTIONS directive are allocated in the order in which they are encountered. Each output section is placed into the first available memory space, considering alignment where necessary.

  • Hi Peter --

    Have you tried the "GROUP" directive which can be used to group linker sections?

    search for "GROUP" on this wiki page: http://processors.wiki.ti.com/index.php/Code_Generation_Tools_FAQ (which I found with google search "GROUP TI")

    and you'll find:

    group the sections as per order I listed them in. The GROUP directive is the only directive in the linker to force ordering. Simply listing sections does not guarantee that the linker will allocate them in the order you desire. In fact the linker typically allocates the largest sections first in an effort to minimize potential memory map holes.

    I recently found that you can add your own linker.cmd file to a project and add your section placement there.  You need to make sure that your linker.cmd file is linked first to override the placement in the generated .cmd file.   I added a couple slides to show how to specify linker .cmd ordering in CCSv4.

    http://e2e.ti.com/support/embedded/f/355/p/91081/319948.aspx#319948

    -Karl-

  • I had it as ".*", I mistyped it above.

    I supplied my own cmd file with:

    SECTIONS {

      .text:_c_int00:  {} > MYRAM

      .text:           {} > MYRAM

      .cinit:          {} > MYRAM

      ...

      .data:           {} > MYRAM

    }

    and get the same results.

     

    I do not want to calculate absolute locations for my code to use a specific binding address as in 7.7.2 (1) and (2); that is the job of the compiler / linker.

    I want my sections in specific memory areas.  How do I do that if they are not specified in a SECTIONS block (as in 7.7.2 (3)).

     

    Section 7.5.4.3 specifies that it will reorder my sections from largest to smallest, and that is the result that I appear to get.



  • Peter,
    I think I misread that section from the documentation. Karl's explanation is most likely the right one. I just wanted to verify that you are using the right values for your configuration parameters, so that you can supply your own linker command file.

    If the solution that Karl is proposing does not work for you, you should move this thread to the compiler forum. Someone from the compiler team may have a solution.

  • I'm able to use the GROUP directive to get the results I'm looking for.

     

    Thanks for the quick answer.

     

    Peter