Horgan: Linux x86 Program Start Up
Patrick Horgan explainsthe process of starting a program on Linux in great detail.
Well, __libc_start_main calls __libc_init_first,who immediately uses secret inside information to find theenvironment variables just after the terminating null of theargument vector and then sets a global variable __environwhich __libc_start_main uses thereafter whenever it needsit including when it calls main. After the envpis established, then __libc_start_main uses the same trickand surprise! Just past the terminating null at the end of theenvp array, there's another vector, the ELF auxiliaryvector the loader uses to pass some information to the process. Aneasy way to see what's in there is to set the environment variableLD_SHOW_AUXV=1 before running the program.