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 .text
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 .text
and .data
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:
- write a c++ program
- compile it using mipseb-linux-g++ (cross compiler)
- hex dump all sections into their own file
- read files and load contents into processor "memory"
- run program
Where in the ELF file should I place my program counter initially? I have it at the beginning of .text
right now. Also, do I only need to include .text
and .data
for my program to work correctly? What am I doing wrong here?