ABI
An application binary interface (abi) is primarily the interface between:
- Program and Operating System - How your compiled program interacts with the OS kernel
- Program and Libraries - How your compiled program uses shared libraries
- Different parts of compiled code - How compiled modules/objects link together
More Precisely:
ABI defines how compiled binary code interacts with:
- The operating system kernel (system calls)
- Shared libraries (
.so,.dllfiles) - Other compiled object files during linking
- Hardware/CPU architecture
💡 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 languages or when using multiple compilers for the same language.
Interface aspects covered by an ABI include:
-
Processor instruction set, with details like register file structure, memory access types, etc.
-
Size, layout, and alignment 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:
- How the call stack is organized
- Whether all parameters are passed on the call stack, or some are passed in registers
- Which registers are used for which function parameters
- Whether the first function parameter passed on the call stack is pushed first or last
- Whether the caller or callee is responsible for cleaning up the call stack after the function call
-
Exception propagation
-
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.
