Why does readelf show "System V" as my OS instead of Linux?

5,610

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.

Share:
5,610

Related videos on Youtube

alex_reader
Author by

alex_reader

Updated on September 18, 2022

Comments

  • alex_reader
    alex_reader almost 2 years

    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) 
    
    • terdon
      terdon about 10 years
      Please show us i) the code you compiled ii) the output of gcc --version and iii) the exact command you used to compile it.
    • alex_reader
      alex_reader about 10 years
      I've edited the question accordingly.
    • ctrl-alt-delor
      ctrl-alt-delor about 10 years
      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.
    • Stéphane Chazelas
      Stéphane Chazelas about 10 years
      Wikipedia says It [the OSABI field in the ELF header] is often set to 0 [SysV] regardless of the target platform
    • Leiaz
      Leiaz about 10 years
      This field tells if the ELF file is using any OS specific extensions, the default is 0. More detailled description here(at EI_OSABI).
    • Jakob Bennemann
      Jakob Bennemann about 10 years
      @StephaneChazelas, that's probably the answer. Maybe good to post it as one. :)
  • Ciro Santilli Путлер Капут 六四事
    Ciro Santilli Путлер Капут 六四事 about 8 years
    And the ELF standard says 0 means "ELFOSABI_NONE 0 No extensions or unspecified" sco.com/developers/gabi/2003-12-17/ch4.eheader.html