How is a program (e.g. C or C++) arranged in computer memory? I kind of know a little about segments, variables etc, but basically I have no solid understanding of the entire structure.

Since the in-memory structure may differ, let's assume a C++ console application on Windows.

Some pointers to what I'm after specifically:

  • Outline of a function, and how is it called?
  • Each function has a stack frame, what does that contain and how is it arranged in memory?
  • Function arguments and return values
  • Global and local variables?
  • const static variables?
  • Thread local storage..

Links to tutorial-like material and such is welcome, but please no reference-style material assuming knowledge of assembler etc.

Edit
Report