我有一个 MIPS 32 位 MSB 二进制文件,我可以使用 IDA Pro 反汇编代码并使用 ReTargetable Decompiler 成功反编译它。
为了更好地理解二进制文件,我需要调试二进制文件以了解一些子程序。
我正在使用 Ubuntu 64 位(版本 14.04)。我已按照此处提供的说明进行操作:https : //reverseengineering.stackexchange.com/a/8917/2673 用于安装 qemu、binfmt、gdb-multiarch、MIPS 库和交叉编译工具链。
交叉编译器安装错误:
尝试在 Ubuntu 14.04 上安装 gcc-4.4-mipsel-linux-gnu 时出错
gcc-4.4-mipsel-linux-gnu 依赖于 cpp-4.4-mipsel-linux-gnu。
当我尝试安装 cpp-4.4-mipsel-linux-gnu 时,出现未安装 libgmp32c2 的错误。当我尝试使用 apt-get 安装 libgmp3c2 时,它没有找到该软件包。
我可以找到其他几个包,例如 libgmp3c2-* 但是,找不到 cpp-4.4-mipsel-linux-gnu 需要的特定 libgmp3c2 包。我什至将推荐的存储库添加到 /etc/apt/sources.list
但是,我认为只有当我需要为目标架构编译程序时,才需要安装跨平台编译工具。
MIPS 二进制执行错误
所以,我试图执行 MIPS 二进制文件,但它崩溃了。当我对其运行 strace 时,出现以下错误:
NeonFlash:~$ qemu-mips -strace ./test
61294 brk(NULL) = 0x00412000
61294 mmap(NULL,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = 0x767ca000
61294 uname(0x76ffeae8) = 0
61294 access("/etc/ld.so.nohwcap",F_OK) = -1 errno=2 (No such file or directory)
61294 access("/etc/ld.so.preload",R_OK) = -1 errno=2 (No such file or directory)
61294 open("/etc/ld.so.cache",O_RDONLY) = 3
61294 fstat64(3,0x76ffe6d0) = 0
61294 mmap(NULL,104789,PROT_READ,MAP_PRIVATE,3,0) = 0x767b0000
61294 close(3) = 0
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
以下是我尝试将 gdb 与二进制文件一起使用时的详细信息:
NeonFlash$ qemu-mips -g 12345 ./test &
[1] 60181
NeonFlash$ gdb-multiarch ./test
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./test...(no debugging symbols found)...done.
(gdb) set arch mips
The target architecture is assumed to be mips
(gdb) target remote localhost:12345
Remote debugging using localhost:12345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x767cb880 in ?? ()
(gdb) x/i $pc
=> 0x767cb880: move t9,ra
我什至尝试通过运行 qemu-mips 使用 IDA Pro 远程调试二进制文件,如下所示:
qemu-mips -E REMOTE_ADDR=<IP_address_of_machine_with_IDA_PRO> -g 12345 ./test &
但是,如果我在 main 函数上设置断点,它就会崩溃。
我是否需要安装 qemu-system 或 qemu-user 应该足以调试 MIPS 二进制文件?