Qemu-Arm 文件访问?

Qemu-Arm file access?

我正在尝试为项目设置 arm 调试环境。该项目所需的主要代码功能之一是将二进制文件加载到内存 (6mb)。

我已经在 ubuntu linux 12.04 上安装了 qemu-arm,编译的 GDB 目标设置为 arm。我正在尝试编译以下测试代码:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdint.h>
int main()
{
int fd = open("files/test.txt", O_RDONLY);
printf("File handle: %i ", fd);
perror(NULL);
return 0
}

命令行:

arm-linux-gnueabihf-gcc -static -no-stack-protector -g test.c -o test;qemu-arm  ./test

输出:

File handle: -1 No such file or directory

似乎找不到该文件,我认为这是因为 QEMU 无法访问它...我对 QEMU 不是很有经验,但考虑到我之前使用虚拟机的经验,我猜原来如此。

谁能帮忙解决这个问题?

编辑: 哇,我解决了,好像我的代码中有错字,文件路径不正确。现在修复了......我应该关闭它吗?我的问题无效,因为这是一个愚蠢的错字。我发布的代码中没有错别字。

虽然您通过更正拼写错误找到了问题的解决方案,但我想我会解决您提出的这个问题:

Seems like it can't find the file, I believe this to be because QEMU doesn't have access to it... I am not very experienced with QEMU but given my prior experience with virtual machines I would guess this to be the case.

QEMU 有两种操作模式。一种是全系统模拟器,类似于您可能熟悉的其他 VM。

另一种模式是用户模式模拟器,这就是您正在使用的模式。在这种模式下,QEMU t运行slates user-mode 指令从一个 ISA 到另一个。在您的情况下,它是 t运行slating ARM 指令到 x86 指令。但是,当处理系统调用时,模拟器会直接在主机中执行它们 OS。所以这就是为什么 QEMU 能够像您 运行 能够访问的任何其他进程一样访问本地文件系统。