Android: cannot execute file compiled through Linu

2019-02-19 10:58发布

root@hammerhead:/data/local # ./HelloWorld
tmp-mksh: ./HelloWorld: No such file or directory

Hello!

I compiled using gcc on Linux Deploy, which as I understand downloads Ubuntu and chroots into the environment. The file runs fine inside of this chroot environment.

As I understand this error is given when the file doesn't match the architecture of the machine. But it is running on the same machine! Does anyone know why this may be happening?


File permissions, ownership and context:

-rwxrwxrwx root  root  u:object_r:system_data_file:s0 HelloWorld

Id output:

uid=0(root) gid=0(root) context=u:r:init:s0

Using /system/bin/sh

/system/bin/sh: ./Helloworld: No such file or directory

Trying to execute a non existant file:

/system/bin/sh: ./test: not found

1条回答
老娘就宠你
2楼-- · 2019-02-19 11:32

You should compile your binary with gcc '-static' key. If you don't do that, you binary will need dynamic linker ld.so that doesn't exist on Android (but definitely exists inside your chroot!). This implies that strange error message "No such file or directory".

查看更多
登录 后发表回答