Skip to content
tezvyn:
Menu

The C Application Binary Interface

Source: Wikipedia: Application binary interfaceMediumHow cards are made

The C Application Binary Interface

An ABI is the contract a library exposes for in-process machine code access. You see this whenever a compiled program calls into a compiled library at the binary level.

Why it exists

Once software is compiled into machine code, the original structural cues disappear. A program that wants to use a compiled library cannot see how that library organized its logic before compilation. There needs to be a fixed set of rules for how the program reaches into the library's machine code to invoke behavior or read results. Without this agreement, the consumer would not know where entry points reside or how to pass information at the binary level.

The mental model

Think of an ABI like the standardized plug and voltage specification between two appliances made by different manufacturers. The library is the power plant producing raw energy in the form of machine instructions. The consumer program is the appliance that wants to tap that energy. The ABI defines the shape of the socket, the voltage, and the sequence for connecting safely. Both sides must conform to the same physical standard or the connection fails, even if both devices are perfectly functional on their own.

How it works

A library exposes an interface that is defined for in-process machine code access. This means the contract operates at the level of raw binary rather than at any higher level of abstraction. The exposing software, typically a library, makes its compiled output available in a predictable arrangement. The consumer, typically a program, uses that arrangement to reach the correct locations and exchange information using the agreed-upon binary format. Everything happens within the same process, so the ABI governs internal access and execution flow rather than external channels.

When to use it

You depend on an ABI whenever you integrate a compiled library into an application and need the two pieces to execute together in a single process. This is the default situation for most compiled software ecosystems where libraries ship as binary artifacts rather than text that gets rebuilt inside the consumer. Any time a program invokes behavior from a separately compiled unit without recompiling that unit from scratch, an ABI is in effect.

When not to use it

An ABI is irrelevant when all code is compiled together as one monolithic unit from a single codebase, because no stable public contract is needed between parts that are built simultaneously. It is also unnecessary when communication happens outside of in-process machine code access, such as through human-readable configuration or external messaging, where the boundary is defined by a protocol rather than a binary interface.

One canonical example

Consider a library compiled into a binary artifact and a program that wants to use a routine from that library. The library exposes the routine through its ABI. The program knows how to reach that routine because both adhere to the same interface definition. The program does not need anything beyond the compiled binary and the rules of the ABI to access the machine code correctly within the same process.

Interview question

Which scenario depends on an ABI for the interaction to work?

  • a.A program parses human-readable configuration files at startup.
  • b.A consumer project rebuilds a library from its source text during compilation.
  • c.A compiled program calls into a separately compiled library within the same process.Correct
  • d.All source code is compiled together into a single monolithic binary.
Why?

An ABI governs how a compiled program reaches into a separately compiled library's machine code within the same process. Option B is tempting because it also involves a library and a consumer, but rebuilding from source text means both units are compiled together, so no binary-level contract is needed.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles