尝试使用 qemu 运行 ARM 可执行文件时权限被拒绝

Permission denied when trying to run ARM executable with qemu

我正在尝试 运行 使用 qemu 交叉编译文件,但是出现 "Permission denied" / "Operation not permitted" 错误(即使在 运行 sudo 时)。

我在 VirtualBox 5.0.22 中 运行ning Debian 8.7 i386,交叉编译为 ARM。此处更详细地描述了交叉编译设置 http://exploringbeaglebone.com/chapter7

交叉编译的文件 运行 在复制到本机 ARM 设备时没问题。

#include <stdio.h>
int main()
{
  printf("Hello ARM\n";
  return 0
}

构建它:

# arm-linux-gnueabihf-gcc testARM.c -o testARM -Wall
# file testARM
# testARM: ELF 32-bit LSB executable, ARM, EABI5 version1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=...., not stripped

尝试运行直接给出

# ./testARM
# bash: ./testARM: Permission denied

正在尝试通过 qemu运行

# qemu-arm ./testARM
# ./testARM: Operation not permitted

与 sudo 相同

# sudo qemu-arm ./testARM
# ./testARM: Operation not permitted

运行 它在平台上是本机的,它是交叉编译的作品

beaglebone:~$ ./testARM
Hello ARM

当然,我也检查了文件权限(rwxr-xr-x) 谷歌搜索向我展示了遇到同样问题的其他人,但没有解决方案。

我最好的猜测是 VirtualBox 中的 运行ning qemu 导致了这个问题,但有多个报告表明它可以正常工作。主机 CPU 是 Intel Core i7。

可能是什么问题?我想 运行 自动化测试作为构建过程的一部分,这就是为什么使用 qemu 的工作设置会很好。

正如@TobySpeight 推测的那样,这只是一个文件系统挂载标志问题。它在 stackexchange here.

上有描述

使用 exec 标志进行挂载解决了问题:mount -o remount,exec filesystem