10

I compiled a small C program (2 lines of codes) with gcc to try to understand ELF file format. Doing a readelf -h on the object file, I have in the header :

OS/ABI:                            UNIX - System V 

I am using Fedora, so why isn't it Linux instead ?

Edit: I compiled

int main(){
  int x = 0;
  x++;
}

with gcc -o main.o -c main.c. My gcc version is

gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4) 
  • Please show us i) the code you compiled ii) the output of gcc --version and iii) the exact command you used to compile it. – terdon May 26 '14 at 14:01
  • I've edited the question accordingly. – alex_reader May 26 '14 at 14:07
  • I just did readelf -h /bin/ls on debian gnu/linux. It also showed OS/ABI: UNIX - System V. My guess is that the ABI is used on more than one kernel, not just linux. I also know that linux supports more than one ABI. – ctrl-alt-delor May 26 '14 at 14:50
  • 6
    Wikipedia says It [the OSABI field in the ELF header] is often set to 0 [SysV] regardless of the target platform – Stéphane Chazelas May 26 '14 at 15:00
  • 1
    This field tells if the ELF file is using any OS specific extensions, the default is 0. More detailled description here(at EI_OSABI). – Leiaz May 26 '14 at 15:25
8

There are few differences between ELF executables on different platforms. “UNIX - System V” is the common ground; System V is where the ELF format came from. The corresponding numerical value is 0. This value indicates that the executable doesn't use any OS-specific extension. Debian GNU/Linux, at least, configures GCC/binutils to generate executables with this field set to 0 by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.