`

【翻译】(7)CPU Arch ABIs

 
阅读更多

-----------------

英文文档见android-ndk-r5b的documentation.html

属于Android Native Development Kit (NDK)的一部分

见http://developer.android.com/sdk/ndk/(需要代理)

翻译仅个人见解

-----------------

 

Android Native CPU ABI Management

 

Android原生CPU ABI 管理

 

Introduction:

 

介绍:

=============

 

Every piece of native code generated with the Android NDK matches a given "Application Binary Interface" (ABI) that defines exactly how your application's machine code is expected to interact with the system at runtime.

 

每个用Android NDK生成的原生代码匹配一个给定的“应用程序二进制接口”(ABI),ABI精确地定义了你的应用程序及其代码期待如何在运行时如何和系统交互。

 

A typical ABI describes things in *excruciating* details, and will typically include the following information:

 

一个典型的ABI用艰涩的细节描述事情,通常包含以下信息:

 

  - the CPU instruction set that the machine code should use

 

  - 机器代码应该使用的CPU指令集

 

  - the endianness of memory stores and loads at runtime

 

  - 运行时的内存存取的排列次序(注:通常分为大端和小端)

 

  - the format of executable binaries (shared libraries, programs, etc...) and what type of content is allowed/supported in them.

 

  - 可执行二进制文件(动态库,程序,等等)的格式以及它们里面允许和支持的是什么类型的内容。

 

  - various conventions used to pass data between your code and the system (e.g. how registers and/or the stack are used when functions are called, alignment constraints, etc...)

 

  - 在你的代码和系统之间传递数据时使用的不同约定(例如,在函数调用时寄存器和/或堆栈如何使用,对齐限制,等等)

 

  - alignment and size constraints for enum types, structure fields and arrays.

 

  - 枚举类型的对齐和大小限制,结构体字段和数组。

 

  - the list of function symbols available to your machine code at runtime, generally from a very specific selected set of libraries.

 

  - 在运行时对你的机器代码可用的函数符号列表,通常来源于一个非常特定的库集合。

 

This document lists the exact ABIs supported by the Android NDK and the official Android platform releases.

 

这个文档列出Android NDK和官方Android平台发布版支持的精确ABI。

 

I. Supported ABIs:

 

一、支持的ABI:

==================

 

Each supported ABI is identified by a unique name.

 

每个支持的ABI通过一个唯一的名称标识。

 

 I.1. 'armeabi'

 

 一.1. 'armeabi'

 --------------

 

  This is the name of an ABI for ARM-based CPUs that support *at* *least* the ARMv5TE instruction set. Please refer to following documentation for more details:

 

  这是针对基于ARM CPU的ABI名称,它至少支持ARMv5TE指令集。详细请参考以下文档:

 

   - ARM Architecture Reference manual                (a.k.a  ARMARM)

 

   - ARM架构参考手册(即ARMARM)

 

   - Procedure Call Standard for the ARM Architecture (a.k.a. AAPCS)

 

   - ARM架构的过程调用标准(即AAPCS)

 

   - ELF for the ARM Architecture                     (a.k.a. ARMELF)

 

   - ARM架构的ELF格式(即ARMELF)

 

   - ABI for the ARM Architecture                     (a.k.a. BSABI)

 

   - ARM架构的ABI(即BSABI)

 

   - Base Platform ABI for the ARM Architecture       (a.k.a. BPABI)

 

   - ARM架构的基础平台ABI(即BPABI)

 

   - C Library ABI for the ARM Architecture           (a.k.a. CLIABI)

 

   - ARM架构的C库ABI(即CLIABI)

 

   - C++ ABI for the ARM Architecture                 (a.k.a. CPPABI)

 

   - ARM架构的C++ ABI(即CPPABI)

 

   - Runtime ABI for the ARM Architecture             (a.k.a. RTABI)

 

   - ARM架构的运行时ABI(即RTABI)

 

   - ELF System V Application Binary Interface (DRAFT - 24 April 2001)

 

   - ELF系统V应用程序二进制接口(DRAFT - 2001年4月24日)

 

   - Generic C++ ABI  (http://www.codesourcery.com/public/cxx-abi/abi.html)

 

   - 泛型C++ ABI(http://www.codesourcery.com/public/cxx-abi/abi.html)

 

  Note that the AAPCS standard defines 'EABI' as a moniker used to specify a _family_ of similar but distinct ABIs. Android follows the little-endian ARM GNU/Linux ABI as documented in the following document:

 

  注意AAPCS标准定义EABI作为一个绰号,用于指定一类相似但不同的ABI。Android允许在以下文档中介绍的小端ARM GNU/Linux ABI:

 

      http://www.codesourcery.com/gnu_toolchains/arm/arm_gnu_linux_abi.pdf

 

  With the exception that wchar_t is only one byte. This should not matter in practice since wchar_t is simply *not* really supported by the Android platform anyway.

 

  例外的是wchar_t只有一个字节。实际上没有关系,因为事实上wchar_t直接就不被Android平台支持。

 

  This ABI does *not* support hardware-assisted floating point computations. Instead, all FP operations are performed through software helper functions that come from the compiler's libgcc.a static library.

 

  这种ABI不支持硬件辅助的浮点计算。反之,所有浮点操作由编译器的libgcc.a静态库的软件辅助函数执行。

 

  Thumb (a.k.a. Thumb-1) instructions are supported. Note that the NDK will generate thumb code by default, unless you define LOCAL_ARM_MODE in your Android.mk (see docs/ANDROID-MK.html for all details).

 

  支持Thumb(即Thumb-1)指令。注意NDK默认将生成thumb,除非你在你的Android.mk中定义LOCAL_ARM_MODE(所有细节请参考docs/ANDROID-MK.html)

 

 I.2. 'armeabi-v7a'

 

 一.2. armeabi-v7a

 ------------------

 

  This is the name of another ARM-based CPU ABI that *extends* 'armeabi' to include a few CPU instruction set extensions as described in the following document:

 

  这是另一种基于ARM的CPU ABI,它扩展了armeabi以包含少量在下面的文档中描述的CPU指令集扩展。

 

  - ARM Architecture v7-a Reference Manual

 

  - ARM架构V7-a参考手册

 

  The instruction extensions supported by this Android-specific ABI are:

 

  被这个Android特定的ABI支持的指令扩展有:

 

     - The Thumb-2 instruction set extension.

 

     - Thumb-2指令集扩展。

 

     - The VFP hardware FPU instructions.

 

     - 向量浮点硬件的浮点处理单元指令。

 

  More specifically, VFPv3-D16 is being used, which corresponds to 16 dedicated 64-bit floating point registers provided by the CPU.

 

  更特别地,VFPv3-D16使用这种ABI,对应CPU提供的16个专用64位浮点寄存器。

 

  Other extensions described by the v7-a ARM like Advanced SIMD (a.k.a. NEON), VFPv3-D32 or ThumbEE are optional to this ABI, which means that developers should check *at* *runtime* whether the extensions are available and provide alternative code paths if this is not the case.

 

  其它扩展由v7-a ARM描述,像高级SIMD(即NEON),VFPv3-D32或ThumbEE对于这种ABI是可选的,意味着开发者应该在运行期检查扩展是否可用,并且在它们不可用的时候提供可替换的代码路径。

 

  (Just like one typically does on x86 systems to check/use MMX/SSE2/etc... specialized instructions).

 

  (就像有些人通常在x86系统上为了检查和使用MMX/SSE2/等等的特殊化指令而做的事情那样)。

 

  You can check docs/CPU-FEATURES.html to see how to perform these runtime checks, and docs/CPU-ARM-NEON.html to learn about the NDK's support for building NEON-capable machine code too.

 

  你可以检查docs/CPU-FEATURES.html以查看如何执行这些运行期检查,还可以查看docs/CPU-ARM-NEON.html以知道关于NDK对构建NEON能力机器代码的支持。

 

  IMPORTANT NOTE: This ABI enforces that all double values are passed during function calls in 'core' register pairs, instead of dedicated FP ones. However, all internal computations can be performed with the FP registers and will be greatly sped up.

 

  重要注意:这种ABI强制在函数调用中所有double值在“核心”寄存器对中传递。而不是专用的浮点寄存器,所有内部计算可以用浮点寄存器执行而将大大地加快速度。

 

  This little constraint, while resulting in a slight decrease of performance, ensures binary compatibility with all existing 'armeabi' binaries.

 

  这个小限制,当导致轻微的性能下降时,确保对所有现存armeabi二进制文件的二进制兼容性。

 

  IMPORTANT NOTE: The 'armeabi-v7a' machine code will *not* run on ARMv5 or ARMv6 based devices.

 

  重要注意:armeabi-v7a机器代码将不能运行于基于ARMv5和ARMv6的设备上。

 

 I.3. 'x86'

 

 一.3. x86

 ----------

 

  This is the name of an ABI for CPUs supporting the instruction set commonly named 'x86' or 'IA-32'. More specifically, this targets the instruction set commonly referenced as 'i686' or 'Pentium Pro' in documents such as:

 

  这是针对支持一般称为x86或IA-32的指令集的CPU的ABI名称。更特别地,它的目标是在以下文档中通常称为i686或Pentium Pro的指令集:

 

    Intel IA-32 Intel Architecture Software Developer's Manual volume 2: Instruction Set Reference

 

Intel IA-32 Intel架构软件开发者手册卷2:指令集参考

 

  IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT:

 

  重要:

 

      THE 'x86' ABI IS AN EXPERIMENTAL FEATURE THAT IS NOT FULLY SUPPORTED YET BY THIS NDK RELEASE. TRYING TO USE IT WILL RESULT IN AN ERROR DURING THE BUILD PROCESS.

 

      x86 ABI是一个实验性质的特性,在这个NDK发布版中尚未完全支持。尝试使用它将导致构建过程错误。

 

  Note that optional features like MMX/SSE2/SSE3/3DNow!/KVM must be explicitly tested at runtime by the generated machine code and cannot be assumed to be everywhere.

 

  注意可选特性像MMX/SSE2/SSE3/3DNow!/KVM必须在运行期被生成的机器代码显式地测试,不能假设它在任何地方都存在。

 

II. Generating code for a specific ABI:

 

二、生成特定ABI的代码:

=======================================

 

By default, the NDK will generate machine code for the 'armeabi' ABI. You can however add the following line to your Application.mk to generate ARMv7-a compatible machine code instead:

 

默认,NDK将生成armeabi ABI的机器代码。然而你可以改为添加以下行到你的Application.mk以生成ARMv7-a兼容的机器代码。

 

   APP_ABI := armeabi-v7a

 

It is also possible to build machine code for *two* distinct ABIs by using:

 

还可以通过使用以下方法构建两种不同ABI的机器代码:

 

   APP_ABI := armeabi armeabi-v7a

 

This will instruct the NDK to build two versions of your machine code: one for each ABI listed on this line. Both libraries will be copied to your application project path and will be ultimately packaged into your .apk.

 

这将命令NDK构建你的两种版本的机器代码:对应这行中列出的每种ABI。两个库将被复制到你的应用程序工程路径并且最终被打包进你的.apk

 

Such a package is called a "fat binary" in Android speak since it contains machine code for more than one CPU architecture. At installation time, the package manager will only unpack the most appropriate machine code for the target device. See below for details.

 

这种包用Android的话来说就是“肥胖的二进制库”,因为它包含多于一种CPU架构的机器代码。在安装期,包管理器将只抽取对目标设别最合适的机器代码。详细见下。

 

III. ABI Management on the Android platform:

 

三、Android平台的ABI管理

============================================

 

This section provides specific details about how the Android platform manages native code in application packages.

 

这个章节提供关于Android平台管理应用程序包中原生代码的特定细节。

 

  III.1. Native code in Application Packages:

 

  三.1. 应用程序包内的原生代码

  -------------------------------------------

 

    It is expected that shared libraries generated with the NDK are stored in the final application package (.apk) at locations of the form:

 

    期望NDK所生成的动态库以这种格式的位置保存在最终的应用程序包(.apk)中:

 

       lib/<abi>/lib<name>.so

 

    Where <abi> is one of the ABI names listed in section II above, and <name> is a name that can be used when loading the shared library from the VM as in:

 

这里<abi>是上面第二节列举的ABI名称之一,而<name>是在虚拟机加载动态库时使用的名称,就像这样:

 

        System.loadLibrary("<name>");

 

    Since .apk files are just zip files, you can trivially list their content with a command like:

 

因为.apk文件只是zip文件,你可以用这样的命令简单地列出它们的内容:

 

        unzip -l <apk>

 

    to verify that the native shared libraries you want are indeed at the proper location. You can also place native shared libraries at other locations within the .apk, but they will be ignored by the system, or more precisely by the steps described below; you will need to extract/install them manually in your application.

 

以验证你想要的原生动态库确实是在合适的位置。你还可以在.apk中把原生动态库放在其它位置,但它们将被系统忽略,或者更准确地按照下面的描述的步骤做;你将需要在你的应用程序中手工地抽取或安装它们。

 

    In the case of a "fat" binary, two distinct libraries are thus placed in the  .apk, for example at:

 

对于“肥胖”的二进制库文件,在.apk中放置两种不同的库,例如:

        lib/armeabi/libfoo.so

        lib/armeabi-v7a/libfoo.so

 

  III.2. Android Platform ABI support:

 

  三.2. Android平台ABI支持:

  ------------------------------------

 

    The Android system knows at runtime which ABI(s) it supports. More precisely, up to two build-specific system properties are used to indicate:

 

Android系统在运行期知道它支持哪个或哪些ABI。更准确说,使用多达两个的构建特定的系统属性来指出:

 

    - the 'primary' ABI for the device, corresponding to the machine code used in the system image itself.

 

- 设备的第一ABI,对应于系统镜像自身使用的机器代码。

 

    - an optional 'secondary' ABI, corresponding to another ABI that is also supported by the system image.

 

- 一个可选的第二ABI,对应系统镜像支持的另一个ABI。

 

    For example, a typical ARMv5TE-based device would only define the primary ABI as 'armeabi' and not define a secondary one.

 

    例如,一个典型的基于ARMv5TE的设备将只把第一ABI定义为armeabi,而不会定义第二ABI。

 

    On the other hand, a typical ARMv7-based device would define the primary ABI to 'armeabi-v7a' and the secondary one to 'armeabi' since it can run application native binaries generated for both of them.

 

另一方面,一个典型的基于ARMv7的设备将把第一ABI定义为armeabi-v7a,而把第二ABI定义为armeabi,因为它都可以运行由它们生成的应用程序原生二进制文件。

  III.3. Automatic extraction of native code at install time:

 

  三.3. 安装期本地代码的自动抽取

  -----------------------------------------------------------

 

    When installing an application, the package manager service will scan the .apk and look for any shared library of the form:

 

    当安装一个应用程序,包管理器服务将扫描.apk并且寻找这种格式的动态库:

 

         lib/<primary-abi>/lib<name>.so

 

    If one is found, then it is copied under $APPDIR/lib/lib<name>.so, where $APPDIR corresponds to the application's specific data directory.

 

    如果找到一个,那么它被复制到$APPDIR/lib/lib<name>.so,这里$APPDIR对应于应用程序的特定数据目录。

 

    If none is found, and a secondary ABI is defined, the service will then scan for shared libraries of the form:

 

如果什么都没找到,而定义了一个第二ABI,那么服务将继续以这种格式寻找动态库:

 

        lib/<secondary-abi>/lib<name>.so

 

    If anything is found, then it is copied under $APPDIR/lib/lib<name>.so

 

    如果找到文件,那么它被复制到$APPDIR/lib/lib<name>.so。

 

    This mechanism ensures that the best machine code for the target device is automatically extracted from the package at installation time.

 

    这种机制确保对于目标设备最佳的机器代码在安装期被自动从包中抽取出来。

 

 

分享到:
评论

相关推荐

    SNS单模无芯光纤仿真与传感器结构特性分析——基于Rsoft beamprop模块

    内容概要:本文主要探讨了SNS单模无芯光纤的仿真分析及其在通信和传感领域的应用潜力。首先介绍了模间干涉仿真的重要性,利用Rsoft beamprop模块模拟不同模式光在光纤中的传播情况,进而分析光纤的传输性能和模式特性。接着讨论了光纤传输特性的仿真,包括损耗、色散和模式耦合等参数的评估。随后,文章分析了光纤的结构特性,如折射率分布、包层和纤芯直径对性能的影响,并探讨了镀膜技术对光纤性能的提升作用。最后,进行了变形仿真分析,研究外部因素导致的光纤变形对其性能的影响。通过这些分析,为优化光纤设计提供了理论依据。 适合人群:从事光纤通信、光学工程及相关领域的研究人员和技术人员。 使用场景及目标:适用于需要深入了解SNS单模无芯光纤特性和优化设计的研究项目,旨在提高光纤性能并拓展其应用场景。 其他说明:本文不仅提供了详细的仿真方法和技术细节,还对未来的发展方向进行了展望,强调了SNS单模无芯光纤在未来通信和传感领域的重要地位。

    发那科USM通讯程序socket-rece

    发那科USM通讯程序socket-set

    嵌入式八股文面试题库资料知识宝典-WIFI.zip

    嵌入式八股文面试题库资料知识宝典-WIFI.zip

    JS+HTML源码与image

    源码与image

    物流行业车辆路径优化:基于遗传算法和其他优化算法的MATLAB实现及应用

    内容概要:本文详细探讨了物流行业中路径规划与车辆路径优化(VRP)的问题,特别是针对冷链物流、带时间窗的车辆路径优化(VRPTW)、考虑充电桩的车辆路径优化(EVRP)以及多配送中心情况下的路径优化。文中不仅介绍了遗传算法、蚁群算法、粒子群算法等多种优化算法的理论背景,还提供了完整的MATLAB代码及注释,帮助读者理解这些算法的具体实现。此外,文章还讨论了如何通过MATLAB处理大量数据和复杂计算,以得出最优的路径方案。 适合人群:从事物流行业的研究人员和技术人员,尤其是对路径优化感兴趣的开发者和工程师。 使用场景及目标:适用于需要优化车辆路径的企业和个人,旨在提高配送效率、降低成本、确保按时交付货物。通过学习本文提供的算法和代码,读者可以在实际工作中应用这些优化方法,提升物流系统的性能。 其他说明:为了更好地理解和应用这些算法,建议读者参考相关文献和教程进行深入学习。同时,实际应用中还需根据具体情况进行参数调整和优化。

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_8.doc.zip

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_8.doc.zip

    基于灰狼优化算法的城市路径规划Matlab实现——解决TSP问题

    内容概要:本文介绍了基于灰狼优化算法(GWO)的城市路径规划优化问题(TSP),并通过Matlab实现了该算法。文章详细解释了GWO算法的工作原理,包括寻找猎物、围捕猎物和攻击猎物三个阶段,并提供了具体的代码示例。通过不断迭代优化路径,最终得到最优的城市路径规划方案。与传统TSP求解方法相比,GWO算法具有更好的全局搜索能力和较快的收敛速度,适用于复杂的城市环境。尽管如此,算法在面对大量城市节点时仍面临运算时间和参数设置的挑战。 适合人群:对路径规划、优化算法感兴趣的科研人员、学生以及从事交通规划的专业人士。 使用场景及目标:①研究和开发高效的路径规划算法;②优化城市交通系统,提升出行效率;③探索人工智能在交通领域的应用。 其他说明:文中提到的代码可以作为学习和研究的基础,但实际应用中需要根据具体情况调整算法参数和优化策略。

    嵌入式八股文面试题库资料知识宝典-Intel3.zip

    嵌入式八股文面试题库资料知识宝典-Intel3.zip

    嵌入式八股文面试题库资料知识宝典-2019京东C++.zip

    嵌入式八股文面试题库资料知识宝典-2019京东C++.zip

    嵌入式八股文面试题库资料知识宝典-北京光桥科技有限公司面试题.zip

    嵌入式八股文面试题库资料知识宝典-北京光桥科技有限公司面试题.zip

    物理学领域十字形声子晶体的能带与传输特性研究及应用

    内容概要:本文详细探讨了十字形声子晶体的能带结构和传输特性。首先介绍了声子晶体作为新型周期性结构在物理学和工程学中的重要地位,特别是十字形声子晶体的独特结构特点。接着从散射体的形状、大小、排列周期等方面分析了其对能带结构的影响,并通过理论计算和仿真获得了能带图。随后讨论了十字形声子晶体的传输特性,即它对声波的调控能力,包括传播速度、模式和能量分布的变化。最后通过大量实验和仿真验证了理论分析的正确性,并得出结论指出散射体的材料、形状和排列方式对其性能有重大影响。 适合人群:从事物理学、材料科学、声学等相关领域的研究人员和技术人员。 使用场景及目标:适用于希望深入了解声子晶体尤其是十字形声子晶体能带与传输特性的科研工作者,旨在为相关领域的创新和发展提供理论支持和技术指导。 其他说明:文中还对未来的研究方向进行了展望,强调了声子晶体在未来多个领域的潜在应用价值。

    嵌入式系统开发_USB主机控制器_Arduino兼容开源硬件_基于Mega32U4和MAX3421E芯片的USB设备扩展开发板_支持多种USB外设接入与控制的通用型嵌入式开发平台_.zip

    嵌入式系统开发_USB主机控制器_Arduino兼容开源硬件_基于Mega32U4和MAX3421E芯片的USB设备扩展开发板_支持多种USB外设接入与控制的通用型嵌入式开发平台_

    e2b8a-main.zip

    e2b8a-main.zip

    少儿编程scratch项目源代码文件案例素材-火柴人跑酷(2).zip

    少儿编程scratch项目源代码文件案例素材-火柴人跑酷(2).zip

    【HarmonyOS分布式技术】远程启动子系统详解:跨设备无缝启动与智能协同的应用场景及未来展望

    内容概要:本文详细介绍了HarmonyOS分布式远程启动子系统,该系统作为HarmonyOS的重要组成部分,旨在打破设备间的界限,实现跨设备无缝启动、智能设备选择和数据同步与连续性等功能。通过分布式软总线和分布式数据管理技术,它能够快速、稳定地实现设备间的通信和数据同步,为用户提供便捷的操作体验。文章还探讨了该系统在智能家居、智能办公和教育等领域的应用场景,展示了其在提升效率和用户体验方面的巨大潜力。最后,文章展望了该系统的未来发展,强调其在技术优化和应用场景拓展上的无限可能性。 适合人群:对HarmonyOS及其分布式技术感兴趣的用户、开发者和行业从业者。 使用场景及目标:①理解HarmonyOS分布式远程启动子系统的工作原理和技术细节;②探索该系统在智能家居、智能办公和教育等领域的具体应用场景;③了解该系统为开发者提供的开发优势和实践要点。 其他说明:本文不仅介绍了HarmonyOS分布式远程启动子系统的核心技术和应用场景,还展望了其未来的发展方向。通过阅读本文,用户可以全面了解该系统如何通过技术创新提升设备间的协同能力和用户体验,为智能生活带来新的变革。

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_1.zip

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_1.zip

    少儿编程scratch项目源代码文件案例素材-激光反弹.zip

    少儿编程scratch项目源代码文件案例素材-激光反弹.zip

    COMSOL相控阵检测技术在有机玻璃斜楔中检测工件内部缺陷的应用研究

    内容概要:本文详细介绍了COMSOL相控阵检测技术在有机玻璃斜楔上放置16阵元进行工件内部缺陷检测的方法。首先阐述了相控阵检测技术的基本原理,特别是通过控制各阵元的激发时间和相位来实现声波的聚焦和扫描。接着,重点解析了横孔缺陷的反射接收波,解释了波的折射现象及其背后的物理原因。最后,通过实例展示了COMSOL模拟声波传播过程的成功应用,验证了该技术的有效性和准确性。 适合人群:从事固体力学、无损检测领域的研究人员和技术人员,尤其是对相控阵检测技术和COMSOL仿真感兴趣的读者。 使用场景及目标:适用于需要精确检测工件内部缺陷的研究和工业应用场景,旨在提高检测精度和效率,确保产品质量和安全。 其他说明:文中提到的声速匹配现象有助于理解波在不同介质间的传播特性,这对优化检测参数设置有重要意义。

    少儿编程scratch项目源代码文件案例素材-极速奔跑者.zip

    少儿编程scratch项目源代码文件案例素材-极速奔跑者.zip

    嵌入式八股文面试题库资料知识宝典-微软_interview.zip

    嵌入式八股文面试题库资料知识宝典-微软_interview.zip

Global site tag (gtag.js) - Google Analytics