I just read an example of ABI. Is it correct that

  • an ABI is similar to API, except that ABI is in machine language and API is in a high level programming language

  • an ABI is the interface provided by and belonging to a compiled library in a machine language? (If I am correct, a self-made compiled library provides its ABI (see the above example). An operating system can be viewed as a compiled library, and thus provides its own ABI for applications to access its system call services.)

The above example doesn't mention whether an ABI of a self-made compiled library depends on the operating system.

https://en.wikipedia.org/wiki/Application_binary_interface mentions operating system however:

ABIs cover details such as:

a processor instruction set (with details like register file structure, stack organization, memory access types, ...)

the sizes, layouts, and alignments of basic data types that the processor can directly access

the calling convention, which controls how functions' 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

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

and in the case of a complete operating system ABI, the binary format of object files, program libraries and so on.

Does the ABI of a compiled library depend on the operating system? (I guess no. Even if a compiled library uses system call services via the ABI of the operating system, it is the compiled library not its ABI which depends on (the ABI of) the OS.)

Can the ABI of a compiled library be independent of (the ABI of) the operating system?


1 Answer 1


The ABI of a compiled library depends on its target, and that doesn’t have to include an operating system. There are libraries for embedded systems with no operating system, and there are libraries for platforms such as Java which abstract away the operating system’s ABI.

As you say, the operating system’s ABI determines how a library (or program) calls into it; it doesn’t necessarily determine how the library is called. What determines a library’s ABI is really its API along with the specifics of the compiler it uses. The compiler will typically follow the target platform’s ABI, but that’s not OS-specific; for example on Linux, the platform ABI is the System V ELF ABI, with architecture-specific processor supplements.

It is however possible for an operating system’s ABI to leak into a library’s ABI, for example if the library directly exposes system-specific structures in its ABI.

  • Thanks. Is it correct that self-made compiled libraries almost always depend on some OS's binary libraries, and thus require themselves to be linked to the OS's binary libraries? So a linker must be OS-specific in terms of the files being linked (not in terms of which OS the linker runs in)?
    – Tim
    Sep 26, 2020 at 19:01
  • Linkers are told what files to link, they typically don’t know about OS-specific files if they’re not told about them. Sep 26, 2020 at 19:24
  • What do "target" and "the target platform" mean in "The ABI of a compiled library depends on its target" and "What determines a library’s ABI is really its API along with the specifics of the compiler it uses. The compiler will typically follow the target platform’s ABI, but that’s not OS-specific"? Are they something between operating systems and instruction set architecture (ISA)?
    – Tim
    Sep 27, 2020 at 0:31
  • I guess ABI is the interface of a compiled library in machine language. The only kinds of examples that I know are ABIs of self made compiled application libraries, and ABIs of OSes, Are "ABIs of platforms" a different kind of examples?
    – Tim
    Sep 27, 2020 at 5:38
  • The end of my second paragraph gives an example of a platform ABI, the System V ABI. It’s not specific to an OS or architecture (ISA), but it does have architecture-specific appendices. Sep 27, 2020 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .