Jump to content

Application binary interface: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Perkeo (talk | contribs)
mNo edit summary
m v2.05b - Bot T5 CW#16 - Fix errors for CW project (Unicode control characters)
 
(48 intermediate revisions by 28 users not shown)
Line 1: Line 1:
{{short description|Binary interface between two program units}}
{{Use dmy dates|date=June 2020}}
[[File:Linux kernel interfaces.svg|thumb|300px|A high-level comparison of in-kernel and kernel-to-userspace APIs and ABIs]]
[[File:Linux kernel interfaces.svg|thumb|300px|A high-level comparison of in-kernel and kernel-to-userspace APIs and ABIs]]
[[File:Linux API and Linux ABI.svg|thumb|300px|[[Linux kernel]] and [[GNU C Library]] define the [[Linux kernel interfaces#Kernel–user space API|Linux API]]. After compilation, the binaries offer an ABI; keeping this ABI stable over a long time is important for [[Independent software vendor|ISVs]].]]
[[File:Linux API and Linux ABI.svg|thumb|300px|The [[Linux kernel]] and [[GNU C Library]] define the [[Linux kernel interfaces#Kernel–user space API|Linux API]]. After compilation, the binaries offer an ABI. Keeping this ABI stable over a long time is important for [[Independent software vendor|ISVs]].]]


In [[computer software]], an '''application binary interface''' ('''ABI''') is an [[interface (computing)|interface]] between two binary program modules; often, one of these modules is a [[Library (computing)|library]] or [[operating system]] facility, and the other is a program that is being run by a user.
In [[computer software]], an '''application binary interface''' ('''ABI''') is an [[interface (computing)|interface]] between two binary program modules. Often, one of these modules is a [[Library (computing)|library]] or [[operating system]] facility, and the other is a program that is being run by a user.


An ''ABI'' defines how data structures or computational routines are accessed in [[machine code]], which is a low-level, hardware-dependent format; in contrast, an [[Application programming interface|''API'']] defines this access in [[source code]], which is a relatively high-level, hardware-independent, often [[human-readable]] format. A common aspect of an ABI is the [[calling convention]], which determines how data is provided as input to or read as output from computational routines; examples are the [[x86 calling conventions]].
An ABI defines how data structures or computational routines are accessed in [[machine code]], which is a low-level, hardware-dependent format. In contrast, an [[application programming interface]] (API) defines this access in [[source code]], which is a relatively high-level, hardware-independent, often [[human-readable]] format. A common aspect of an ABI is the [[calling convention]], which determines how data is provided as input to, or read as output from, computational routines. Examples of this are the [[x86 calling conventions]].


Adhering to an ABI (which may or may not be officially standardized) is usually the job of a [[compiler]], operating system, or library author; however, an application programmer may have to deal with an ABI directly when writing a program in a mix of programming languages, which can be achieved by using [[foreign function call]]s.
Adhering to an ABI (which may or may not be officially standardized) is usually the job of a [[compiler]], operating system, or library author. However, an application programmer may have to deal with an ABI directly when writing a program in a mix of programming languages, or even compiling a program written in the same language with different compilers.


== Description ==
== Description ==
Details covered by an ABI include the following:
ABIs cover details such as:
* a processor instruction set (with details like register file structure, stack organization, memory access types, ...)
* Processor instruction set, with details like register file structure, stack organization, memory access types, etc.
* the sizes, layouts, and [[Data structure alignment|alignments]] of basic [[data type]]s that the processor can directly access
* Sizes, layouts, and [[Data structure alignment|alignments]] of basic [[data type]]s that the processor can directly access
* the [[calling convention]], which controls how [[function (programming)|function]]s' arguments are passed and return values are retrieved; for example, whether all parameters are passed on the stack or some are passed in registers, which registers are used for which function parameters, and whether the first function parameter passed on the stack is pushed first or last onto the stack
* [[Calling convention]], which controls how the arguments of [[function (programming)|function]]s are passed, and return values retrieved; for example, it controls the following:
** Whether all parameters are passed on the stack, or some are passed in registers
** Which registers are used for which function parameters
** Whether the first function parameter passed on the stack is pushed first or last
* how an application should make [[system call]]s to the operating system and, if the ABI specifies direct system calls rather than procedure calls to system call stubs, the system call numbers
** Whether the caller or callee is responsible for cleaning up the stack after the function call
* How an application should make [[system call]]s to the operating system, and if the ABI specifies direct system calls rather than procedure calls to system call [[Method stub|stubs]], the system call numbers
* and in the case of a complete operating system ABI, the binary format of [[object file]]s, program libraries and so on.
* In the case of a complete operating system ABI, the binary format of [[object file]]s, program libraries, etc.


== Complete ABIs ==
== Complete ABIs ==
A complete ABI, such as the [[Intel Binary Compatibility Standard]] (iBCS),<ref>[http://www.everything2.com/index.pl?node=iBCS Intel Binary Compatibility Standard (iBCS)]</ref> allows a program from one operating system supporting that ABI to run without modifications on any other such system, provided that necessary shared libraries are present, and similar prerequisites are fulfilled.
A complete ABI, such as the [[Intel Binary Compatibility Standard]] (iBCS),<ref>[http://www.everything2.com/index.pl?node=iBCS Intel Binary Compatibility Standard (iBCS)]</ref> allows a program from one operating system supporting that ABI to run without modifications on any other such system, provided that necessary shared libraries are present, and similar prerequisites are fulfilled.


Other{{which|date=November 2016}} ABIs standardize details such as the [[name mangling#Name mangling in C++|C++ name mangling]],<ref>{{cite web|url=https://itanium-cxx-abi.github.io/cxx-abi/|title=Itanium C++ ABI}} (compatible with multiple architectures)</ref> [[exception handling|exception]] propagation,<ref>{{cite web|url=http://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html|title=Itanium C++ ABI: Exception Handling}} (compatible with multiple architectures)</ref> and calling convention between compilers on the same platform, but do not require cross-platform compatibility.
ABIs can also standardize details such as the [[name mangling#Name mangling in C++|C++ name mangling]],<ref>{{cite web|url=https://itanium-cxx-abi.github.io/cxx-abi/|title=Itanium C++ ABI}} (compatible with multiple architectures)</ref> [[exception handling|exception]] propagation,<ref>{{cite web|url=http://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html|title=Itanium C++ ABI: Exception Handling}} (compatible with multiple architectures)</ref> and calling convention between compilers on the same platform, but do not require cross-platform compatibility.


== {{Anchor|EABI}}Embedded ABIs ==
== {{Anchor|EABI}}Embedded ABIs ==
Line 26: Line 32:
[[Compiler]]s that support the EABI create [[object code]] that is compatible with code generated by other such compilers, allowing developers to link libraries generated with one compiler with object code generated with another compiler. Developers writing their own [[assembly language]] code may also interface with assembly generated by a compliant compiler.
[[Compiler]]s that support the EABI create [[object code]] that is compatible with code generated by other such compilers, allowing developers to link libraries generated with one compiler with object code generated with another compiler. Developers writing their own [[assembly language]] code may also interface with assembly generated by a compliant compiler.


EABIs are designed to optimize for performance within the limited resources of an embedded system. Therefore, EABIs omit most abstractions that are made between kernel and user code in complex operating systems. For example, dynamic linking is avoided to allow smaller executables and faster loading, fixed register usage allows more compact stacks and kernel calls, and running the application in privileged mode allows direct access to custom hardware operation without the indirection of calling a device driver.
EABIs are designed to optimize for performance within the limited resources of an embedded system. Therefore, EABIs omit most abstractions that are made between kernel and user code in complex operating systems. For example, [[dynamic linking]] may be avoided to allow smaller executables and faster loading, fixed register usage allows more compact stacks and kernel calls, and running the application in privileged mode allows direct access to custom hardware operation without the indirection of calling a device driver.<ref name="ppc-eabi">{{cite book
<ref name="ppc-eabi">{{cite book
| title = PowerPC Embedded Application Binary Interface: 32-Bit Implementation
| title = PowerPC Embedded Application Binary Interface: 32-Bit Implementation
| date = 1995-10-01
| date = 1 October 1995
| edition = Version 1.0
| edition = Version 1.0
| chapter = EABI Summary
| chapter = EABI Summary
| pages = 28&ndash;30
| pages = 28&ndash;30
| publisher = Freescale Semiconductor, Inc
| publisher = Freescale Semiconductor, Inc
| url = http://www.nxp.com/files/32bit/doc/app_note/PPCEABI.pdf
| url = http://www.nxp.com/docs/en/application-note/PPCEABI.pdf
}}</ref> The choice of EABI can affect performance.<ref>{{cite web
}}</ref> The choice of EABI can affect performance.<ref>{{cite web
|title=Debian ARM accelerates via EABI port
|title=Debian ARM accelerates via EABI port
|date=2016-10-16
|date=16 October 2016
|publisher=Linuxdevices.com
|publisher=Linuxdevices.com
|url=http://linuxdevices.com/news/NS9048137234.html
|url=http://linuxdevices.com/news/NS9048137234.html
|access-date=11 October 2007
|accessdate=2007-10-11
|archiveurl=https://web.archive.org/web/20070121183413/http://www.linuxdevices.com/news/NS9048137234.html
|archive-url=https://web.archive.org/web/20070121183413/http://www.linuxdevices.com/news/NS9048137234.html
|archivedate=21 January 2007
|archive-date=21 January 2007
|url-status=dead
|url-status=dead
}}</ref><ref>{{cite web
}}</ref><ref>{{cite web
|author=Andrés Calderón and Nelson Castillo
|author=Andrés Calderón and Nelson Castillo
|title=Why ARM's EABI matters
|title=Why ARM's EABI matters
|date=2007-03-14
|date=14 March 2007
|publisher=Linuxdevices.com
|publisher=Linuxdevices.com
|url=http://linuxdevices.com/articles/AT5920399313.html
|url=http://linuxdevices.com/articles/AT5920399313.html
|access-date=11 October 2007
|accessdate=2007-10-11
|archiveurl=https://web.archive.org/web/20070331193917/http://www.linuxdevices.com/articles/AT5920399313.html
|archive-url=https://web.archive.org/web/20070331193917/http://www.linuxdevices.com/articles/AT5920399313.html
|archivedate=31 March 2007
|archive-date=31 March 2007
|url-status=dead
|url-status=dead
}}</ref>
}}</ref>


Widely used EABIs include [[PowerPC]],<ref name="ppc-eabi"/> [[Arm architecture|Arm]] EABI<ref>{{cite web|url=https://developer.arm.com/architectures/system-architectures/software-standards/abi |title=ABI for the Arm Architecture |publisher=Developer.arm.com |date= |accessdate=2020-02-04}}</ref> and [[MIPS architecture|MIPS]] EABI.<ref>{{cite web|url=http://www.cygwin.com/ml/binutils/2003-06/msg00436.html |title=Eric Christopher - mips eabi documentation |publisher=Cygwin.com |date=2003-06-11 |accessdate=2014-02-27}}</ref>
Widely used EABIs include [[PowerPC]],<ref name="ppc-eabi"/> [[Arm architecture|Arm]] EABI<ref>{{cite web|url=https://developer.arm.com/architectures/system-architectures/software-standards/abi |title=ABI for the Arm Architecture |publisher=Developer.arm.com |access-date=4 February 2020}}</ref> and [[MIPS architecture|MIPS]] EABI.<ref>{{cite mailing list |url=https://sourceware.org/legacy-ml/binutils/2003-06/msg00436.html |author=Eric Christopher |title=mips eabi documentation |mailing-list=binutils@sources.redhat.com |date=11 June 2003 |access-date=19 June 2020}}</ref> Specific software implementations like the C library may impose additional limitations to form more concrete ABIs; one example is the GNU OABI and EABI for ARM, both of which are subsets of the ARM EABI .<ref>{{cite web |title=ArmEabiPort |url=https://wiki.debian.org/ArmEabiPort |website=Debian Wiki |quote=Strictly speaking, both the old and new ARM ABIs are subsets of the ARM EABI specification, but in everyday usage the term "EABI" is used to mean the new one described here and "OABI" or "old-ABI" to mean the old one.}}</ref>


== See also ==
== See also ==
Line 62: Line 67:


{{Div col|colwidth=25em}}
{{Div col|colwidth=25em}}
* [[Binary code compatibility]]
* [[Binary-code compatibility]]
* [[Bytecode]]
* [[Bytecode]]
* [[Comparison of application virtual machines]]
* [[Comparison of application virtualization software]]
* [[Debugging symbol]]
* [[Debug symbol]]
* [[Foreign function interface]]
* [[Foreign function interface]]
* [[Language binding]]
* [[Language binding]]
* [[Native (computing)]]
* [[Opaque pointer]]
* [[Opaque pointer]]
* [[PowerOpen Environment]]
* [[PowerOpen Environment]]
Line 83: Line 89:
* [http://wiki.debian.org/ArmEabiPort Debian ARM EABI port]
* [http://wiki.debian.org/ArmEabiPort Debian ARM EABI port]
* [http://www.uclibc.org/ μClib: Motorola 8/16-bit embedded ABI]
* [http://www.uclibc.org/ μClib: Motorola 8/16-bit embedded ABI]
* [https://web.archive.org/web/20080528070803/http://www.x86-64.org/documentation.html AMD64 (x86-64) Application Binary Interface]
* {{webarchive|url=https://web.archive.org/web/20080528070803/http://www.x86-64.org/documentation.html|title=AMD64 (x86-64) Application Binary Interface}}
* [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0036a/index.html Application Binary Interface (ABI) for the ARM Architecture]
* [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ihi0036b/index.html Application Binary Interface (ABI) for the ARM Architecture]
* [http://www.cygwin.com/ml/binutils/2003-06/msg00436.html MIPS EABI documentation]
* [https://sourceware.org/legacy-ml/binutils/2003-06/msg00436.html MIPS EABI documentation]
* [http://www.oracle.com/technetwork/server-storage/solaris10/about-amd64-abi-141142.html Sun Studio 10 Compilers and the AMD64 ABI]{{snd}} a summary and comparison of some popular ABIs
* {{webarchive|url=https://web.archive.org/web/20150114065444/http://www.oracle.com/technetwork/server-storage/solaris10/about-amd64-abi-141142.html|title=Sun Studio 10 Compilers and the AMD64 ABI}}{{snd}} a summary and comparison of some popular ABIs
* [http://www.freescale.com/files/32bit/doc/ref_manual/MCOREABISM.pdf M•CORE Applications Binary Interface Standards Manual] for the Freescale [[M·CORE]] processors
* [http://www.freescale.com/files/32bit/doc/ref_manual/MCOREABISM.pdf M•CORE Applications Binary Interface Standards Manual] for the Freescale [[M·CORE]] processors


{{Application binary interface}}
{{Application binary interface}}
{{Use dmy dates|date=February 2019}}



[[Category:Application programming interfaces]]
[[Category:Application programming interfaces]]

Latest revision as of 01:22, 19 February 2024

A high-level comparison of in-kernel and kernel-to-userspace APIs and ABIs
The Linux kernel and GNU C Library define the Linux API. After compilation, the binaries offer an ABI. Keeping this ABI stable over a long time is important for ISVs.

In computer software, an application binary interface (ABI) is an interface between two binary program modules. Often, one of these modules is a library or operating system facility, and the other is a program that is being run by a user.

An ABI defines how data structures or computational routines are accessed in machine code, which is a low-level, hardware-dependent format. In contrast, an application programming interface (API) defines this access in source code, which is a relatively high-level, hardware-independent, often human-readable format. A common aspect of an ABI is the calling convention, which determines how data is provided as input to, or read as output from, computational routines. Examples of this are the x86 calling conventions.

Adhering to an ABI (which may or may not be officially standardized) is usually the job of a compiler, operating system, or library author. However, an application programmer may have to deal with an ABI directly when writing a program in a mix of programming languages, or even compiling a program written in the same language with different compilers.

Description

[edit]

Details covered by an ABI include the following:

  • Processor instruction set, with details like register file structure, stack organization, memory access types, etc.
  • Sizes, layouts, and alignments of basic data types that the processor can directly access
  • Calling convention, which controls how the arguments of functions are passed, and return values retrieved; for example, it controls the following:
    • Whether all parameters are passed on the stack, or some are passed in registers
    • Which registers are used for which function parameters
    • Whether the first function parameter passed on the stack is pushed first or last
    • Whether the caller or callee is responsible for cleaning up the stack after the function call
  • How an application should make system calls to the operating system, and if the ABI specifies direct system calls rather than procedure calls to system call stubs, the system call numbers
  • In the case of a complete operating system ABI, the binary format of object files, program libraries, etc.

Complete ABIs

[edit]

A complete ABI, such as the Intel Binary Compatibility Standard (iBCS),[1] allows a program from one operating system supporting that ABI to run without modifications on any other such system, provided that necessary shared libraries are present, and similar prerequisites are fulfilled.

ABIs can also standardize details such as the C++ name mangling,[2] exception propagation,[3] and calling convention between compilers on the same platform, but do not require cross-platform compatibility.

Embedded ABIs

[edit]

An embedded-application binary interface (EABI) specifies standard conventions for file formats, data types, register usage, stack frame organization, and function parameter passing of an embedded software program, for use with an embedded operating system.

Compilers that support the EABI create object code that is compatible with code generated by other such compilers, allowing developers to link libraries generated with one compiler with object code generated with another compiler. Developers writing their own assembly language code may also interface with assembly generated by a compliant compiler.

EABIs are designed to optimize for performance within the limited resources of an embedded system. Therefore, EABIs omit most abstractions that are made between kernel and user code in complex operating systems. For example, dynamic linking may be avoided to allow smaller executables and faster loading, fixed register usage allows more compact stacks and kernel calls, and running the application in privileged mode allows direct access to custom hardware operation without the indirection of calling a device driver.[4] The choice of EABI can affect performance.[5][6]

Widely used EABIs include PowerPC,[4] Arm EABI[7] and MIPS EABI.[8] Specific software implementations like the C library may impose additional limitations to form more concrete ABIs; one example is the GNU OABI and EABI for ARM, both of which are subsets of the ARM EABI .[9]

See also

[edit]

References

[edit]
  1. ^ Intel Binary Compatibility Standard (iBCS)
  2. ^ "Itanium C++ ABI". (compatible with multiple architectures)
  3. ^ "Itanium C++ ABI: Exception Handling". (compatible with multiple architectures)
  4. ^ a b "EABI Summary". PowerPC Embedded Application Binary Interface: 32-Bit Implementation (PDF) (Version 1.0 ed.). Freescale Semiconductor, Inc. 1 October 1995. pp. 28–30.
  5. ^ "Debian ARM accelerates via EABI port". Linuxdevices.com. 16 October 2016. Archived from the original on 21 January 2007. Retrieved 11 October 2007.
  6. ^ Andrés Calderón and Nelson Castillo (14 March 2007). "Why ARM's EABI matters". Linuxdevices.com. Archived from the original on 31 March 2007. Retrieved 11 October 2007.
  7. ^ "ABI for the Arm Architecture". Developer.arm.com. Retrieved 4 February 2020.
  8. ^ Eric Christopher (11 June 2003). "mips eabi documentation". binutils@sources.redhat.com (Mailing list). Retrieved 19 June 2020.
  9. ^ "ArmEabiPort". Debian Wiki. Strictly speaking, both the old and new ARM ABIs are subsets of the ARM EABI specification, but in everyday usage the term "EABI" is used to mean the new one described here and "OABI" or "old-ABI" to mean the old one.
[edit]