title: Executable Section Headers - Meaning and use?
body: <p>By opening many executable (<code>.exe.</code>, <code>.msi</code>) files in Windows using 7zip, i have noticed many different file types that are common. Those include .text, .data, .bss, .rdata, .pdata etc.. I've tried to get information about them, but i can't find out what they all mean. Here's some of them: </p>
  
  <ul>
  <li><code>.text</code> : Code section, contains the program’s instructions - read only -. </li>
  <li><code>.data</code> : Generally used for writable data with some initialized non-zero content. Thus, the data section contains information that could be changed during application execution and this section must be copied for every instance. </li>
  <li><code>.bss</code> : Used for writable static data initialized to zero. </li>
  <li><code>.rdata</code> : Const / Read-only data of any kind are stored here. </li>
  <li><code>.edata</code> : Export directory, descriptors &amp; handles </li>
  <li><code>.idata</code> : Import directory for handles &amp; descriptors. It is used by executable files (exe's, dll’s etc.) to designate the imported and exported functions. </li>
  <li><code>.rsrc</code> : Section which holds information about various other resources needed by the executable, such as the icon that is shown when looking at the executable file in explorer </li>
  </ul>
  
  <p>There are many others, which are common and i can't find any information on. Mostly those are: <code>.pdata</code>, <code>.tls</code>, <code>.reloc</code>, CERTIFICATE, <code>.rsrc_1</code>, <code>.aspack</code>, <code>.adata</code>, <code>.INIT</code>, <code>DATA</code>, <code>CODE</code>, <code>.ctors</code>.</p>
  
  <p>Also a <code>rsrc</code> folder is contained in most of them, which contains folders like BITMAP, CURSOR, ICON, GROUP_CURSOR, GROUP_ICON, MENU, VERSION and others. </p>
  
  <p>Some executables also contain more executables inside, <code>.html</code> files, <code>.txt</code> files etc. I also opened one which contained nothing at all (at least nothing shown by opening it with 7zip)! [ I opened them all with 7zip. ]</p>
  
  <hr>
  
  <p>Questions </p>
  
  <ol>
  <li>What those sections / segments i posted do? Is there a website where i can find them all? </li>
  <li>All those i looked at are PEs for Windows. Are these formats standard and apply to LINUX, UNIX etc. in a similar / same way? </li>
  <li>Why do some executables contain other executables inside, or .html, .txt and other files? How are these handled when you launch the executable? What are they supposed to do? AFAIK everything inside an executable should have only those "segments" that resemble assembly code sections. </li>
  <li>What is the use of <code>rsrc</code> folder? What kind of resources does it hold?</li>
  </ol>
  
  <p>I would appreciate it, if you could post more information / links as to why are all these used (as low level as possible) and generally how the executable structure should look like, what it should contain etc.</p>
  
  <p>That's about all. </p>
  
  <hr>
  
  <p><strong>EDIT</strong> </p>
  
  <p>I found other common section header names. I will post their meaning here for completeness. </p>
  
  <ul>
  <li><code>.reloc</code> : Contains the relocation table. </li>
  <li><code>.pdata</code> : contains an array of function table entries for exception handling, and is pointed to by the exception table entry in the image data directory </li>
  <li><code>*data</code> : custom data section names </li>
  <li><code>.init</code> : This section holds executable instructions that contribute to the process initialization code. That is, when a program starts to run the system arranges to execute the code in this section before the main program entry point (called main in C programs). </li>
  <li><code>.fini</code> : This section holds executable instructions that contribute to the process termination code. That is, when a program exits normally, the system arranges to execute the code in this section. </li>
  <li><code>.ctors</code> : Section which preserves a list of constructors </li>
  <li><code>.dtors</code> : Section that holds a list of destructors </li>
  </ul>