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.