title: ELF File Format
body: <p>I'm attempting to manually load the hexdump of an elf file that I compiled using g++ into a processor simulation I designed. There are 30 sections to a standard elf file and I am loading all 30 segments with their proper memory location offset taken into account. I then start my program counter at the beginning of the <code>.text</code> section (00400130) but it seems that the program isn't running correctly. I have verified my processor design relatively thoroughly using SPIM as a gold standard. The strange thing is that, if I load an assembly file into SPIM, and then take the disassembled <code>.text</code> and <code>.data</code> sections that are generated by the software, load them into my processor's memory, the programs work. This is different from what I want to do because I want to:</p>
  
  <ul>
  <li>write a c++ program</li>
  <li>compile it using mipseb-linux-g++ (cross compiler)</li>
  <li>hex dump all sections into their own file</li>
  <li>read files and load contents into processor "memory"</li>
  <li>run program</li>
  </ul>
  
  <p>Where in the ELF file should I place my program counter initially? I have it at the beginning of <code>.text</code> right now. Also, do I only need to include <code>.text</code> and <code>.data</code> for my program to work correctly? What am I doing wrong here?</p>