Compatible with glibc and Linux kernel versions

When creating the compiler, in addition to the glibc version, you must specify the Linux header version and the kernel version with minumum support. And then on the target machine there is a real kernel version and a glibc version (with its own version of kernel headers and a minimal kernel version). I'm pretty confused trying to figure out how these versions go together.

Example 1: Suppose I have a system with glibc 2.13 built into the 3.14 kernel headers. Does this make sense? How is it possible for glibc 2.13 (released in 2011) to use the new kernel features from version 3.14 (released in 2014)?

Example 2: Suppose I have a compiler with a version of glibc newer than 2.13. Will compiled programs work on glibc 2.13? And if the glibc compiler version is older than 2.13?

Example 3: From https://sourceware.org/glibc/wiki/FAQ#What_version_of_the_Linux_kernel_headers_should_be_used.3F I understand that it is ok to use an older kernel if it satisfies the "minimal kernel version" used when compiling glibc, But I do not understand The other way round (compiling the GNU C library with old kernel headers and running on a recent kernel) does not necessarily work as expected. For example you can't use new kernel features if you used old kernel headers to compile the GNU C library. The other way round (compiling the GNU C library with old kernel headers and running on a recent kernel) does not necessarily work as expected. For example you can't use new kernel features if you used old kernel headers to compile the GNU C library. . Is this the only thing that can happen to me? Wouldn't that break something in glibc if the kernel is newer than at compile time?

Example 4: Make more subtle differences in glibc settings (for example, associating an executable with a version of glibc 2.X compiled with 3.Y kernel headers with a minimum supported kernel version 2.6.A and running on a system with the same glibc 2.X, but compiled against 3.Z kernel headers with the minimum supported kernel version 2.6.B)? I suspect that this is not so, but I would like to be sure.

So many questions :) Thank you!

+5
source share
1 answer
  • You cannot easily (for any definition of a word) use the new kernel features with older versions of glibc. If you really need to, you can directly access system calls (using the syscall() library function) and dig out any constant values ​​and data structures needed from user space kernel headers (material that is in the new kernel under include/uapi ), C on the other hand, kernel developers usually promise not to interrupt legacy functions in new kernels, so older versions of glibc work fine (well, almost).

  • Older programs still work with newer versions of glibc, since glibc supports version control of characters (see some details here: https://www.kernel.org/pub/software/libs/glibc/hjl/compat/ ). If your program is dynamically linked to the new version of glibc without special provisions (as described in the link above), you will not be able to run it with the old version of glibc libraries (the dynamic linker will complain about unresolved characters, as the correct version of the characters will not be available).

+6
source

Source: https://habr.com/ru/post/1207809/


All Articles