Mysterious Versioning Reported By File Command

Home » CentOS » Mysterious Versioning Reported By File Command
CentOS 4 Comments

I just noticed this, which doesn’t actually seem to affect anything but does
create a mystery:

[frankcox@mutt temp]$ cat test.c
#include
int main(void)
{
printf(“Hello world\n”);
return 0;
}
[frankcox@mutt temp]$ gcc -o test test.c
[frankcox@mutt temp]$ file test
test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked
(uses shared libs), for GNU/Linux 2.6.18, not stripped
[frankcox@mutt temp]$ uname -a
Linux mutt.melvilletheatre.net 2.6.32-220.17.1.el6.x86_64 #1 SMP Wed May 16
00:01:37 BST 2012 x86_64 x86_64 x86_64 GNU/Linux

Why does the output from file say “Linux 2.6.18” when the actual kernel in use
is 2.6.32?

4 thoughts on - Mysterious Versioning Reported By File Command

  • [frankcox@mutt ~]$ rpm -q elfutils
    elfutils-0.152-1.el6.x86_64

    That’s not version 2.6.18 either.

    My question is, where does that 2.6.18 come from?

    It’s not the current kernel version, it’s not the gcc version, and it’s not the
    current elfutils version either.

  • Ok, then where does it come from, since it’s not the current kernel version and
    it’s not the elfutils version? gcc somehow finds that number and inserts it
    into the binary. Where did it find it and why is that number not the same as
    the other stuff, notably the kernel, since it appears to be a kernel version
    number? Just not the current kernel version number.

  • An educated guess would be because the C and C++ ABI is backwards
    compatable with el5. Check it out…build the code on el5 and it should
    run under el6. For el5 you need the gcc44 update package.

    John

LEAVE A COMMENT