Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Where does the kernel info in an executable come from?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Mon Jan 26, 2015 6:28 pm    Post subject: Where does the kernel info in an executable come from? Reply with quote

Hi,

I recently reinstalled from a stage3 using a previous Gentoo installation for the initial chroot part of the process.

I have a bootable ( non-X ) system that is capable of emerging packages but there is a problem.

If I examine the executables build by the new system they show a kernel version of 2.6.x with was the kernel of the old system during chroot.

I have tried rebuilding glibc glib binutils and a number of other system packages from the freshly booted Gentoo, but newly built files are still showing old kernel version.

gcc is 4.8.4 and gcc-config -l shows the new kernel version.

A non-portage fortran file fails to rum properly when build under this system and file a.out output equally shows it was build for 2.6..x

Where does this info come from and what needs rebuilding on the newly booted system to get correct output?

TIA, Gentree. 8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
Apheus
Guru
Guru


Joined: 12 Jul 2008
Posts: 420

PostPosted: Mon Jan 26, 2015 8:29 pm    Post subject: Reply with quote

How exactly do you examine the binaries?

Code:
$ file /usr/lib64/firefox/firefox-bin
/usr/lib64/firefox/firefox-bin: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.16, stripped

$ file /lib64/libm-2.19.so
/lib64/libm-2.19.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a046bf8c6804250f3bac4f704b30063dfade3055, for GNU/Linux 2.6.16, stripped


This is normal and only a min required kernel version, I presume. I have never seen file report anything requring kernel 3.x.
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Mon Jan 26, 2015 8:40 pm    Post subject: Reply with quote

Ah thanks, maybe I was not paying close enough attention.

The old kernel was 2.6.32 , I was assuming that this related to the kernel version of glibc or something. I had not thought of it being a minimum kernel version.
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Tue Jan 27, 2015 7:40 am    Post subject: Reply with quote

No, I've checked back on the new installation and the kernel version reported is 2.6.32 which is that of the old system from which the chroot was done.

This implies that something is building using 'uname' instead of the target system specified in the CFLAGS -march= settings. So the question remains where does this come from and what needs rebuilding to remove it.


If this is displayed in 'file' it must matter. What does it affect?

TIA. 8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Tue Jan 27, 2015 3:17 pm    Post subject: Reply with quote

Gentree wrote:
If this is displayed in 'file' it must matter. What does it affect?

guessing:

elf format should have version (even God didn't build stuff in 1 day), and it tells you a kernel 2.1.16 is able to understand that elf format version.
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Tue Jan 27, 2015 4:22 pm    Post subject: Reply with quote

Well everyone's guessing but guess that it doesn't matter.

I've checked in the old system and
Code:
 file /bin/cp 
reports 2.6.9, which was what I running a while back ( not even the previous kernel version before 2.6.23 ). So it looks like this gets pulled from uname at some stage and gets embedded and transmitted like some bit of virus or "junk" DNA into future compilers.

I thought this might indicate I'd messed up somewhere and wanted to check it out before charging ahead with building everything I need into the new system.

Since this seems to be a "normal" oddity, I'll carry on.

Thx for replies.
8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
acmondor
n00b
n00b


Joined: 08 Aug 2014
Posts: 35
Location: Canadian Prairies

PostPosted: Sun Feb 01, 2015 10:50 pm    Post subject: Reply with quote

I was curious so I did a bit of digging and this is what I came up with:

Code:
# file /bin/cp
/bin/cp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.16, stripped


# readelf -n /bin/cp

Displaying notes found at file offset 0x0000028c with length 0x00000020:
  Owner                 Data size       Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 2.6.16


# man ld.so                              (explains NT_GNU_ABI_TAG)

...snip...

       LD_ASSUME_KERNEL
              (glibc since 2.2.3) Each shared library can inform the dynamic linker
              of  the  minimum kernel ABI version that it requires.  (This require‐
              ment is encoded in an ELF note section that  is  viewable  via  read‐
              elf -n  as  a  section  labeled  NT_GNU_ABI_TAG.)   At  run time, the
              dynamic linker determines the ABI version of the running  kernel  and
              will  reject  loading  shared libraries that specify minimum ABI ver‐
              sions that exceed that ABI version.

              LD_ASSUME_KERNEL can be used to cause the dynamic  linker  to  assume
              that  it  is running on a system with a different kernel ABI version.
              For example, the following command line causes the dynamic linker  to
              assume it is running on Linux 2.2.5 when loading the shared libraries
              required by myprog:

                  $ LD_ASSUME_KERNEL=2.2.5 ./myprog

              On systems that provide multiple versions of  a  shared  library  (in
              different directories in the search path) that have different minimum
              kernel ABI version requirements,  LD_ASSUME_KERNEL  can  be  used  to
              select  the  version  of  the  library that is used (dependent on the
              directory search order).  Historically, the most common  use  of  the
              LD_ASSUME_KERNEL  feature  was  to  manually  select the older Linux‐
              Threads POSIX threads implementation on systems  that  provided  both
              LinuxThreads and NPTL (which latter was typically the default on such
              systems); see pthreads(7).

...snip...


# readelf -n /lib64/libc.so.6      (n.b. /lib64/libc.so.6 is a symlink to /lib64/libc-2.19.so)

Displaying notes found at file offset 0x000002a8 with length 0x00000020:
  Owner                 Data size       Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 2.6.16



I'm not 100% sure, but it appears that the minimum kernel ABI version assigned to a program (at build time) is that from the glibc library on the system (at build time).

The minimum kernel ABI version assigned to glibc is defined in its the ebuild:

Code:
# cd /usr/portage/sys-libs/glibc
# grep 'min kernel version' *.ebuild | cut --delimiter=\# --fields=-1 | sort | grep KERN
glibc-2.10.1-r1.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.11.3.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.12.1-r3.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.12.2.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.13-r2.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.13-r4.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.14.1-r2.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.14.1-r3.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.14.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.15-r1.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.15-r2.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.15-r3.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-2.16.0.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.16"}       
glibc-2.17.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.16"}       
glibc-2.18-r1.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.16"}       
glibc-2.19-r1.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.16"}       
glibc-2.19.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.16"}       
glibc-2.20-r1.ebuild:: ${NPTL_KERN_VER:="2.6.32"}                   
glibc-2.20.ebuild:: ${NPTL_KERN_VER:="2.6.32"}                   
glibc-2.9_p20081201-r3.ebuild:NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}       
glibc-9999.ebuild:: ${NPTL_KERN_VER:="2.6.32"}
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Mon Feb 02, 2015 6:02 am    Post subject: Reply with quote

Thanks acmondor, good work. You've restored by faith in Gentoo forums. ;)

I was guessing that this came from glibc ( which I did rebuld from the chroot before rebooting to the new installation ). That much would seem to fit nicely.

However, having guessed that I then rebuild kernel, glib, glibc and gcc on the new system expecting this to flush out the last traces off my 2.6.32 system.

I'm still getting that version showing.

When I have a day to spare when I don't need the computer I'll try to emerge system and see whether it clears it.

Thanks for digging into the question in thorough and competent way. A few years ago I would have got that kind of response in 24h here. I get the impression Gentoo usage has dropped considerably. :(

You're a hardcore Gentooer, many thanks.
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum