crt0 (also known as c0) is a set of execution startup routines linked into a C program that performs any initialization work required before calling the program’s main function.
- crt stands for C runtime.
- crt is a set of execution startup routines compiled into a program which performs any initialization work required before calling the program’s main function. It is a basic runtime library/system.
- The work performed by crt depends on the ABI, machine, compiler, operating system and C standard library implementation.
The C Runtime system must carry out the following tasks.
- Set up the target platform in a consistent state. For example setting up appropriate exception vectors.
- Initialize the stack and frame pointers
- Invoke the C constructor initialization and ensure destructors are called on exit.
- Carry out any further platform specific initialization.
- Call the C
- Exit with the return code supplied if the C
mainfunction ever terminates.
Crt0 generally takes the form of an object file called crt0.o, often written in assembly language, which is automatically included by the linker into every executable file it builds.