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.

Trouble with TMS470 |Linker v4.6.6

    We use the CCS v4 to build our project for the OMAP3530 device.
Our code generation tools version is 4.6.6. We use the EABI mode.
After building the project we use the hex470.exe utility to create a *.bin file.
To reduce the size of the *.bin file I order the sections in the *.cmd linker file
so that all uninitialized section were at the end of the resulting out file.
If I do not use the GROUP statement my .bss and .sysmem sections in
the out file become UNINITIALIZED. I see it in the *.map file and it is what I want.
But in this case the linker uses the default section allocation algorithm that
places sections by size and .bss and .sysmem section appear in the middle
of the other output sections. Unfortunately, the 4.6.6 version linker does not
support the shell key --default_order to return to the previous section allocation
algorithm, that places output sections in the order in which they are specified
in the linker command file SECTIONS directive.
    I have read on Your ftp://ftp.ti.com/... resource, that now to place sections in
the particular order, I have to use the GROUP statement. I tried to use it
and included all the sections in the GROUP statement. All sections appeared
in the correct order after that. But one interesting thing also appeared: .bss
and .sysmem sections became initialized. I decided so because the
UNINITIALIZED word disappeared opposite these sections in the *.map file
and their size in the column "init length" in the SEGMENT ALLOCATION MAP
portion of the *.map file became nonzero (for uninitialized sections this size is zero).

To sort this problem out I carried out a lot of experiments.
And I found out the following:
   (Please, keep in mind that this behavior is observed ONLY
when all the sections are included in a GROUP).

1. When the linker creates the .sysmem output section, it places
there 8 bytes from the memory.c file`s .sysmem input section
(the first PACKET structure). The remaining space
of (--heap_size - 8) bytes size the linker makes as a hole.

If in my linker command file I write only
SECTIONS
{
GROUP
{
...
.sysmem
...
} > MEMORY_RANGE
}
for the .sysmem output section, the .sysmem output section
appears initialized as a result and hex470 utility generates
raw data for it in the *.bin file.

If in my linker command file I write
SECTIONS
{
GROUP
{
...
.sysmem
{
*(.sysmem)
. += 0x7F8;
}
...
} > MEMORY_RANGE
}
for the .sysmem output section, the .sysmem output section
appears uninitialized as a result and hex470 utility does
not generate raw data for it in the *.bin file.
In this case the 0x7F8 is the size of the hole in the .sysmem
output section, because I use the --heap_size=0x800 option,
from which size the memory.c file`s *.sysmem input section
takes 8 bytes. (0x800 - 8 = 0x7F8).

2. If in my linker command file I write only
SECTIONS
{
GROUP
{
...
.bss
...
} > MEMORY_RANGE
}
for the .bss output section, the .bss output section
appears initialized as a result and hex470 utility generates
raw data for it in the *.bin file.

If in my linker command file I write
SECTIONS
{
GROUP
{
...
.bss
{
. = 0;
*(.bss)
}
...
} > MEMORY_RANGE
}
for the .bss output section, the .bss output section
appears uninitialized as a result and hex470 utility does
not generate raw data for it in the *.bin file.

Please, help me find the correct way to solve both problems
simultaneously:
1. Output sections must be placed in the order which I specify
in the linker command file SECTIONS directive.
2. Uninitialized sections must be placed at the end of the
output file (at the end of the resulting compiled address
space occupied by the program) and as a result uninitialized
sections must be cut off and not included in the *.bin file.

Thank You very much in advance!

