Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Application Binary Interface important for programming

I don't understand why the ABI is important context of developing user-space applications. Is the set of system calls for an operating system considered an ABI? But if so then aren't all the complexities regarding system calls encapsulated within standard libraries?

So then is ABI compatibility only relevant for running statically linked applications on different platforms, since the system calls would be embedded into the binary?

like image 235
theactiveactor Avatar asked Jan 09 '10 05:01

theactiveactor


3 Answers

An ABI defines a set of alignment, calling convention, and data types that are common to a system. This makes an ABI awfully important if you're doing any sort of dynamic linking; as without it code from one application has no way of calling code provided by another.

So, no. ABI compatibility is relevant for all dynamic linking (less so for static).

Its worth emphasizing again that a system's ABI affects inter-application work as well as application-to-operating-system work.

like image 71
Kevin Montrose Avatar answered Nov 15 '22 21:11

Kevin Montrose


The ABI is more than what system calls are available. It also usually describes the actual way arguments are passed to functions and how structures and objects are laid-out in memory. Without a consistent ABI, code built by different compilers might not be able to call each other -- if you call foo(a,b) and one compiler pushes a and b on the stack while another passes those in registers, you've got an ABI clash.

like image 36
Ben Combee Avatar answered Nov 15 '22 21:11

Ben Combee


"ABI" (see Wikipedia) is an umbrella term for all the assumptions an operating system makes about data formats. This includes the layout of executable files and that of any data structure in memory given its C definition.

The term also generally covers formatting requirements between programs written in the same language. Each language has particular features that might result in different conventions within executable formats and memory structures, but all must ultimately generate executables compatible with the OS and data structures compatible with the processor's instruction set.

ABI doesn't matter much if you only care about compiling standard-conformant code. It matters a little when you violate the standard and do unportable things like casting a char * to a long *. It's yet more important when writing a large body of assembly code. Writing something like a linker or a debugger, it can come to embody the bulk of work to be done.

like image 32
Potatoswatter Avatar answered Nov 15 '22 23:11

Potatoswatter