Application binary interface: Difference between revisions

Content deleted Content added
KolbertBot (talk | contribs)
m Bot: HTTP→HTTPS (v456)
Qtf0x (talk | contribs)
m Fixed grammar
Tags: canned edit summary Mobile edit Mobile app edit iOS app edit App section source
 
(95 intermediate revisions by 49 users not shown)
Line 1:
{{short description|Interface to software defined in terms of in-process, machine code access}}
{{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 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;. keepingKeeping this ABI stable over a long time is important for [[Independent software vendor|ISVs]].]]
 
An '''application binary interface''' ('''ABI''') is an [[interface (computing)|interface]] exposed by [[software]] that is defined for in-[[Process (computing)|process]] [[machine code]] access. Often, the exposing software is a [[Library (computing)|library]], and the consumer is a [[computer program|program]].
In [[computer software]], an '''application binary interface''' ('''ABI''') is the [[interface (computing)|interface]] between two program modules, one of which is often a [[Library (computing)|library]] and/or [[operating system]] and the other one is usually an application created by a regular programmer. In contrast to an [[Application programming interface|''API'']], which defines structures and methods one can use at software level, an ''ABI'' defines the structures and methods used to access external, ''already compiled'' libraries/code at the level of [[machine code]]. It does this by determining in which binary format information should be passed from one program component to the next, or to the operating system in the case of a [[system call]]. Thus it sets details such as the [[calling convention]].
 
An ABI is at a relatively low level of [[abstraction (computer science)|abstraction]]. Interface compatibility depends on the target [[computer hardware|hardware]] and the [[software build]] [[toolchain]]. In contrast, an [[application programming interface]] (API) defines access in [[source code]], which is a relatively high-level, hardware-independent, and [[human-readable]] format. An API defines an interface at the source code level, before compilation, whereas an ABI defines an interface to compiled code.
Adhering to ABIs (which may or may not be officially standardized) is usually the job of the [[compiler]], OS or library writer, but application programmers may have to deal with ABIs directly when writing programs in a mix of programming languages, using [[foreign function call]] interfaces between them.
 
API compatibility is generally the concern for [[system design]] and of the toolchain. However, a [[programmer]] may have to deal with an ABI directly when writing a program in multiple [[programming language|languages]] or when using multiple [[compiler]]s for the same language.
ABIs differ from [[application programming interface]]s (APIs), which similarly define interfaces between program components, but at the [[source code]] level.
 
A complete ABI enables a program that supports an ABI to run without modification on multiple operating systems that provide the ABI. The target system must provide any required libraries (that implement the ABI), and there may be other prerequisites.
 
