重新创建 Ubuntu 安装以运行未知二进制文件

重新创建 Ubuntu 安装以运行未知二进制文件

我可以访问 Ubuntu 16.04 安装,它可以运行某个二进制文件(它是某个版本的液化石油气泥浆我用未知参数编译了这个二进制文件(我使用这个二进制文件编译了这个二进制文件),但是我无法在不同的 Ubuntu 16.04 安装上运行相同的二进制文件——在第二个系统上,二进制文件因段错误而失败。

我并不是真的对制作第一个系统的精确副本感兴趣 - 我想知道二进制文件运行到底需要什么,这样我就可以创建一个可以运行二进制文件的 Ubuntu 的最小安装。

最好的方法是什么?我正在考虑提取已安装软件包的列表(使用apt list --installed)和/etc目录,在第二个系统中重新安装软件包并复制/etc目录。

我知道,二进制文件在不同系统上出现段错误的原因有很多,但在尝试从逐位复制缩小环境范围之前,我想尝试一些数据密集程度较低的方法。

这是一个合理的方法吗?有人知道如何提高成功率吗?


编辑-有关二进制文件的更多信息:

$ file driver
driver: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, stripped
$ ldd driver
       statically linked
$ gdb driver
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 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"...
"/mud/bin/driver": not in executable format: File format not recognized

尝试使用 32 位版本的 gdb 进行调试会带来类似的结果:

$ gdb driver
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 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 "i686-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"...
"/mud/bin/driver": not in executable format: File format not recognized
(gdb) show configuration
This GDB was configured as follows:
   configure --host=i686-linux-gnu --target=i686-linux-gnu
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/lib/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --with-python=/usr (relocatable)
             --without-guile
             --with-separate-debug-dir=/usr/lib/debug (relocatable)
             --with-system-gdbinit=/etc/gdb/gdbinit
             --with-babeltrace

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)
(gdb) 
$ strace -o ./log ./driver ; cat ./log
execve("./driver", ["./driver"], [/* 9 vars */]) = 0
brk(NULL)                               = 0x8952000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf7f89000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
set_thread_area({entry_number:-1, base_addr:0xf7f89a80, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 (entry_number:12)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x4} ---
+++ killed by SIGSEGV (core dumped) +++

答案1

在比较了第一个系统和第二个系统上的二进制文件的哈希值(使用 md5sum)后,我发现第二个系统上的二进制文件已损坏。再次复制二进制文件(并验证哈希值是否相同)解决了该问题。

谢谢至梅斯蒂亚谁在评论中提供了帮助。

相关内容