简体   繁体   English

各种glibc和Linux内核版本的兼容性

[英]Various glibc and Linux kernel versions compatibility

When building a compiler, one must specify Linux headers version and minumum supported kernel version, in addition to glibc version. 在构建编译器时,除了glibc版本之外,还必须指定Linux头版本和最小支持的内核版本。 And then there is actual kernel version and glibc version (with its own kernel headers version and minumum supported kernel version) on the target machine. 然后在目标机器上有实际的内核版本和glibc版本(具有自己的内核头文件版本和最低支持的内核版本)。 I'm rather confused trying to understand how these versions go together. 我很难理解这些版本是如何结合在一起的。

Example 1: Assume I have system with glibc 2.13 built against kernel headers 3.14 . 示例1:假设我的系统具有针对内核头3.14构建的glibc 2.13 Does that make any sense? 这有任何意义吗? How is it possible for glibc 2.13 (released in 2011) to use new kernel features from 3.14 (released in 2014)? glibc 2.13 (2011年发布)如何使用3.14 (2014年发布)的新内核功能?

Example 2: Assume I have a compiler with glibc version newer than 2.13 . 例2:假设我有一个编译器,glibc的版本比2.13 更新 Will compiled programs work on system with glibc 2.13 ? 编译程序是否可以在glibc 2.13系统上运行? And if compiler's glibc version is older than 2.13 ? 如果编译器的glibc版本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's OK to use older kernel if it satisfies "minumum kernel version" used when compiling glibc. 示例3:来自https://sourceware.org/glibc/wiki/FAQ#What_version_of_the_Linux_kernel_headers_should_be_used.3F我明白如果它满足编译glibc时使用的“最小内核版本”,则可以使用旧内核。 But I don't understand the passage 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. 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 it the only thing that can happen to me? 这是唯一可能发生在我身上的事吗? Won't it break something in glibc if the kernel is newer than at compile-time? 如果内核比编译时更新,它会不会在glibc中破坏某些东西?

Example 4: Do more subtle differences in glibc settings (for example, linking an executable against glibc version 2.X compiled against kernel headers 3.Y with minimum supported kernel version 2.6.A and executing in on system with the same glibc 2.X , but compiled against kernel headers 3.Z with minumum supported kernel version 2.6.B ) influence anything? 示例4:在glibc设置中执行更细微的差异(例如,将可执行文件与针对内核头文件3.Y编译的glibc版本2.X 链接到最小支持内核版本2.6.A并在具有相同glibc 2.X的系统上执行,但针对内核头文件编译3.Z与minumum支持内核版本2.6.B )影响什么? I suspect they're not, but would like to be sure. 我怀疑他们不是,但我想确定。

So many questions :) Thanks! 这么多问题:)谢谢!

  1. You can not easily (for whatever definition of the word) use newer kernel features with older versions of glibc. 您不能轻易(对于该词的任何定义)使用旧版本的glibc更新的内核功能。 If you really need to, you can invoke system calls directly (using the syscall() library function) and dig whatever constant values and datastructures necessary from user-space kernel headers (the stuff which in the newer kernel is held under include/uapi ). 如果你真的需要,你可以直接调用系统调用(使用syscall()库函数)并从用户空间内核头文件中挖掘所需的任何常量值和数据结构(在较新的内核中include/uapi ) 。 On the other hand, kernel developers usually promise not to break legacy features in newer kernels, so older glibc versions keep working as expected (well, almost). 另一方面,内核开发人员通常承诺不会破坏较新内核中的遗留功能,因此较旧的glibc版本会按预期工作(好吧,差不多)。

  2. Older programs still work with newer versions of glibc because glibc supports versioning of symbols (see here for some details: https://www.kernel.org/pub/software/libs/glibc/hjl/compat/ ). 较旧的程序仍然适用于较新版本的glibc,因为glibc支持符号的版本控制(有关详细信息,请参阅此处: https//www.kernel.org/pub/software/libs/glibc/hjl/compat/ )。 If your program is dynamically linked with newer version of glibc without special provisions (as described in the link above) you would not be able to run it with an older version of glibc libraries (dynamic linker will complain about unresolved symbols, as proper symbol versions will not be available). 如果您的程序与较新版本的glibc动态链接而没有特殊规定(如上面的链接所述),您将无法使用旧版本的glibc库运行它(动态链接器会抱怨未解析的符号,作为正确的符号版本将无法使用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM