title: How does a program look in memory?
body: <p>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 <strong>entire</strong> structure.</p>
  
  <p>Since the in-memory structure may differ, let's assume a C++ console application on Windows.</p>
  
  <p>Some pointers to what I'm after specifically:</p>
  
  <ul>
  <li>Outline of a function, and how is it called?</li>
  <li>Each function has a stack frame, what does that contain and how is it arranged in memory?</li>
  <li>Function arguments and return values</li>
  <li>Global and local variables?</li>
  <li>const static variables?</li>
  <li>Thread local storage..</li>
  </ul>
  
  <p>Links to tutorial-like material and such is welcome, but please no reference-style material assuming knowledge of assembler etc.</p>