Kernel - 内核同libc的关系

内核空间中有 libc 吗?我的意思是,你必须根据某个 libc 来构建内核,对吗?那么内核空间中是否有一个 libc(可能是静态链接的)?

如果有,这与用户态的 glibc 有什么关系? 它们必须是相同的版本吗?

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?

内核空间实际上没有 libc。libc 是用户空间库,不能在内核空间使用。

但 libc 中几乎所有对内核空间有意义的函数都被移植到了内核空间。你通常可以在 include/linux/ 中找到头文件。

据我所知,这两种实现并不共享代码库。

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.

libc 中的一些可用函数是在内核代码中实现的,例如,有一个 printf 函数可以像普通函数一样工作(至少就其自身所需的内核代码而言)。

这就意味着,虽然代码看起来使用了 libc(从似乎可用的函数来看),但实际上并不需要将其与库链接(目前看来)。

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).

参考:

linux - Is there a libc in kernel space? - Stack Overflow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值