我可以访问 Ubuntu 16.04 安装,它能够运行某个二进制文件(它是使用未知参数编译的LPMud的某个版本),但我无法在不同的 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) +++
在比较第一个和第二个系统上的二进制文件的哈希值(使用 md5sum)后,我发现第二个系统上的二进制文件已损坏。再次复制二进制文件(并验证哈希值是否相同)解决了这个问题。
感谢在评论中提供帮助的mestia 。