0
votes

I need to generate a machine code of different C codes. I compiled C codes by using soucery code bench I can compile it successfully and get the assembly code and executable file what I have a problem I need a machine code only than I can put that machine code on FPGA . I have one way to get to get is use -objdump command means decompile the executable but this decompile file is in the elf format add a lot of this so if any one knows how to get only machine code. It would be very helpful for me.

2
Er, what? Try rewriting that question, this time with punctuation and formatting. - Nic

2 Answers

0
votes

Try readelf -x .text foo to get a hex dump of the text (machine code) section of the compiled executable foo. You might also need to dump other sections, such as the GOT and initialized data sections.

0
votes

thanks for the reply

this command work but give me an empty text file, what I do.

  1. ~/Mentor_sourcery/bin/mips-linux-gnu-gcc -x C_code.c it gives me an executable a.out.

  2. then i run ~/Mentor_sourcery/bin/mips-linux-gnu-objdump -x a.out >foo1.txt

it gives me elf formatted file.

3.then ~/Mentor_sourcery/bin/mips-linux-gnu-readelf -x foo1.txt >final.txt

this command run without any error but gives me an empty .txt file