Using TI ARM CGT v5.2.4 was attempting to force the placement of output sections such that:
a) All the initialized sections are consecutive in memory, to reduce the size of the .bin file.
b) The entry point (in section .text:Entry) is at the start of the memory region, to give a known entry point address for the boot-loader.
The initial attempt was to create a single GROUP in the linker command file to order the initialized sections followed by uninitialized sections:
SECTIONS { GROUP { /* Initialised sections */ .text:Entry .text .const .cinit /* Uninitialised sections */ .bss RUN_START(bss_start) RUN_END(bss_end) .stack } > L3OCMC0 }
However, this caused the link to fail with:
Building target: sdram_test.out
Invoking: ARM Linker
"/opt/ti/ti_ccs6_1/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/bin/armcl" -mv7A8 --code_state=32 --abi=eabi -me -g --define=am3352 --display_error_number --diag_warning=225 --diag_wrap=off -z -m"sdram_test.map" --heap_size=0x800 --stack_size=0x2000 -i"/opt/ti/ti_ccs6_1/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/lib" -i"/opt/ti/ti_ccs6_1/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include" --reread_libs --define=A8_CORE=1 --warn_sections --display_error_number --diag_wrap=off --xml_link_info="sdram_test_linkInfo.xml" --rom_model -o "sdram_test.out" "./sdram_test_main.obj" "../AM335x.cmd" -l"libc.a" -l"/home/Mr_Halfword/AM3352-SOM-EVB_bare_metal/AM3352_SOM_platform/Debug/AM3352_SOM_platform.lib" -l"/opt/ti/AM335X_StarterWare_02_00_01_01/binary/armv7a/cgt_ccs/utils/Release/utils.lib" -l"/opt/ti/AM335X_StarterWare_02_00_01_01/binary/armv7a/cgt_ccs/am335x/drivers/Release/drivers.lib" -l"/opt/ti/AM335X_StarterWare_02_00_01_01/binary/armv7a/cgt_ccs/am335x/system_config/Release/system.lib"
<Linking>
fatal error #10333: illegal attempt to place ".cinit" before ".bss" in "GROUP_1"
As a work-around a separate GROUP was created for the initialized and uninitialized sections, and used HIGH on the uninitialized sections to place the initialized section at the start of the memory region:
SECTIONS { /* Initialised sections */ GROUP { .text:Entry .text .const .cinit } > L3OCMC0 /* Uninitialised sections */ GROUP { .bss RUN_START(bss_start) RUN_END(bss_end) .stack } > L3OCMC0 HIGH }
sectti showed that the initialized sections were contiguous in memory and at the start of the L3OCMC0 region (o = 0x40300000 l = 0x00010000):
/opt/ti/ti_ccs6_1/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/bin/armofd -x /home/Mr_Halfword/AM3352-SOM-EVB_bare_metal/sdram_test/Release/sdram_test.out | /opt/ti/cg_xml/bin/sectti Reading from stdin ... ************************************************************ REPORT FOR FILE: /home/Mr_Halfword/AM3352-SOM-EVB_bare_metal/sdram_test/Release/sdram_test.out ************************************************************ Name : Size (dec) Size (hex) Type Load Addr Run Addr -------------------- : ---------- ---------- ---- ---------- ---------- .text:Entry : 200 0x000000c8 CODE 0x40300000 0x40300000 .text : 19296 0x00004b60 CODE 0x403000c8 0x403000c8 .const : 140 0x0000008c DATA 0x40304c28 0x40304c28 .cinit : 20 0x00000014 DATA 0x40304cb8 0x40304cb8 .bss : 16900 0x00004204 UDATA 0x40308000 0x40308000 .stack : 8192 0x00002000 UDATA 0x4030c204 0x4030c204 ------------------------------------------------------------ Totals by section type ------------------------------------------------------------ Uninitialized Data : 25092 0x00006204 Initialized Data : 160 0x000000a0 Code : 19496 0x00004c28
Is the linker fatal error #10333: illegal attempt to place ".cinit" before ".bss" in "GROUP_1" a bug, or a limitation of how the linker generates the contents of the .cinit section?
[I can't seem to find any documentation which describes linker fatal error #10333]