在 Android 上安装预构建的二进制文件:“未找到”

发布于 2024-07-25 09:09:14 字数 1331 浏览 5 评论 0原文

我正在尝试在自定义 Android 映像中安装预构建的二进制文件。 为此,我已将其复制到 prebuilt/android-arm/ 中的一个新目录,其中包含与此类似的 Android.mk 文件:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := binary_name
LOCAL_MODULE := binary_name
LOCAL_MODULE_CLASS := EXECUTABLES
include $(BUILD_PREBUILT)

因此,如果我运行 make system_image binary_name,将二进制文件复制到系统映像中的/bin/中。 如果我运行模拟器,我可以在 /system/bin 中看到二进制文件。 权限与其他可执行文件 (-rwxr-xr-x) 相同,并且根据 file,这是一个 ARM 二进制文件 (ELF 32-bit LSB 可执行文件,ARM,版本 1 (SYSV),动态链接(使用共享库),已剥离)。

但是当我在模拟器上运行它时,它说:

# binary_name
binary_name: not found

我已经对它进行了 strace,这就是我所看到的:

# strace binary_name
execve("/system/bin/binary_name", ["binary_name"], [/* 9 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec", 12strace: exec)            = 12
write(2, ": ", 2: )                       = 2
write(2, "No such file or directory", 25No such file or directory) = 25
write(2, "\n", 1
)                       = 1
io_submit(1, -1344063348, {...} <unfinished ... exit status 1>

但是文件在那里,strace 能够找到它。

知道会发生什么吗?

更新:正如 Kristof 所说,这可能是动态链接的问题,但我没有适用于 Android ARM 的 ldd ...

I'm trying to install a prebuilt binary in a custom Android image. For that I have copied it to a new directory in prebuilt/android-arm/ with an Android.mk file similar to this one:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := binary_name
LOCAL_MODULE := binary_name
LOCAL_MODULE_CLASS := EXECUTABLES
include $(BUILD_PREBUILT)

So if I run make system_image binary_name, the binary file is copied to /bin/ in system image. And if I run the emulator I can see the binary file in /system/bin. The permissions are the same as the other executables (-rwxr-xr-x) and, according to file, this is an ARM binary (ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped).

But when I run it on the emulator, it says:

# binary_name
binary_name: not found

I have straced it and this is what I can see:

# strace binary_name
execve("/system/bin/binary_name", ["binary_name"], [/* 9 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec", 12strace: exec)            = 12
write(2, ": ", 2: )                       = 2
write(2, "No such file or directory", 25No such file or directory) = 25
write(2, "\n", 1
)                       = 1
io_submit(1, -1344063348, {...} <unfinished ... exit status 1>

But the file is there, and strace is able to find it.

Any idea of what can be happening?

UPDATE: As Kristof says, this is probably a problem of dynamic linking, but I don't have ldd for Android ARM...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

π浅易 2024-08-01 09:09:14

可能有些需要的动态库找不到。

尝试 'ldd binary_name'

如果可以找到所有库,输出应该看起来有点像这样。
缺失的库应明确标记。

linux-gate.so.1 =>  (0xb7fbf000)
libcap.so.2 => /lib/libcap.so.2 (0xb7fa7000)
libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7fa3000)
libncursesw.so.5 => /lib/libncursesw.so.5 (0xb7f64000)
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7f3e000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7dde000)
libattr.so.1 => /lib/libattr.so.1 (0xb7dd9000)
/lib/ld-linux.so.2 (0xb7fc0000)

Perhaps some of the required dynamic libraries can't be found.

Try 'ldd binary_name'

The output should look a little like this if all libraries can be found.
Missing libraries should be clearly marked.

linux-gate.so.1 =>  (0xb7fbf000)
libcap.so.2 => /lib/libcap.so.2 (0xb7fa7000)
libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7fa3000)
libncursesw.so.5 => /lib/libncursesw.so.5 (0xb7f64000)
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7f3e000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7dde000)
libattr.so.1 => /lib/libattr.so.1 (0xb7dd9000)
/lib/ld-linux.so.2 (0xb7fc0000)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文