Kjell
Kjell

Reputation: 582

Permission denied when trying to run ARM executable with qemu

I am trying to run a cross compiled file with qemu, but get "Permission denied" / "Operation not permitted" erros (even when running with sudo).

I am running Debian 8.7 i386 in a VirtualBox 5.0.22, cross compiling to ARM. The cross-compile setup is described in more detail here http://exploringbeaglebone.com/chapter7.

The cross-compiled file runs fine when copied over to a native ARM device.

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

Build it:

# 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

Trying to run directly gives

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

Trying to run via qemu

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

Same with sudo

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

Running it native on the platform it was cross-compiled for works

beaglebone:~$ ./testARM
Hello ARM

Of course, I also checked the file permissions ( rwxr-xr-x ) Googling showed me someone else with the same issue, but no solution.

My best guess is that running qemu from within VirtualBox is causing the issue, but there are multiple reports that it just works. Host CPU is an Intel Core i7.

What could be the issue? I would like to run automated tests as part of the build process, thats why a working setup with qemu would be nice.

Upvotes: 0

Views: 3729

Answers (1)

Kjell
Kjell

Reputation: 582

As @TobySpeight supposed, this was just a filesystem mount flag issue. It is described on stackexchange here.

Using the exec flag for mounting resolved the issue: mount -o remount,exec filesystem

Upvotes: 1

Related Questions