For faster navigation, this Iframe is preloading the Wikiwand page for 应用二进制接口.

应用二进制接口

在软件开发中,应用二进制接口(英语:application binary interface,缩写为ABI)是指两程序模块间的接口;通常其中一个程序模块会是函数库或操作系统所提供的服务,而另一边的模块则是用户所执行的程序。

一个ABI定义了机器代码如何存取数据结构与运算程序,此处所定义的界面相当低端并且相依于硬件。而类似概念的API则在原始码定义这些,则较为高阶,并不直接相依于硬件,通常会是人类可阅读的代码。一个ABI常见的样貌即是调用约定:资料怎么成为计算程序的输入或者从中得到输出;x86的调用约定即是一个ABI的例子。

决定要不要采取既定的ABI(不论是否由官方提供),通常由编译器,操作系统或函数库的开发者来决定;然而,如果撰写一个混和多个编程语言的应用程式,就必须直接处理ABI,采用外部函数调用英语Foreign function interface来达成此目的。

描述

[编辑]

ABI涵盖了各种细节,如:

  • 数据类型的大小、布局和对齐;
  • 调用约定(控制着函数的参数如何传送以及如何接受返回值),例如,是所有的参数都通过栈传递,还是部分参数通过寄存器传递;哪个寄存器用于哪个函数参数;通过栈传递的第一个函数参数是最先push到栈上还是最后;
  • 系统调用的编码和一个应用如何向操作系统进行系统调用;
  • 以及在一个完整的操作系统ABI中,目标文件的二进制格式、程序库等等。

一个完整的ABI,像Intel二进制兼容标准英语Intel Binary Compatibility Standard(iBCS)[1],允许支持它的操作系统上的程序不经修改在其他支持此ABI的操作系统上运行。

其他的ABI标准化了一些细节,包括C++名字修饰[2] ,和同一个平台上的编译器之间的调用约定[3],但是不包括跨平台的兼容性。

ABI不同于应用程序接口(API),API定义了原始码和库之间的接口,因此同样的代码可以在支持这个API的任何系统中编译,然而ABI允许编译好的目标代码在使用兼容ABI的系统中无需改动就能运行。 在Unix风格的操作系统中,存在很多运行在同一硬件平台上互相相关但是不兼容的操作系统(尤其是Intel 80386兼容系统)。有一些努力尝试标准化ABI,以减少销售商将程序移植到其他系统时所需的工作。然而,直到现在还没有很成功的例子,虽然Linux标准化工作组正在为Linux做这方面的努力。

EABI

[编辑]

嵌入式应用二进制接口指定了文件格式、数据类型、寄存器使用、堆积组织优化和在一个嵌入式软件中的参数的标准约定。开发者使用自己的汇编语言也可以使用EABI作为与兼容的编译器生成的汇编语言的接口。 支持EABI的编译器创建的目标文件可以和使用类似编译器产生的代码兼容,这样允许开发者链接一个由不同编译器产生的库。EABI与关于通用电脑的ABI的主要区别是应用程式代码中允许使用特权指令,不需要动态链接(有时是禁止的),和更紧凑的堆栈帧组织用来节省内存。[4] 广泛使用EABI的有Power PC[5]ARM.[6][7]

参见

[编辑]

参考资料

[编辑]
  1. ^ Intel Binary Compatibility Standard (iBCS). [2011-01-19]. (原始内容存档于2012-05-27). 
  2. ^ Itanium C++ ABI 互联网档案馆存档,存档日期2008-11-19. (compatible with multiple architectures)
  3. ^ Itanium C++ ABI: Exception Handling 互联网档案馆存档,存档日期2008-05-11. (compatible with multiple architectures)
  4. ^ EABI Summary. PowerPC Embedded Application Binary Interface: 32-Bit Implementation (PDF) Version 1.0. Freescale Semiconductor, Inc. 1995-10-01: 28–30 [2011-01-19]. (原始内容存档 (PDF)于2012-03-16). 
  5. ^ "PowerPC Embedded Processors Application Note"[永久失效链接]
  6. ^ Debian ARM accelerates via EABI port. Linuxdevices.com. 2007-01-19 [2007-10-11]. (原始内容存档于2012-07-14). 
  7. ^ Andrés Calderón and Nelson Castillo. Why ARM's EABI matters. Linuxdevices.com. 2007-03-14 [2007-10-11]. (原始内容存档于2012-07-14). 

外部链接

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
应用二进制接口
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?