|
|
Subscribe / Log in / New account

Horgan: Linux x86 Program Start Up

Patrick Horgan explains the 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 the environment variables just after the terminating null of the argument vector and then sets a global variable __environ which __libc_start_main uses thereafter whenever it needs it including when it calls main. After the envp is established, then __libc_start_main uses the same trick and surprise! Just past the terminating null at the end of the envp array, there's another vector, the ELF auxiliary vector the loader uses to pass some information to the process. An easy way to see what's in there is to set the environment variable LD_SHOW_AUXV=1 before running the program.


to post comments

Horgan: Linux x86 Program Start Up

Posted Nov 4, 2021 15:28 UTC (Thu) by wtarreau (subscriber, #51152) [Link]

Wow, a big kudos for this work! For having found myself trying to find my way through all this a number of times, I do appreciate how painful an experience this must have been, and I'm sure it will be extremely useful to a number of developers!

Horgan: Linux x86 Program Start Up

Posted Nov 6, 2021 2:45 UTC (Sat) by unixbhaskar (guest, #44758) [Link]

It is indeed an enriching experiance. Thank you so much for the article.

Horgan: Linux x86 Program Start Up

Posted Nov 11, 2021 2:58 UTC (Thu) by ncm (guest, #165) [Link]

Of course little of this is really necessary, but it is easier to add to than to simplify.

This is a pretty good example of Conway's Law, with various bits branching off according to who is responsible for them.


Copyright © 2021, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds