可让内核模块链接到的标准内核库在哪里? [英] Where is the standard kernel libraries to let kernel module link to?

查看:129
本文介绍了可让内核模块链接到的标准内核库在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于libc在用户空间下运行,因此内核模块无法调用libc.
还有其他一些内核指定的API,就像printk()一样,可以使模块正常工作.
据我了解,libc是几个标准c函数obj的集合.
它应该存在一个包含几个内核标准函数对象的集合(或库).
所以我可以将我的内核模块与这些内核标准库链接起来工作,对吧?

The kernel module can not call libc since libc run under user space.
There are some other kernel specified APIs just like printk() to make modules work fine.
As I understand that libc is a collection of several standard c function obj(s).
It is supposed to exist a collection (or library) to include several kernel standard function objects.
So I can link my kernel module with these kernel standard libraries to do work, right ?

简而言之,我的问题如下...

briefly speaking , my question is as followings ...

在用户空间中:
aaa.o链接bbb.o调用myfunc()
aaa.o链接libc.so来调用printf()

in user space :
aaa.o link bbb.o to call myfunc()
aaa.o link libc.so to call printf()

在内核空间中:
aaa.ko链接bbb.ko调用myfunc()吗?这是Question1
aaa.ko链接xxx以调用printk()吗? xxx叫什么,Question2

in kernel space :
aaa.ko link bbb.ko call myfunc() ? this is Question1
aaa.ko link xxx to call printk() ? what is xxx called , Question2

谢谢!

推荐答案

内核模块只能调用内核函数(位于内核的固定部分).他们不也不能使用任何外部库.

Kernel modules can only call kernel functions (which are in the fixed part of the kernel). They don't and can't use any external libraries.

因此没有内核标准库(内核本身包含printk).

So there is no kernel standard library (it is the kernel itself which contains printk).

从概念上讲,内核代码位于C的独立式方言中;它不使用任何C标准库函数(出于晦涩的原因,Linux内核代码未使用-ffreestanding

Conceptually, kernel code is in the freestanding dialect of C; it does not use any C standard library functions (for obscure reasons, Linux kernel code is not compiled with -ffreestanding dialect option to gcc )

这篇关于可让内核模块链接到的标准内核库在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