Application binary interface

Incomputer software,anapplication binary interface(ABI) is aninterfacebetween two binary program modules. Often, one of these modules is alibraryoroperating systemfacility, and the other is a program that is being run by a user.

A high-level comparison of in-kernel and kernel-to-userspace APIs and ABIs
TheLinux kernelandGNU C Librarydefine theLinux API.After compilation, the binaries offer an ABI. Keeping this ABI stable over a long time is important forISVs.

An ABI defines how data structures or computational routines are accessed inmachine code,which is a low-level, hardware-dependent format. In contrast, anapplication programming interface(API) defines this access insource code,which is a relatively high-level, hardware-independent, oftenhuman-readableformat. A common aspect of an ABI is thecalling convention,which determines how data is provided as input to, or read as output from, computational routines. Examples of this are thex86 calling conventions.

Adhering to an ABI (which may or may not be officially standardized) is usually the job of acompiler,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, andalignmentsof basicdata typesthat the processor can directly access
  • Calling convention,which controls how the arguments offunctionsare 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 makesystem callsto the operating system, and if the ABI specifies direct system calls rather than procedure calls to system callstubs,the system call numbers
  • In the case of a complete operating system ABI, the binary format ofobject files,program libraries, etc.

Complete ABIs

edit

A complete ABI, such as theIntel 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 theC++ name mangling,[2]exceptionpropagation,[3]and calling convention between compilers on the same platform, but do not require cross-platform compatibility.

Embedded ABIs

edit

Anembedded-application binary interface(EABI) specifies standard conventions forfile formats,data types, register usage,stack frameorganization, and function parameter passing of anembeddedsoftware program, for use with anembedded operating system.

Compilersthat support the EABI createobject codethat 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 ownassembly languagecode 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 linkingmay 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 includePowerPC,[4]ArmEABI[7]andMIPSEABI.[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. ^ab"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 fromthe originalon 21 January 2007.Retrieved11 October2007.
  6. ^Andrés Calderón and Nelson Castillo (14 March 2007)."Why ARM's EABI matters".Linuxdevices.com. Archived fromthe originalon 31 March 2007.Retrieved11 October2007.
  7. ^"ABI for the Arm Architecture".Developer.arm.com.Retrieved4 February2020.
  8. ^Eric Christopher (11 June 2003)."mips eabi documentation".[email protected](Mailing list).Retrieved19 June2020.
  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