-1

As from this Question What is Application binary Interface, 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;
  • Stack frames (activation records) [not in the above question]

My questions are,

  1. If ABIs define these rule then does the compiler that generates binaries for the target architecture depends on Architecture ABIs??? for example the compiler of ARM has to follow ARM eabi???
  2. Who design these ABIs??? the vendor, architecture designer (core), compiler designers???
Aimal
  • 621
  • 1
  • 7
  • 13

1 Answers1

1

A compiler is just a program like an image manipulation program. You have an input and an output, in both cases they have to conform to some standard (language, file format). But how you do it is up to you. For the compiler case you only need to make code that will work on the target platform which is defined by the instruction set, and for a sane compiler you choose or create a calling convention that works for the language, but it is up to you.

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • So it means it is not mandatory for the compiler to follow specific ABI??? wouldn't it be a problem if let say ARM compiler is based on different ABI other than ARM EABI??? how will the generated binaries run on ARM if the used ABIs have quite different registers references...like in which registers the function parameters be passed... – Aimal Jun 10 '17 at 13:22
  • for example the arm abi itself has changed in recent years, and will no doubt continue to evolve. it is incompatible with prior versions of itself if you will, yet we can still write programs that work. – old_timer Jun 10 '17 at 13:35
  • Kindly correct me if i am wrong, So you mean for various object code to be compatible with each other, they must be compiled under same ABI. like for example if one fun1(x) expect arguments to be in reg0-3 (ABI1) and fun2(x) expects arguments in stack (based on ABI2) then they cant be linked in single object code. and you mean if you can compile you whole project under your own ABI (all procedure calls expect arguments in same locations) then this is perfectly fine... – Aimal Jun 10 '17 at 13:50
  • if you were to want to use two different compilers, say llvm/clang and gcc, why would you I dont know but not only do they need to conform to the same abi, they also need to conform to the same either assembly language and/or object file format, depends on at what level you are mixing them. could conform to the same abi and mixing compilers in a project could still fail. But why would you want to mix compilers? stick with one it is made to work with itself otherwise it is a useless compiler. – old_timer Jun 10 '17 at 14:03