The C Runtime Initialization

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.

  1. crt stands for C runtime.
  2. 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.
  3. 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 main function.
  • Exit with the return code supplied if the C main function 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s