The following section describes the role of the C runtime startup code.

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:

- Initialize the stacks.
- Copy the contents of the .data (initialized data) section from non-volatile memory should it be required.
- Copy the contents of the .fast section from non-volatile memory to SRAM should it be required.
- Initialize the .bss section.
- Initialize the heap.
- Call constructors.
- Jump to the main entry point.
- Call destructors.
- Wait in exit loop.

### Stacks

The ARM maintains six separate stacks. The position and size of these stacks are specified in the project's memory map file by the following program sections:

- .stack - System and User mode stack.
- .stack_svc - Supervisor mode stack
- .stack_irq - IRQ mode stack
- .stack_fiq - FIQ mode stack
- .stack_abt - Abort mode stack.
- .stack_und - Undefined mode stack.

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 memory map. To change the maximum size of a particular stack the Size property of the section should be modified to the required value. 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 and the initialization code from the crt0.s file.

### .data Section

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.

### .fast Section

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.

### .bss Section

The .bss section contains the zero initialized data. The crt0.s startup code references the .bss section and sets its contents to zero.

### Heap

The position and size of the heap is specified in the project's 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 memory map. To change the size of the heap the Size property of the section should be modified to the required value. Should your application not require the heap functions, the heap section can be removed from the memory map file and the heap initialization code may be removed from the crt0.s file.