1

For various testing reasons, I need to run my own 32-bit ARM ELF executables on various real ARM Android devices (I can't use emulators). Because it is not easy to buy an ARMv7 device nowadays, I'd like to run the executables on 64-bit Android devices. However, all the 64-bit devices from various vendors I have access to refuse to run the executables with this message:

not executable: 32-bit ELF file

This means that the system can't run 32-bit ELF files, or it can run them but it is configured to refuse them. Is there any trick to make the 64-bit OS running 32-bit executables, just like 64-bit Windows or 64-bit Linux can run 32-bit executables?

I use the following steps to push and execute the file:

adb push printf /data/local/tmp/
adb shell chmod 555 /data/local/tmp/printf
adb shell /data/local/tmp/printf

This returns:

/system/bin/sh: /data/local/tmp/printf: not executable: 32-bit ELF file

8
  • 1
    the error message is misleading, it's another reason. download busybox and try busybox printf
    – alecxs
    Commented Jun 25, 2020 at 17:59
  • @alecxs Can you be more specific please? When I rename my printf executable to printfx and run ./busybox-armv8l printfx from /data/local/tmp/, it says "printfx: applet not found" because it expects the parameter to be one of the functions supported by busybox.
    – MazeGen
    Commented Jun 25, 2020 at 19:01
  • Mostly ARM64 devices (processors) support 32-bit execution. But the opposite is not impossible either. Mostly 64-bit Linux/Android kernels are built to support 32-bit compatibility mode, but the opposite isn't impossible either. Details here: Could a 64-bit hardware device run a 32-bit Android version?. But try with some pre-built binaries to make sure that the problem is not with your static (or dynamic) linking, environment, permissions etc. What does ls -lZ /data/local/tmp/printf; file /data/local/tmp/printf return? Root? SELinux? Commented Jun 25, 2020 at 19:09
  • @alecxs Why do you think my executable is broken? It runs just fine on an armv7 device. Perhaps you misunderstand my question, I'm not interested in printf functionality. I named my executable "printf" just because it prints something to stdout.
    – MazeGen
    Commented Jun 25, 2020 at 19:24
  • 1
    @MazeGen ARMv8 processors are backward compatible only with ARMv7. Your binary must be ARM v5/v6. Rebuild it for at least armeabi-v7a. See details here: android.stackexchange.com/a/208132/218526 Commented Jun 25, 2020 at 20:34

1 Answer 1

1

This question was viewed many times and it deserves an answer:

ARMv8 processors are backward compatible only with ARMv7. Your binary must be ARM v5/v6. Rebuild it for at least armeabi-v7a.

As correctly answered by Irfan Latif in the comments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .