Question

How are compilation and ABI related?

Is a compiler's solely job to build Application Binary Interface (ABI) to OS and/or other applications?

About ABI, quoted from Wikipedia:

ABIs cover details such as data type, size, and alignment; the calling convention, which controls how functions' arguments are passed and return values retrieved; the system call numbers and how an application should make system calls to the operating system; and in the case of a complete operating system ABI, the binary format of object files, program libraries and so on.

Thanks and regards!

Was it helpful?

Solution

An ABI describes the features of the underlying OS, and includes some rules about how a program must be compiled. It's the compiler's job not to "build" the ABI, but to conform to the ABI as it creates executable code.

OTHER TIPS

Well, compiler may not follow the ABI completely. It had to emit valid machine code but for example it may not follow calling conventions for inner function calls. But of course, on the border between compiled code and OS the compiler should follow ABI.

Compiler has to output object file from source. This is dependent on the architecture, such as addressing mode availability, registers available, and such that are clarified within ABI. Also, OS is tightly coupled with architecture for performance reasons, so unless you are writing firmware, OS's calling convention for system calls and any such relevant details are part of ABI parcel.

Compiler replaces high-level source text by machine level opcodes and data. The output is required to comply depending on the tool-chain. For instance, linker targeting Windows will require object file in PE format for supporting Windows libraries, and additional formats if the compiler in the tool-chain output to one of these other formats like ELF.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top