title: What happens when you run a program?
body: <p>I would like to collect here what happens when you run an executable on Windows, Linux and OSX. In particular, I would like to understand exactly the order of the operations: my guess is that the executable file format (PE, ELF or Mach-O) is loaded by the kernel (but I ignore the various sections of the <a href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format" rel="noreferrer">ELF</a>（Executable and Linkable Format） and their meaning), and then you have the dynamic linker that resolves the references, then the <code>__init</code> part of the executable is run, then the main, then the <code>__fini</code>, and then the program is completed, but I am sure it's very rough, and probably wrong.</p>
  
  <p><em>Edit</em>: the question is now CW. I am filling up for linux. If anyone wants to do the same for Win and OSX it would be great.</p>