How to Debug MIPS elf?

2019-07-24 11:58发布

Suppose I have a MIPS elf binary (meaning someone cross compiled/compiled on MIPS a MIPS linux executable)

Are there any linux distros that are compiled to run on mips architecture that could perhaps run the executable? I've looked around, but all I can find is linux-mips. Even better would be if the distro was already installed to a VM disk file, and you could just download it.

Is there any guaranteed way to run the MIPS elf on a non MIPS distro? Like using some qemu setup or something? (By "guaranteed" I mean if it runs in a MIPs distro then it should run in the emulator without a doubt, and that ALL functionality is absolutely implemented in the emulator, so that whatever would occur (userland specific obviously) in the MIPS distro will also occur in the emulator, so that I can have some confidence that it will work properly).

Lastly, if I wanted to debug MIPS, but I don't understand it all that well, is there any kind of learning tool that would be really good for understanding what MIPS is doing besides a VM? Here's what I have in mind-using a tool, you could attach to either a MIPS compiled elf or a x86, and as you walk through the instructions in the executable, you can see a conversion from the format of the executable in control of the debugger to the format of your choice. A not so good alternative that would still work would be where you could past any MIPS instruction into a text box, and see another text box with the equivalent x86 instruction, or vice versa.

1条回答
Luminary・发光体
2楼-- · 2019-07-24 12:47

If you are in possession of a hardware with MIPS CPU that can run Linux, the easiest way would be to use one of the Linux distributions for MIPS architecture. A common one is Debian distribution, and you can find more about Debian for MIPS at this link.

If you do not have access to MIPS hardware, running QEMU on your x86 host should be sufficient. Take a look at MIPS-QEMU instructions.

Last, once you have MIPS Linux in place, copy your MIPS binary to it, log in, and run gdb with it. This should give you a solid environment to debug it. Speaking of understanding MIPS assembly, the architecture is clean and simple, and it is much easier to read MIPS assembly than other arch's assembly code.

查看更多
登录 后发表回答