Advertisement
Guest User

SupportedABIs

a guest
Dec 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. On this page
  2. Supported ABIs
  3. Generating Code for a Specific ABI
  4. ABI Management on the Android Platform
  5. Different Android handsets use different CPUs, which in turn support different instruction sets. Each combination of CPU and instruction sets has its own Application Binary Interface, or ABI. The ABI defines, with great precision, how an application's machine code is supposed to interact with the system at runtime. You must specify an ABI for each CPU architecture you want your app to work with.
  6.  
  7. A typical ABI includes the following information:
  8.  
  9. The CPU instruction set(s) that the machine code should use.
  10. The endianness of memory stores and loads at runtime.
  11. The format of executable binaries, such as programs and shared libraries, and the types of content they support.
  12. Various conventions for passing data between your code and the system. These conventions include alignment constraints, as well as how the system uses the stack and registers when it calls functions.
  13. The list of function symbols available to your machine code at runtime, generally from very specific sets of libraries.
  14. This page enumerates the ABIs that the NDK supports, and provides information about how each ABI works. For a list of ABI issues for 32-bit systems, see 32-bit ABI bugs
  15.  
  16. Supported ABIs
  17. Each ABI supports one or more instruction sets. Table 1 provides an at-a-glance overview of the instruction sets each ABI supports.
  18.  
  19. Table 1. ABIs and supported instruction sets.
  20.  
  21. ABI Supported Instruction Set(s)    Notes
  22. armeabi
  23. ARMV5TE and later
  24. Thumb-1
  25. Deprecated in r16. Will be removed in r17. No hard float.
  26. armeabi-v7a
  27. armeabi
  28. Thumb-2
  29. VFPv3-D16
  30. Other, optional
  31. Incompatible with ARMv5, v6 devices.
  32. arm64-v8a  
  33. AArch-64
  34. x86
  35. x86 (IA-32)
  36. MMX
  37. SSE/2/3
  38. SSSE3
  39. No support for MOVBE or SSE4.
  40. x86_64 
  41. x86-64
  42. MMX
  43. SSE/2/3
  44. SSSE3
  45. SSE4.1, 4.2
  46. POPCNT
  47. mips   
  48. MIPS32r1 and later
  49. Deprecated in r16. Will be removed in r17. Uses hard-float, and assumes a CPU:FPU clock ratio of 2:1 for maximum compatibility. Provides neither micromips nor MIPS16.
  50. mips64 
  51. MIPS64r6
  52. Deprecated in r16. WIll be removed in r17.
  53. More detailed information about each ABI appears below.
  54.  
  55. armeabi
  56. Note: This ABI is deprecated in NDK r16 and will be removed in NDK r17.
  57.  
  58. This ABI is for ARM-based CPUs that support at least the ARMv5TE instruction set. Please refer to the following documentation for more details:
  59.  
  60. ARM Architecture Reference Manual
  61. Procedure Call Standard for the ARM Architecture
  62. ARM ELF File Format
  63. Application Binary Interface (ABI) for the ARM Architecture
  64. Base Platform ABI for the ARM Architecture
  65. C Library ABI for the ARM Architecture
  66. C++ ABI for the ARM Architecture
  67. Run-time ABI for the ARM Architecture
  68. ELF System V Application Binary Interface
  69. Generic/Itanium C++ ABI
  70. The AAPCS standard defines EABI as a family of similar but distinct ABIs. Also, Android follows the little-endian ARM GNU/Linux ABI.
  71.  
  72. This ABI does not support hardware-assisted floating point computations. Instead, all floating-point operations use software helper functions from the compiler's libgcc.a static library.
  73.  
  74. The armeabi ABI supports ARM’s Thumb (a.k.a. Thumb-1) instruction set. The NDK generates Thumb code by default unless you specify different behavior using the LOCAL_ARM_MODE variable in your Android.mk file.
  75.  
  76. armeabi-v7a
  77. This ABI extends armeabi to include several CPU instruction set extensions. The instruction extensions that this Android-specific ABI supports are:
  78.  
  79. The Thumb-2 instruction set extension, which provides performance comparable to 32-bit ARM instructions with similar compactness to Thumb-1.
  80. The VFP hardware-FPU instructions. More specifically, VFPv3-D16, which includes 16 dedicated 64-bit floating point registers, in addition to another 16 32-bit registers from the ARM core.
  81. Other extensions that the v7-a ARM spec describes, including Advanced SIMD (a.k.a. NEON), VFPv3-D32, and ThumbEE, are optional to this ABI. Since their presence is not guaranteed, the system should check at runtime whether the extensions are available. If they are not, you must use alternative code paths. This check is similar to the one that the system typically performs to check or use MMX, SSE2, and other specialized instruction sets on x86 CPUs.
  82.  
  83. For information about how to perform these runtime checks, refer to The cpufeatures Library. Also, for information about the NDK's support for building machine code for NEON, see NEON Support.
  84.  
  85. The armeabi-v7a ABI uses the -mfloat-abi=softfp switch to enforce the rule that the compiler must pass all double values in core register pairs during function calls, instead of dedicated floating-point ones. The system can perform all internal computations using the FP registers. Doing so speeds up the computations greatly.
  86.  
  87. arm64-v8a
  88. This ABI is for ARMv8-based CPUs that support AArch64. It also includes the NEON and VFPv4 instruction sets.
  89.  
  90. For more information, see the ARMv8 Technology Preview, and contact ARM for further details.
  91.  
  92. x86
  93. This ABI is for CPUs supporting the instruction set commonly referred to as "x86" or "IA-32". Characteristics of this ABI include:
  94.  
  95. Instructions normally generated by GCC with compiler flags such as the following:
  96. -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32
  97. These flags target the the Pentium Pro instruction set, along with the the MMX, SSE, SSE2, SSE3, and SSSE3 instruction set extensions. The generated code is an optimization balanced across the top Intel 32-bit CPUs.
  98.  
  99. For more information on compiler flags, particularly related to performance optimization, refer to GCC x86 performance hints.
  100.  
  101. Use of the standard Linux x86 32-bit calling convention, as opposed to the one for SVR. For more information, see section 6, "Register Usage", of Calling conventions for different C++ compilers and operating systems.
  102. The ABI does not include any other optional IA-32 instruction set extensions, such as:
  103.  
  104. MOVBE
  105. Any variant of SSE4.
  106. You can still use these extensions, as long as you use runtime feature-probing to enable them, and provide fallbacks for devices that do not support them.
  107.  
  108. The NDK toolchain assumes 16-byte stack alignment before a function call. The default tools and options enforce this rule. If you are writing assembly code, you must make sure to maintain stack alignment, and ensure that other compilers also obey this rule.
  109.  
  110. Refer to the following documents for more details:
  111.  
  112. GCC online documentation: Intel 386 and AMD x86-64 Options
  113. Calling conventions for different C++ compilers and operating systems
  114. Intel IA-32 Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference
  115. Intel IA-32 Intel Architecture Software Developer's Manual, Volume 3: System Programming Guide
  116. System V Application Binary Interface: Intel386 Processor Architecture Supplement
  117. x86_64
  118. This ABI is for CPUs supporting the instruction set commonly referred to as "x86-64." It supports instructions that GCC typically generates with the following compiler flags:
  119.  
  120. -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel
  121. These flags target the x86-64 instruction set, according to the GCC documentation. along with the MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, and POPCNT instruction-set extensions. The generated code is an optimization balanced across the top Intel 64-bit CPUs.
  122.  
  123. For more information on compiler flags, particularly related to performance optimization, refer to GCC x86 Performance.
  124.  
  125. This ABI does not include any other optional x86-64 instruction set extensions, such as:
  126.  
  127. MOVBE
  128. SHA
  129. AVX
  130. AVX2
  131. You can still use these extensions, as long as you use runtime feature probing to enable them, and provide fallbacks for devices that do not support them.
  132.  
  133. Refer to the following documents for more details:
  134.  
  135. Calling conventions for different C++ compilers and operating systems
  136. Intel64 and IA-32 Architectures Software Developer's Manual, Volume 2: Instruction Set Reference
  137. Intel64 and IA-32 Intel Architecture Software Developer's Manual Volume 3: System Programming
  138. mips
  139. Note: This ABI is deprecated in NDK r16 and will be removed in NDK r17.
  140.  
  141. This ABI is for MIPS-based CPUs that support at least the MIPS32r1 instruction set. It includes the following features:
  142.  
  143. MIPS32 revision 1 ISA
  144. Little-endian
  145. O32
  146. Hard-float
  147. No DSP application-specific extensions
  148. For more information, please refer to the following documentation:
  149.  
  150. Architecture for Programmers ("MIPSARCH")
  151. ELF System V Application Binary Interface
  152. Itanium/Generic C++ ABI
  153. For more specific details, see MIPS32 Architecture. Answers to common questions are in the MIPS FAQ.
  154.  
  155. mips64
  156. Note: This ABI is deprecated in NDK r16 and will be removed in NDK r17.
  157.  
  158. This ABI is for MIPS64 R6. For more information, see MIPS64 Architecture.
  159.  
  160. Generating Code for a Specific ABI
  161. By default, the NDK targets for all non-deprecated ABIs. You can target a single ABI by setting APP_ABI in your Application.mk file. The following snippet shows a few examples of using APP_ABI
  162.  
  163. APP_ABI := arm64-v8a  # Target only arm64-v8a
  164. APP_ABI := all  # Target all ABIs, including those that are deprecated.
  165. APP_ABI := armeabi-v7a x86_64  # Target only armeabi-v7a and x86_64.
  166. For more information on the values you can specify for APP_ABI, see Application.mk.
  167.  
  168. The default behavior of the build system is to include the binaries for each ABI in a single APK, also known as a fat APK. A fat APK is much larger than one containing only the binaries for a single ABI; the tradeoff is gaining wider compatibility, but at the expense of a larger APK. It is strongly recommended that you take advantage of split APKs to reduce the size of your APKs while still maintaining maximum device compatibility.
  169.  
  170. At installation time, the package manager unpacks only the most appropriate machine code for the target device. For details, see Automatic extraction of native code at install time.
  171.  
  172. ABI Management on the Android Platform
  173. This section provides details about how the Android platform manages native code in APKs.
  174.  
  175. Native code in app packages
  176. Both the Play Store and Package Manager expect to find NDK-generated libraries on filepaths inside the APK matching the following pattern:
  177.  
  178. /lib/<abi>/lib<name>.so
  179. Here, <abi> is one of the ABI names listed under Supported ABIs, and <name> is the name of the library as you defined it for the LOCAL_MODULE variable in the Android.mk file. Since APK files are just zip files, it is trivial to open them and confirm that the shared native libraries are where they belong.
  180.  
  181. If the system does not find the native shared libraries where it expects them, it cannot use them. In such a case, the app itself has to copy the libraries over, and then perform dlopen().
  182.  
  183. In a fat APK, each library resides under a directory whose name matches a corresponding ABI. For example, a fat APK may contain:
  184.  
  185. /lib/armeabi/libfoo.so
  186. /lib/armeabi-v7a/libfoo.so
  187. /lib/arm64-v8a/libfoo.so
  188. /lib/x86/libfoo.so
  189. /lib/x86_64/libfoo.so
  190. /lib/mips/libfoo.so
  191. /lib/mips64/libfoo.so
  192. Note: ARMv7-based Android devices running 4.0.3 or earlier install native libraries from the armeabi directory instead of the armeabi-v7a directory if both directories exist. This is because /lib/armeabi/ comes after /lib/armeabi-v7a/ in the APK. This issue is fixed from 4.0.4.
  193.  
  194. Android Platform ABI support
  195. The Android system knows at runtime which ABI(s) it supports, because build-specific system properties indicate:
  196.  
  197. The primary ABI for the device, corresponding to the machine code used in the system image itself.
  198. Optionally, secondary ABIs, corresponding to other ABI that the system image also supports.
  199. This mechanism ensures that the system extracts the best machine code from the package at installation time.
  200.  
  201. For best performance, you should compile directly for the primary ABI. For example, a typical ARMv5TE-based device would only define the primary ABI: armeabi. By contrast, a typical, ARMv7-based device would define the primary ABI as armeabi-v7a and the secondary one as armeabi, since it can run application native binaries generated for each of them.
  202.  
  203. 64-bit devices also support their 32-bit variants. Using arm64-v8a devices as an example, the device can also run armeabi and armeabi-v7a code. Note, however, that you application will perform much better on 64-bit devices if it targets arm64-v8a rather than relying on the device running the armeabi-v7a version of your application.
  204.  
  205. Many x86-based devices can also run armeabi-v7a and armeabi NDK binaries. For such devices, the primary ABI would be x86, and the second one, armeabi-v7a.
  206.  
  207. A typical MIPS-based device only defines a primary abi: mips.
  208.  
  209. Automatic extraction of native code at install time
  210. When installing an application, the package manager service scans the APK, and looks for any shared libraries of the form:
  211.  
  212. lib/<primary-abi>/lib<name>.so
  213. If none is found, and you have defined a secondary ABI, the service scans for shared libraries of the form:
  214.  
  215. lib/<secondary-abi>/lib<name>.so
  216. When it finds the libraries that it's looking for, the package manager copies them to /lib/lib<name>.so, under the application's data directory (data/data/<package_name>/lib/).
  217.  
  218. If there is no shared-object file at all, the application builds and installs, but crashes at runtime.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement