我目前正在尝试使用qemu运行MIPS二进制文件。我在Arch linux中的主机系统。截至目前,我已经进入了我试图运行的二进制文件存在的固件的根目录。我还将qemu-mips二进制文件从主机系统复制到固件的根目录中。
在固件的根目录中,我正在运行此命令:
sudo chroot . ./qemu-mips bin/busybox
然而我收到了这个错误:
chroot: failed to run command ‘./qemu-mips’: No such file or directory
这很奇怪,考虑到我刚刚将qemu-mips二进制文件复制到我当前所在的固件根目录。我读到的大多数指南描述了如何使用qemu-mips-static,但是即使在安装了所有可用的qemu工具之后,我的系统上也不存在该二进制文件。有什么东西明显我错过了吗?谢谢。
execve("/usr/sbin/chroot", ["chroot", ".", "./qemu-mips", "bin/busybox"], 0x7fffc0804f98 /* 16 vars */) = 0
brk(NULL) = 0x5653dd4e7000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=124268, ...}) = 0
mmap(NULL, 124268, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f209819a000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\20\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2069912, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2098198000
mmap(NULL, 3897584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2097bdd000
mprotect(0x7f2097d8b000, 2097152, PROT_NONE) = 0
mmap(0x7f2097f8b000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ae000) = 0x7f2097f8b000
mmap(0x7f2097f91000, 14576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2097f91000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7f2098199500) = 0
mprotect(0x7f2097f8b000, 16384, PROT_READ) = 0
mprotect(0x5653dcd5b000, 4096, PROT_READ) = 0
mprotect(0x7f20981b9000, 4096, PROT_READ) = 0
munmap(0x7f209819a000, 124268) = 0
brk(NULL) = 0x5653dd4e7000
brk(0x5653dd508000) = 0x5653dd508000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1682192, ...}) = 0
mmap(NULL, 1682192, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2097ffd000
close(3) = 0
getcwd("/home/user/firmware/kkeps-root", 4096) = 46
chroot(".") = 0
chdir("/") = 0
execve("./qemu-mips", ["./qemu-mips", "bin/busybox"], 0x7ffec746eba0 /* 16 vars */) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "chroot: ", 8chroot: ) = 8
write(2, "failed to run command \342\200\230./qemu-"..., 39failed to run command ‘./qemu-mips’) = 39
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
) = 1
close(1) = 0
close(2) = 0
exit_group(127) = ?
+++ exited with 127 +++
所以看起来有一些东西没有找到,其中一个是/etc/ld.so.preload。我不是100%肯定该怎么办这个情况。我猜这与我不使用静态二进制文件的事实有关。
编辑:通过从AUR安装qemu-user-static来解决。
答案 0 :(得分:0)
正如您所知,这是因为您没有使用静态链接的二进制文件。在chroot中使用静态QEMU二进制文件实际上并不是绝对必要的,只是对于静态二进制文件,您只需要将一个文件复制到chroot中,而如果使用动态链接的QEMU,则还需要在主机动态中复制链接器和QEMU链接的所有主机库 - 如果主机和guest虚拟机想要为动态库使用相同的路径名,则可能会遇到问题。