Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine ABI of Android .so file (i.e. armeabi or armeabi-v7a)?

I have a .so file provided by a third-party vendor that is to be included in my Android application. I do not have access to the source code nor can I (easily) contact the vendor.

Is there a way for me to figure out by examining the .so file whether or not it was compiled targeting the armeabi or armeabi-v7a ABI?

I'm asking for two reasons. First, I prefer for it to have been compiled targeting the armeabi-v7a ABI to get the improved performance compared to armeabi; knowing this will give me confidence that I'm getting the best possible performance. Also, I would like to name the directory in which the .so files live appropriately (i.e. name the folder "armeabi" or "armeabi-v7a" corresponding to the ABI that it was compiled targeting).

like image 528
denversc Avatar asked Mar 24 '14 21:03

denversc


2 Answers

readelf in Android SDK should solve something like this easier:

PATH(may change based on your own platform): sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-readelf

$ arm-linux-androideabi-readelf -A liba.so
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
  Tag_DIV_use: Not allowed
like image 91
imcaspar Avatar answered Oct 19 '22 23:10

imcaspar


I ended up disassembling the .so files using the arm-linux-androideabi-objdump program from the Android NDK. In the disassembled code I found the vmaxnm.f32 instruction, which is present in the armeabi-v7a instruction set but not in armeabi. Based on that I concluded that the .so was compiled targeting armeabi-v7a. There are probably other instructions that I could have looked for but I'm not at all familiar with the ARM instruction set to be able to tell. I got lucky that this one was fairly obvious (being that it is a floating point operation, one of the major differences between armeabi and armeabi-v7a). Thanks for the ideas to those who posted.

like image 24
denversc Avatar answered Oct 20 '22 00:10

denversc