Lably
Skip to content

Crt0

Set of execution startup routines linked into a C program

  • 3 min read
  • 2 chapters

Related on Lably

Through Constructor (object-oriented programming)

Form and usage

Crt0 generally takes the form of an object file called crt0.o, often originally written in assembly language, which is automatically included by the linker into every executable file it builds.

crt0 contains the most basic parts of the runtime library. As such, the exact work it performs depends on the program's compiler, operating system and C standard library implementation. Beside the initialization work required by the environment and toolchain, crt0 can perform additional operations defined by the programmer, such as executing C++ global constructors and C functions carrying GCC's ((constructor)) attribute.

Usually, crt0 does not contain more complex initialization code like the previously mentioned calling of functions carrying GCC's ((constructor)) attribute. Most modern libc implementations use __libc_start_main, a function written in C, to handle more complex tasks.

"crt" stands for "C runtime", and the zero stands for "the very beginning". However, when programs are compiled using GCC, it is also used for languages other than C. Alternative versions of crt0 are available for special usage scenarios; for example, to enable profiling with gprof, programs must be compiled with gcrt0 instead.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Computing and communication

Source and licence. Adapted from the Wikipedia article “Crt0” (this version, 2026-10-04) by its contributors, shared under CC BY-SA 4.0. Lablypedia has left out its tables, references and most pictures, and linked it to other Lablypedia articles.