如何判断 .so 是否用于 android 和右臂版本?

How to tell if a .so is for android and for the right arm version?

我有一个 .so,我想确认它是否来自 android,以及它是哪个 arm 版本。比如:它适用于 armv7-a 吗? armv8? x86 android 或 x86 linux?

我在 Linux,但 macOS 命令也很棒。也许两者都适用。

在 GNU/Linux 和 macOS 上您都可以使用 file:

$ file */libtest.so                                                                                                                                              
arm64-v8a/libtest.so:   ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e6d1f9085a87057035b5ad7b0b1e3b66a4d7fecf, with debug_info, not stripped
armeabi-v7a/libtest.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=ba43c719e2ed6988e753f80163f4fca3f309d4ab, with debug_info, not stripped
x86/libtest.so:         ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=615ccead713c8b8a9155a229f9d530c1126c984b, with debug_info, not stripped
x86_64/libtest.so:      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=390e1469af1f53ae3456f8a0464180d2bf3f6d18, with debug_info, not stripped

区分 Android 和 Linux 比较棘手,因为 Android 基于 Linux,并运行 Linux 二进制文件和库。