TLDR Dev · MISCELLANEOUS
THE JOURNEY BEFORE MAIN()
Summary from the TLDR Dev newsletter
This article explains the journey from when the OS kernel is asked to run a program to when the `main()` function is executed. The kernel uses the `execve` system call to load the program, which is usually in ELF format on Linux. The ELF file contains code, data, and other information, including an entry point where execution begins. The kernel sets up the stack with arguments, environment variables, and auxiliary vectors before jumping to the `_start` function, which then initializes the language runtime and calls the user's `main()` function.