The following section describes the role of the C runtime startup code, crt0.s.
When you create a new project to produce an executable file using a target specific project template, the crt0.s file will be added to the project. Initially a shared version of this file will be added to the project, if you want to modify this file you should select the file in the project explorer and then select Import to copy the file to your project directory.
The entry point of the C runtime startup code is _start. In a typical system this will be called by the target-specific startup code after it has initialized the target.
The C runtime carries out the following actions:
The ARM maintains six separate stacks. The position and size of these stacks are specified in the project's section placement or memory map file by the following program sections:
The crt0.s startup code references these sections and initializes each of the stack pointer registers to point to the appropriate memory location. To change the location in memory of a particular stack, the section should be moved to the required position in the section placement or memory map file.
There is a Stack Size linker project property for each stack, you can modify this property in order to alter each stack maximum size. For compatibility with earlier versions of CrossStudio you can also specify the stack size using the stack section's Size property in the section placement or memory map file.
Should your application not require one or more of these stacks to be set up you can remove the sections from the memory map file or set the size to 0 and remove the initialization code from the crt0.s file.
The .data section contains the initialized data. If the run address is different from the load address, as it would be in a FLASH based application in order to allow the program to run from reset, the crt0.s startup code will copy the .data section from the load address to the run address before calling the main entry point.
For performance reasons it is a common requirement with embedded systems to have critical code running from fast memory, the .fast section can be used to simplify this. If the .fast section's run address is different from the load address the crt0.s startup code will copy the .fast section from the load address to the run address before calling the main entry point.
The .bss section contains the zero initialized data. The crt0.s startup code references the .bss section and sets its contents to zero.
The position and size of the heap is specified in the project's section placement or memory map file by the .heap program section.
The crt0.s startup code references this section and initializes the heap. To change the position of the heap, the section should be moved to the required position in the section placement or memory map file.
There is a Heap Size linker project property, you can modify this property in order to alter the heap size. For compatibility with earlier versions of CrossStudio you can also specify the heap size using the heap section's Size property in the section placement or memory map file.
Should your application not require the heap functions, you can remove the heap section from the memory map file or set the size to 0 and remove the heap initialization code from the crt0.s file.