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.

COFF flags for heap sections



 

Hi,

I'm in the process of moving a set of applications from cgt v6.0.8 to v7.2.0, and have noticed some subtle differences in how the resulting COFF files are generated.  For the moment, the applications need to be built as "Legacy COFF" files (aka "COFF1" -- spraa08).  The differences lie in the way that the sections are flagged.  Specifically, the sections that have been reserved for the heap.  Previously, these sections had no flag set, whereas with v7.2.0 the heap sections are marked as BSS, which, if I'm understanding things correctly, indicates that they should be zeroed before run-time:

From cgt v6.0.8

<10> ".DDR2_HEAP$heap"

       Load Address:        0xe1000000  Run Address:        0xe1000000

       Size:                117440512   Alignment:          1         

       Loaded Onto Device:  Yes         Address Unit Size:  8 bits    

       File Offset:         0x00000000  # Relocs:           0         

       Reloc File Offset:   0x00000000  # Lines:            0         

       Line File Offset:    0x00000000  TI-COFF s_flags:    0x00000000

 

From cgt v7.2.0

 

    <8> ".DDR2_HEAP$heap"

       Load Address:        0xe1000000  Run Address:        0xe1000000

       Size:                117440512   Alignment:          1         

       Loaded Onto Device:  Yes         Address Unit Size:  8 bits    

       File Offset:         0x00000000  # Relocs:           0         

       Reloc File Offset:   0x00000000  # Lines:            0         

       Line File Offset:    0x00000000  TI-COFF s_flags:    0x00000080

       TI-COFF s_flag:      STYP_BSS  

 

 

The reason that this is important to me is that, as part of our boot-up sequence, we rely on keeping that heap section uninitialized.  So, I'd be interested to know more about this change.  Does this conform to some sort of standard?

At any rate, to solve this issue, one potential option is for me to strip out or modify the heap sections from the COFF file altogether.  Our COFF loader can then remain unchanged, which is preferable.  I'd like to know if there are ways to configure the way the linker constructs sections within the COFF file.  For instance, is it possible to instruct the linker to give the heap sections a specific flag set, or better yet can we have it exclude sections for us?  If none of those options are available, are there some reliable means that I can use to identify heap sections within a COFF so that I might strip them out myself?  Are they given a standard label, or something like that?

Thanks for your help,

_matt

 

  • The STYP_BSS flag does not mean the section should be initialized to 0.  In spraa08 it says the "Section contains uninitialized data".  That this heap section had no flags at all is a bug.  The bug may be in the linker or in how BIOS created the heap.  At any rate, it is fixed now.  It is your loader which is incorrect about the handling of STYP_BSS sections.  Unfortunately, the no flags bug masked the bug in your loader.  I understand your reluctance to change your loader.  But I don't see any other alternative.

    Thanks and regards,

    -George

  • OK. Thanks for the information George.