Is there a libc in kernel space?

落爺英雄遲暮 提交于 2019-12-05 03:45:06

问题


Is there a libc in kernel space? I mean you have to build kernel against some libc right? So Is there a libc (probably statically-linked) sitting within kernel space?

If yes, how is this related to userland glibc? Must they be the same version?


回答1:


There is actually no libc in kernel space. Libc is user-space library, and you can't use it from kernel-space.

But almost all functions from libc that make sense in kernel space are ported. You can find headers in include/linux/ usually.

As far as I know these two implementations don't share codebase.




回答2:


Some of the functions that are available in libc are implemented inside the kernel code, for example there's a printf function that works as the normal (at least as far as the kernel code it self requires).

This means that while it looks like the code uses libc (by the functions that seem to be available) there actually no need to link it with a library (AFAIK).



来源:https://stackoverflow.com/questions/19489610/is-there-a-libc-in-kernel-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!