== Description ==
Interface aspects covered by an ABI include:
ABIs cover details such as:
* a[[Processor processor(computing)|Processor]] [[instruction set]], (with details like register file structure, stack organization,[[Computer memory|memory]] access types, etc...)
* the sizesSize, layout, and [[Data structure alignment|alignment]] of basic [[data type]]s that the processor can directly access
* the [[callingCalling convention]], which controls how the arguments of [[function (programming)|function]]s' arguments are passed, and return values retrieved; for example, whetherit controls the following:
** How the [[call stack]] is organized
** Whether all parameters are passed on the call stack, or some are passed in registers,
** whichWhich registers are used for which function parameters,
** and whetherWhether the first function parameter passed on the call stack is pushed first or last onto the stack
** Whether the caller or callee is responsible for cleaning up the call 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 stubs, the system call numbers
* [[Name mangling]]<ref>{{cite web|url=https://itanium-cxx-abi.github.io/cxx-abi/|title=Itanium C++ ABI}} (compatible with multiple architectures)</ref>
* and in the case of a complete operating system ABI, the binary format of [[object file]]s, program libraries and so on.
* [[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>
 
* howHow 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
== Complete ABIs ==
* and inIn the case of a complete operating system ABI, the binary format of [[object file]]s, program libraries, and so onetc.
 
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.
 
ABIs include the [[Intel Binary Compatibility Standard]] (iBCS)<ref>{{cite web |url=http://www.everything2.com/index.pl?node=iBCS |title=Intel Binary Compatibility Standard (iBCS)}}</ref> and the [[System V Release 4]] ABIs for various instruction sets.
Other{{which|date=November 2016}} ABIs standardize details such as the [[name mangling#Name mangling in C++|C++ name mangling]],<ref>[https://mentorembedded.github.com/cxx-abi/ Itanium C++ ABI] (compatible with multiple architectures)</ref> [[exception handling|exception]] propagation,<ref>[https://mentorembedded.github.com/cxx-abi/abi-eh.html 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 ABIsABI ==
An '''embedded-application binary interfaceABI''' ('''EABI'''), used on an [[embedded operating system]], specifies standardaspects conventionssuch foras [[file format]]s, data types, register usage, [[stack frame]] organization, and function parameter passing of an [[Embedded system|embedded]] software program, for use with an [[embedded operating system]].
 
Each compiler and [[Compilerassembly language|assembler]]s that supportsupports thean EABI createcreates [[object code]] that is compatible with code generated by other such compilers, allowingand assemblers. This allows developers to link libraries generated withby one compiler with object code generated withby another compiler. Developers writing their own [[assembly language]] code may also interface with assembly generated by a compliant compiler.
 
EABIsTypically, arean designedEABI tois optimizeoptimized for performance withinfor the limited resources of anthe target embedded system. Therefore, EABIsan omitEABI mostmay omit abstractions thatbetween are[[User madespace betweenand kernel space|kernel and user codespace]] typically found in complex[[desktop computer|desktop]] operating systems. For example, [[dynamic linking]] ismay 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
| date = 1 October 1995-10-01
| edition = Version 1.0
| chapter = EABI Summary
| pages = 28&ndash;30
| publisher = Freescale Semiconductor, Inc
| url = http://www.nxp.com/filesdocs/32biten/doc/app_noteapplication-note/PPCEABI.pdf
}}</ref> The choice of EABI can affect performance.<ref>{{cite web
|title=Debian ARM accelerates via EABI port
|date=2016-10-16 October 2016
|publisher=Linuxdevices.com
|url=http://linuxdevices.com/news/NS9048137234.html
|access-date=11 October 2007
|accessdate=2007-10-11
|archiveurlarchive-url=https://web.archive.org/web/20070121183413/http://www.linuxdevices.com/news/NS9048137234.html
|archivedatearchive-date=21 January 2007
|url-status=dead
|deadurl=yes
}}</ref><ref>{{cite web
|author=Andrés Calderón and Nelson Castillo
|title=Why ARM's EABI matters
|date=2007-03-14 March 2007
|publisher=Linuxdevices.com
|url=http://linuxdevices.com/articles/AT5920399313.html
|access-date=11 October 2007
|accessdate=2007-10-11
|archiveurlarchive-url=https://web.archive.org/web/20070331193917/http://www.linuxdevices.com/articles/AT5920399313.html
|archivedatearchive-date=31 March 2007
|url-status=dead
|deadurl=yes
}}</ref>
 
Widely used EABIs include the [[PowerPC]],<ref name="ppc-eabi"/> [[ARMArm architecture|ARMArm]] EABI2,<ref>{{cite web|url=httphttps://infocenterdeveloper.arm.com/helparchitectures/index.jsp?topic=system-architectures/com.arm.doc.ihi0036bsoftware-standards/index.htmlabi |title=ARMABI Informationfor Centerthe Arm Architecture |publisher=InfocenterDeveloper.arm.com |access-date=4 |accessdate=2014-02-27February 2020}}</ref> and [[MIPS architecture|MIPS]] EABIEABIs.<ref>{{cite webmailing list |url=httphttps://wwwsourceware.cygwin.comorg/legacy-ml/binutils/2003-06/msg00436.html |titleauthor=Eric Christopher - |title=mips eabi documentation |publishermailing-list=Cygwinbinutils@sources.redhat.com |date=11 June 2003 |access-06-11date=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 |accessdatetitle=2014ArmEabiPort |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-02-27ABI" to mean the old one.}}</ref>
 
== See also ==
{{Portal|Computing|Computer programming}}
 
* [[Binary{{Annotated link|Binary-code compatibility]]}}
{{Div col||25em}}
* {{Annotated link|Bytecode}}
* [[Binary code compatibility]]
* [[{{Annotated link|Comparison of application virtualvirtualization machines]]software}}
* [[Bytecode]]
* {{Annotated link|Debug symbol}}
* [[Comparison of application virtual machines]]
* [[{{Annotated link|Foreign function interface]]}}
* [[Debugging symbol]]
* [[{{Annotated link|Language binding]]}}
* [[Foreign function interface]]
* {{Annotated link|Native (computing)}}
* [[Language binding]]
* [[{{Annotated link|Opaque pointer]]}}
* [[{{Annotated link|PowerOpen Environment]]}}
* [[{{Annotated link|Symbol table]]}}
* [[{{Annotated link|SWIG]]}}
* [[Visual C++#Compatibility|Visual C++ ABI instability detailsCompatibility]]
{{Div col end}}
 
==References==
Line 83 ⟶ 88:
* [https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/LowLevelABI/000-Introduction/introduction.html OS X ABI Function Call Guide]
* [http://wiki.debian.org/ArmEabiPort Debian ARM EABI port]
* [http://www.uclibc.org/ µClibμClib: Motorola 8/16-bit embedded ABI]
* [{{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/index.jsp?topic=/com.arm.doc.ihi0036aihi0036b/index.html Application Binary Interface (ABI) for the ARM Architecture]
* [httphttps://wwwsourceware.cygwin.comorg/legacy-ml/binutils/2003-06/msg00436.html MIPS EABI documentation]
* [{{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
* [httphttps://www.freescalenxp.com/filesdocs/32biten/doc/ref_manualreference-manual/MCOREABISM.pdf M•CORE Applications Binary Interface Standards Manual] for the Freescale [[M·CORE]] processors
 
{{Application binary interface}}