how does process initialization work?

Thu Jan 15 17:33:00 GMT 2009


I'm trying to understand how address space is initialized for programs
compiled with gcc using glibc on linux ia32.  

Specifically, how do the heap and stack get set up, and where do they reside
in address space?  Is it glibc that's responsible for doing this, or the
kernel, or some code added by gcc that executes before main() ?  Is thread
local storage set up at the same time, and how does TLS currently work on
Linux anyway?  I know that at least some of the memory layout comes from the
linker (and I've read through linker scripts), but where's the code that
makes this happen?

So I guess I'm asking you wise folks to help me fill in the question marks-

1. fork() and exec() called in kernel; address space for process is created
2. ???
3. main()

Pointers to documentation are also quite welcome.  I've spent hours Googling
this stuff, but many hits are out-dated or too high-level, or so general
that I can't figure out what is happening on this particular architecture.

Thanks very much
View this message in context:
Sent from the gcc - Help mailing list archive at

More information about the Gcc-help mailing list