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?

Edited by dansnyderECE: n/a

8 Years
Discussion Span
Last Post by dansnyderECE

So I've sense determined where in memory to start (using objdump -f to get a more accurate location.) Turns out I was choosing the correct PC start point anyway. Does anyone know of a way to hex dump an entire binary file in the format readelf does it?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.