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: CCS linker command syntax (fill, align(0x10)....)

Tool/software: Code Composer Studio

Dear all experts,

I am learning CCS linker commad file editing.

I have read some instructions from internet, and can understand most commands.

I just got a command file sample and can not understand some syntax in it?

Coulds you help to explane what it means? 

The commands are as below, thanks for your kind help

.stack  {} > IRAM,fill=00c0ffeeh,align(0x10)     >> What does fill=00c0ffeeh and  align(0x10) mean

and what doese the following mean?

.IRAM_Heap: fill=00c0ffeeh {
    _IRAMHEAP_base = .;
    . += 0x2000;    
    _IRAMHEAP_end = .;            
  } > SIRAM,align(0x10)

Thanks a lot !

  • For an introduction to linker command files, please see the article Linker Command File Primer.

    Regarding ...

    Jason Liu4 said:
    .stack  {} > IRAM,fill=00c0ffeeh,align(0x10)

    This forms an output section named .stack.  It is made up of all the input sections also named .stack.  In this particular case, there is (almost certainly) only one input section named .stack.  It is allocated to the memory range named IRAM.  Because of the align(0x10), the address chosen in IRAM is an even multiple of 0x10.  Normally, this section is uninitialized.  But because of the fill=00c0ffeeh, it is an initialized section where every 32-bit wide memory location contains the value 0x00c0ffee.  Typically, this is done to see how much the stack the application uses while running.

    Regarding ...

    Jason Liu4 said:
    .IRAM_Heap: fill=00c0ffeeh {
        _IRAMHEAP_base = .;
        . += 0x2000;    
        _IRAMHEAP_end = .;            
      } > SIRAM,align(0x10)

    The overall effect is to create an initialized output section named IRAM_Heap that is filled with 0x00c0ffee.  Details ...

    This forms an output section named IRAM_Heap.  It is made up of all the input sections also named IRAM_Heap.  However, there are no input sections with that name.  The . += 0x2000 says to create a hole of that many bytes starting at that point in the output section.  In this particular case, that point is the beginning of the section.  It is allocated to the SIRAM memory range.  The align(0x10) and fill=00c0ffeeh work the same as with .stack.  The two assignment statements assign the address, at that point in the output section, to those symbols.  In this case, those symbols capture the beginning and ending address of the section.  

    Thanks and regards,

    -George

  • Dear George

    Thank you very much for your great help !
    After reading your reply, I got more concepts about Linker Command Files.
    Excuse me, may I ask for more detail? expecially on align(0x10) and fill


    About align(0x10):
    In what case we should use align(...), is that for certain purpose?
    If the original linker command file contain align(0x10), may I just delete it? What happens if I delete it without considering the details?

    About fill=00c0ffeeh, you said that it is an initialized section where every 32-bit wide memory location contains the value 0x00c0ffee.
    I think I didn't catch it, cluld you explain more? Do you mean that every 0xffffffff bytes memory length contains the value 0x00c0ffee?
    You said that "Typically, this is done to see how much the stack the application uses while running.", May I know how ?
    Can I use fill=.... to check wheter stack overflow occurs? The same, What happens if i delete it without considering the details?

    Thanks a lot for your kindly help !

  • Jason Liu4 said:
    In what case we should use align(...), is that for certain purpose?

    Alignment is typically related to some requirement of the CPU.  Certain instructions which read from memory may require the address be aligned to a certain boundary.  Or, the beginning of a function may be required to be aligned to a certain boundary.  Or, other things like that.

    Jason Liu4 said:
    If the original linker command file contain align(0x10), may I just delete it?

    You need to understand why that alignment is necessary, and whether that situation still applies to your system.  

    Jason Liu4 said:
    What happens if I delete it without considering the details?

    The system might fail while running.  Such problems are often very hard to diagnose.

    Jason Liu4 said:
    Do you mean that every 0xffffffff bytes memory length contains the value 0x00c0ffee?

    Yes

    Jason Liu4 said:
    You said that "Typically, this is done to see how much the stack the application uses while running.", May I know how ?

    While running the code under control of the debugger, open a view into memory for the stack.  See where it stops showing 0x00c0ffee.  

    Note filling the stack is only a debug technique.   Don't do it in your final production build.

    Thanks and regards,

    -George

  • Dear George

    Thank you very much.

    Your reply resolved my question. I understand now.

    Thank you for your great help ! Thanks !

    Best regards,

    Jason