What is Application binary interface (ABI)?
The machine-level agreement that lets compiled programs and libraries work together, covering the calling convention, data type sizes and alignment, how system calls are made and more.
Field: ISA & Assembly
Japanese name: ABI(アプリケーションバイナリインターフェース)
What an ABI pins down
An application binary interface (ABI) fixes everything two pieces of compiled code must agree on to call each other without being rebuilt. That includes the calling convention (which registers carry arguments and return values, which registers a callee must preserve, how the stack is aligned and laid out), the size and alignment of basic types such as int, long and pointers, the layout and padding of structs, how C++ names are mangled, how exceptions unwind, the object-file format and the instruction sequence used to make a system call into the operating system.
API versus ABI
An application programming interface (API) is a source-level contract: function names, parameter types and behaviour as a programmer sees them. An ABI is the same contract after compilation. A library can keep its API unchanged yet break its ABI, for instance by adding a field to a public struct, which changes the struct's size and the offsets of later fields. Programs then compile fine against the new header, but binaries built against the old version misread memory unless they are recompiled. Shared-library version numbers exist largely to signal such ABI breaks.
One ISA, several ABIs
The instruction set architecture (ISA) defines what the processor executes; the ABI is a software convention layered on top, so one ISA can have several. On x86-64, the System V ABI used by Linux passes the first six integer arguments in RDI, RSI, RDX, RCX, R8 and R9 and makes long 64 bits, while the Windows x64 ABI uses RCX, RDX, R8 and R9 and keeps long at 32 bits. RISC-V defines ABIs such as ilp32, lp64 and lp64d, the last passing floating-point arguments in floating-point registers.
Keeping a library's ABI small
Every symbol a shared library exports becomes part of its ABI and must stay compatible. In ELF shared libraries, used on Linux and elsewhere, exported functions can also be overridden by a same-named symbol in another module, so even calls inside the library by default go through the procedure linkage table (PLT) or global offset table (GOT). Marking internal functions with hidden visibility removes them from the public interface: the dynamic linker has fewer symbols to resolve, internal calls become direct PC-relative calls, name collisions with other libraries are avoided, and the library is free to change those functions later.
Try it: questions about Application binary interface (ABI)
- AAn agreement at the source-code level defining function names and argument types
- BAn agreement defining only the kinds of CPU instructions and their bit layouts
- CA set of machine-level agreements, such as calling conventions and data type sizes and alignment, that let programs interoperate
Show answer and explanation
Answer: C. A set of machine-level agreements, such as calling conventions and data type sizes and alignment, that let programs interoperate
An ABI is the machine-level agreement that lets compiled programs and libraries work together. It covers the calling convention, the sizes of int, long and pointers, struct alignment, how system calls are made and so on. An API defines how functions are used at the source level; even with the same API, a different ABI means a library cannot be used without rebuilding. The same RISC-V ISA can have different ABIs depending on the OS or application.
FAQ
What is the difference between an API and an ABI?
An API is the source-code interface a programmer writes against, while an ABI is the binary-level agreement on registers, data layout and calling sequence that compiled code relies on. Keeping the API but changing the ABI forces dependent programs to be recompiled.
Why can a library update break programs that were not changed?
If the update changes the ABI, for example a struct's size or a function's argument types, existing binaries still use the old layout and pass data in the wrong form. The source may compile unchanged, but already-built programs fail until they are rebuilt.
Is a calling convention part of the ABI?
Yes. The calling convention, which specifies where arguments and return values go and which registers each side must preserve, is one of the central parts of an ABI.
Books on ISA & Assembly Ad
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.
Back to the glossary