验证Android NDK编译库是否正确编译

时间:2017-01-03 08:07:44

标签: android-ndk

我有许多使用CMake或Automake构建的库,我希望确保它们针对各种体系结构进行了正确编译。具体来说,我想确保我为armeabi和armeabi-v7a定位的库是使用ARM v5或ARM v7-a编译的。

1 个答案:

答案 0 :(得分:2)

我发现linux上的readelf提供了一定程度的确定性,即库是使用所需的选项编译的,并且您不需要在Linux上,因为该工具位于NDK中。以下示例使用NDK r13b与Clang编译。

# -h option instead of -A is helpful if you're inspecting x86 binaries
arm-linux-androideabi-readelf -A library.so 

readelf位于NDK工具链中,因此即使您使用的是macOS,仍然可以使用它。

armeabi

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "5TE"
  Tag_CPU_arch: v5TE
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_optimization_goals: Aggressive Speed

armeabi-V7A

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM v7"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3
  Tag_Advanced_SIMD_arch: NEONv1
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: Deprecated
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_CPU_unaligned_access: v6