P.S. Please, notice: if I do not use the GROUP statement all
becomes fine and .bss and .sysmem sections become
uninitialized. I do not do any other changes except
removing the GROUP and placing sections just inside the
SECTIONS statement. The only problem in this case is that
the output sections are placed by size and not in the order
I specified in the linker command file SECTIONS directive.
  • Ilya Sidorov said:
     If I do not use the GROUP statement my .bss and .sysmem sections in the out file become UNINITIALIZED. I see it in the *.map file and it is what I want. 

    Unfortunately, there is a bug in the linker where it doesn't always show an output section is UNINITIALIZED, even though it is.  Please try sectti from the cg_xml package.  You are likely to see output like this ...

                   Name : Size (dec)  Size (hex)  Type   Load Addr   Run Addr
    -------------------- : ----------  ----------  ----   ----------  ----------
                  .cinit :        192  0x000000c0  DATA   0x0000ec68  0x0000ec68
                   .text :      18032  0x00004670  CODE   0x00000000  0x00000000
                  .const :        257  0x00000101  DATA   0x00004670  0x00004670
                   .data :        608  0x00000260  UDATA  0x00004778  0x00004778
                    .bss :        656  0x00000290  UDATA  0x000049d8  0x000049d8
                 .sysmem :       8192  0x00002000  UDATA  0x00004c68  0x00004c68
                  .stack :      32768  0x00008000  UDATA  0x00006c68  0x00006c68
    
    ------------------------------------------------------------
    Totals by section type
    ------------------------------------------------------------
      Uninitialized Data :      42224  0x0000a4f0
        Initialized Data :        449  0x000001c1
                    Code :      18032  0x00004670
    

    A UDATA section is uninitialized.  That is more reliable.

    If you are still seeing unexpected initialization after that, then please show me the SECTIONS directive from your link command file.

    Thanks and regards,

    -George

     

  • Hello Georgem!

            You advised me to use the sectti from the cg_xml package.

            But in what part of the *.bin file construction process You propose to use this utility?

            To construct the *.bin file from the *.out file I use the standard post build step

        that involves the following files and utilities:

        1. tiobj2bin.bat - controls the post build step.

        2. ofd470.exe - creates the *.xml file from the *.out file.

        3. mkhex4bin.exe - creates the *.tmp file (a command file for the TI hex conversion utility) from the *.xml file.

        4. hex470.exe - creates the *.bin file from the *.out and *.tmp files.

            As I read in the sectti description, it extracts the information about each section in an *.out file.

            But as I see, the mkhex4bin.exe does not take the output of the sectti as an input.

            Thanks in advance,

                                           Ilya.

  • Use sectti on the .out file that is in the input to tiobj2bin.bat.  

    Thanks and regards,

    -George

  • Hi,

    I just read this post because I am experiencing the same problem.

    Isn't there any way at all we can define the section in the order we want ?

    I'm working on an omap L138 and I would like to build an image and reduce it the maximum I can. So I was thinking about putting all initialized sections up in memory contiguously.

    First I tried this :

     

    #define EXTERNAL_RAM_START			0xC0000000
    #define EXTERNA_RAM_SIZE   			128*1024*1024
    #define NOT_CACHEABLE_AREA_SIZE 	         1*1024*1024
    #define CACHEABLE_AREA_SIZE 		EXTERNA_RAM_SIZE - NOT_CACHEABLE_AREA_SIZE
    
    MEMORY
    {
    	DDR: 		o = EXTERNAL_RAM_START	l = CACHEABLE_AREA_SIZE
    	NO_CACHE:		o = END(DDR)		l = NOT_CACHEABLE_AREA_SIZE
    }
    
    SECTIONS
    {
    	GROUP >	EXTERNAL_RAM_START
    	{
    		.sect1
    		.intvecs
    	}
    
    	.cinit		>		DDR
    	.binit		>		DDR
    	.const		>		DDR
    
    	.switch		>		DDR
    	.text		>		DDR
    
    	.bss		>		DDR
    	.far		>		DDR
    	.stack		>		DDR
    	.svcstack 	>		DDR
    	.irqstack	         >		DDR
    	.fiqstack  	>		DDR
    	.data		>		DDR
    
    	.mmusetup		load = DDR, run = NO_CACHE, table(BINIT)
    	.mmutable	         >		NO_CACHE	ALIGN(0x4000)
    }
    
     

    But it does not respect the order, here is the map file of the code generated :

    SEGMENT ALLOCATION MAP
    
    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    c0000000    c0000000    00000004   00000004    rw-
      c0000000    c0000000    00000004   00000004    rw- .sect1
    c0000004    c0000004    00000030   00000030    r-x
      c0000004    c0000004    00000030   00000030    r-x .intvecs
    c0000034    c0000034    001360e8   00000000    rw-
      c0000034    c0000034    001360e8   00000000    rw- .bss
    c013611c    c013611c    0002b93c   0002b93c    r-x
      c013611c    c013611c    0002b93c   0002b93c    r-x .text
    c0161a58    c0161a58    00008000   00000000    rw-
      c0161a58    c0161a58    00004000   00000000    rw- .stack
      c0165a58    c0165a58    00004000   00000000    rw- .svcstack
    c0169aac    c0169aac    00002956   00002956    r--
      c0169aac    c0169aac    00002956   00002956    r-- .const
    c016c404    c016c404    00004000   00000000    rw-
      c016c404    c016c404    00002000   00000000    rw- .fiqstack
      c016e404    c016e404    00002000   00000000    rw- .irqstack
    c0170404    c0170404    0000046d   0000046d    rw-
      c0170404    c0170404    0000046d   0000046d    rw- .data
    c0170878    c0170878    00000280   00000280    r--
      c0170878    c0170878    00000270   00000270    r-- .cinit
      c0170ae8    c0170ae8    00000010   00000010    r-- .binit
    c7f00000    c7f00000    00004000   00000000    rw-
      c7f00000    c7f00000    00004000   00000000    rw- .mmutable
    c7f04000    c0169a58    00000054   00000054    r-x
      c7f04000    c0169a58    00000054   00000054    r-x .mmusetup
    


     And what bothers me is that there are uninitialized section between initialized. (This makes a bigger hex file when generating with hex470.exe)

    I tried using group from .sect1 to .data but get an error "fatal error #10333: illegal attempt to place ".cinit" before ".data" in "GROUP_1"".

    Well, so I tried some combination with GROUP but no success, either fatal error or not placed the way I want.

    The only way I can manage that is by adding HIGH on all the section from .bss to .data, it places everything at the end of memory but does seems like fiddling with to me.

     Is there any proper work around ?

    Thanks,

    Maxime

     

  • Maxime Renaudet said:
    Isn't there any way at all we can define the section in the order we want ?

    The GROUP operator is the only mechanism which controls the order in which output sections are allocated within the same memory range.  See this wiki article for more detail.

    Try this ... Put all the uninitialized sections together in a GROUP, then apply the HIGH operator to that GROUP.  Please let me know how this works out.

    Thanks and regards,

    -George