In the _start
function, argc
, argv
and envp
are contained on the stack.
A good read on this is the Linux x86 Program Start Up or - How the heck do we get to main()
?
When you run a program, the shell or gui calls execve()
which executes the linux system call execve()
. If you want more information about execve()
then you can simply type man execve
from your shell. It will come from section 2 of man where all the system calls are. To summarize, it will set up a stack for you, and push onto it argc
, argv
, and envp
. The file descriptions 0, 1, and 2, (stdin
, stdout
, stderr
), are left to whatever the shell set them to. The loader does much work for you setting up your relocations, and as we'll see much later, calling your preinitializers. When everything is ready, control is handed to your program by calling _start()
.