GCC Target Specificity and Binary Compatibility

Source note. The question mentions AIX because it is the initial context, but the question really refers to gcc itself, most likely, regardless of the platform.

AIX is assumed to be binary compatible: the C program compiled on AIX 5.1 will run as 5.2, 5.3, 6.1, and 7.1.

In my understanding, gcc should be built to target a specific system (whether this or that in the case of cross-compilation). Thus, gcc built on AIX 6.1 targets AIX 6.1 and creates binaries that can be used for both 6.1 and 7.1 due to binary compatibility.

However, gcc itself, built on AIX 6.1, is a 6.1 program, so it should run as 7.1. Of course, if I compile a program with it on 7.1, this program can be linked or use headers specific to 7.1, as a result of which the resulting binary requires 7.1. As far as I understand, I could run gcc, built on AIX 6.1, on the 7.1 machine and create, possibly, non-optimal, but completely correct binaries, although this would require 7.1 as a side effect of linking.

It is too much like a rainbow and unicorns dancing in glittering skies. I smell something fishy, ​​but I lack knowledge of gcc. Please, mighty crowd, enlighten me.

tl; dr . Can gcc embed and target version N of the operating system / platform that will be launched and used on version N + 1, thanks to the binary compatibility of the platform for creating executable files on version N +1? If not, what mechanism will this prevent?

+5
source share
1 answer

Here is enlightenment: your question is too general . To answer it, someone had to know

  • the operating systems you care about
  • OS versions you care about
  • gcc versions you care about

and then explore binary compatibility in this three-dimensional matrix.

, , . - API, , a.out ELF.
+2

All Articles