3

I compiled a binary on an aarch64 server & am trying to run it on a Android device that's aarch64 architecture.

I ran readelf -a on the program 'cat' (left side) & ran the same command on my program (right side)

Any ideas why I get this error when trying to run the binary on the device:

:/data/local # ls -lh total 48M -rwxrwxrwx 1 root root 1.4M 2018-11-16 10:42 example-app -rw-rw-rw- 1 root root 47M 2018-11-14 18:03 mnist-traced.pt drwxrwx--x 3 shell shell 4.0K 2018-11-05 16:58 tmp :/data/local # ./example-app mnist-traced.pt /system/bin/sh: ./example-app: No such file or directory

Binary is chmod'd to 751, Android device is rooted, binary runs fine on arm64 server.

enter image description here

Android device info:

# uname -a Linux localhost 3.18.35 #4 SMP PREEMPT Thu May 17 18:24:00 CST 2018 aarch64

objdump

root@scw-ac272c:~/mnist-torch/build# objdump -j .interp -s ./example-app

./example-app:     file format elf64-littleaarch64

Contents of section .interp:
 400238 2f6c6962 2f6c642d 6c696e75 782d6161  /lib/ld-linux-aa
 400248 72636836 342e736f 2e3100             rch64.so.1.


root@scw-ac272c:~/mnist-torch/build# objdump -j .interp -s ./cat


./cat:     file format elf64-littleaarch64 (Android device program)

Contents of section .interp:
 0238 2f737973 74656d2f 62696e2f 6c696e6b  /system/bin/link
 0248 65723634 00                          er64.
Suhail Doshi
  • 716
  • 1
  • 10
  • 23
  • Try moving the binary to `/data/local/tmp` instead. If won't help you might consider (if applicable) [compiling it with NDK](https://stackoverflow.com/q/35231168/3290339) – Onik Nov 16 '18 at 19:43
  • Same problem: :/data/local/tmp # ./example-app mnist-traced.pt /system/bin/sh: ./example-app: No such file or directory – Suhail Doshi Nov 16 '18 at 19:46
  • Please show the code and/or state the errors. The text on the picture is too small for some people to read. In addition, the text on the image cannot be indexed by search engines for future visitors. – jww Nov 17 '18 at 03:40
  • does /lib/ld-linux-aarch64.so.1 exist on android devices? – Martin Keßler Nov 23 '18 at 17:46
  • 1
    as shown in your output above, it is the linker ("interpreter") that is defined for your "example-app" binary. the android OS uses a complete different set of system components (e.g. `/system/bin/linker64` instead of `/lib/ld-linux-aarch64.so.1` as the linker binaries that use shared libraries) you could try compiling your program statically (add `-static` to invocation of GCC), so no run time linker would be needed. `gcc -Wall -O2 -s -static foo.c` – Martin Keßler Nov 23 '18 at 17:56
  • Hi @SuhailDoshi did you find answer to this issue? I am also facing the same issue with one of my cross-compiled application. – atul_pant Nov 23 '22 at 18:46

0 Answers0