Crt0
(also known as ) 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.[src] After the main function completes the control returns to crt0, which calls the library function exit with the return code of the main function to terminate the process.[src]
(also known as ) 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.[src] After the main function completes the control returns to crt0, which calls the library function exit with the return code of the main function to terminate the process.[src] ==Form and usage== Crt0 generally takes the form of an object file called , often originally written in assembly language, which is automatically included by the linker into every executable file it builds.[src] contains the most basic parts of the runtime library.[src] As such, the exact work it performs depends on the program's compiler, operating system and C standard library implementation.[src] Beside the initialization work required by the environment and toolchain, can perform additional operations defined by the programmer, such as executing C++ global constructors and C functions carrying GCC's attribute.[src] Usually, crt0 does not contain more complex initialization code like the previously mentioned calling of functions carrying GCC's ((constructor)) attribute.[src] Most modern libc implementations use __libc_start_main , a function written in C, to handle more complex tasks.[src] "crt" stands for "C runtime", and the zero stands for "the very beginning".[src] However, when programs are compiled using GCC, it is also used for languages other than C.[src] Alternative versions of are available for special usage scenarios; for example, to enable profiling with gprof, programs must be compiled with instead.[src] .text .globl _start _start: # _start is the entry point known to the linker xor %ebp, %ebp # effectively RBP := 0, mark the end of stack frames mov (%rsp), %edi # get argc from the stack (implicitly zero-extended to 64-bit) lea 8(%rsp), %rsi # take the address of argv from the stack lea 16(%rsp,%rdi,8), %rdx # take the address of envp from the stack xor %eax, %eax # per ABI and compatibility with icc call main # %edi, %rsi, %rdx are the three args (of which first two are C standard) to main mov %eax, %edi # transfer the return of main to the first argument of _exit xor %eax, %eax # per ABI and compatibility with icc call _exit # terminate the program glibc x86_64 start.S[src]
14 sentences · 14 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Crt0." encyclopegia.org, 2026, https://encyclopegia.org/wiki/crt0. Accessed 05 December 2026.
Chicago
"Crt0." encyclopegia.org. Accessed December 5, 2026. https://encyclopegia.org/wiki/crt0.
APA
encyclopegia.org. (2026). Crt0. Retrieved December 5, 2026, from https://encyclopegia.org/wiki/crt0
Accessed December 5, 2026 · CC BY-SA 4.0 · citation page · JSON