I've been trying to run a compiled binary in my android phone, but it just keeps telling me "No such file or directory".
To be specific, I compiled wificurse, and as the description has mention to an arm command it's obvious that the source code can be compiled for an arm architecture without making any change to the makefile. And so I did the following:
export CROSS_COMPILE=arm-linux-gnueabi-
make CROSS_COMPILE=arm-linux-gnueabi-
And then with the resulting binary (wificurse) I did the following:
adb push wificurse /data
In a root adb shell I did:
root@android:/data # chmod 0777 wificurse
Returns nothing; works.
root@android:/data # chmod u+x wificurse
Returns "Bad Mode".
root@android:/data # busybox chmod 077 wificurse
Returns nothing; works.
root@android:/data # busybox chmod u+x wificurse
Returns nothing; works.
But when I try to run the binary with
root@android:/data # ./wificurse
It returns "/system/bin/sh: ./wificurse: No such file or directory". Did a ls in the folder and the binary is indeed there.
Already tried copying the binary to the internal sdcard, then moving to /data (even tried /system/bin and /system/xbin) and it returns "Access denied", but if I chmod the binary it will return the same error (No such file or directory). Could someone help me, please? I've used the linux shell for 2+ years, though I'm completely a noob when it comes to programming stuff. I guess that I'm missing something like a toolchain, I don't know.
I'm running Ubuntu 15.10 x64.
Your binary apparently depends on some shared library (.so) that is not visible for dynamic linking. You can use readelf
from your toolchain and you get something like this:
tom@pc:~/workspace/test/arm-v7a_android9/release$ ~/toolchains/armeabiv7a_android-9_ndk-r10e_gcc-4.9/bin/arm-linux-androideabi-readelf -d test
Dynamic section at offset 0x445a14 contains 27 entries:
Tag Type Name/Value
0x00000003 (PLTGOT) 0x44fc50
0x00000002 (PLTRELSZ) 1864 (bytes)
0x00000017 (JMPREL) 0x74d24
0x00000014 (PLTREL) REL
0x00000011 (REL) 0x74cd4
0x00000012 (RELSZ) 80 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x00000015 (DEBUG) 0x0
0x00000006 (SYMTAB) 0x8148
0x0000000b (SYMENT) 16 (bytes)
0x00000005 (STRTAB) 0x26718
0x0000000a (STRSZ) 273460 (bytes)
0x00000004 (HASH) 0x6934c
0x00000001 (NEEDED) Shared library: [liblog.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x0000001a (FINI_ARRAY) 0x447cb8
0x0000001c (FINI_ARRAYSZ) 12 (bytes)
0x00000019 (INIT_ARRAY) 0x447cc4
0x0000001b (INIT_ARRAYSZ) 324 (bytes)
0x00000020 (PREINIT_ARRAY) 0x447e08
0x00000021 (PREINIT_ARRAYSZ) 0x8
0x0000001e (FLAGS) BIND_NOW
0x6ffffffb (FLAGS_1) Flags: NOW
0x00000000 (NULL) 0x0
Check that all libraries with type (NEEDED)
are on your Android device and are visible for your binary (you should use export LD_LIBRARY_PATH=<path>[:<another_path>[..]]
to make .so available for dynamic linking with your binary).
If problem isn't still resolved, your application is linked with different version of some system library - try to use an older toolchain.
Did you try the methods in this thread? "No such file or directory" trying to execute linux binary on Android device
An alternative way to solve this problem would be installing KBOX on Android. The author has developed tools like gcc, ssh server for the Android platform. Therefore, you can start an ssh server on your phone and do all your work on your PC, which means that you can compile your code directly on the phone :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With