When creating kernel modules, why do we need / lib / modules?

In the Kbuild tree, when we write a simple hello.ko program, why do we use -C / lib / module / in the build rule. Why is this required? Can it be built exclusively? What is his purpose?

0
source share
2 answers

while building kernel modules why do we need /lib/modules?

It is not necessary to give the above option ie the /lib/modulesmain intention is to get configured source-code directory.

You can install directly configured source code, or you can provide above ie / lib / modules /, which have a programmatic link for the embedded source code.

KDIR,

( ) ( ).

1)Full kernel sources

2)Only kernel headers (linux-headers-* packages in Debian/Ubuntu distributions)

configured. macros or functions depend on the configuration

-C kernel Makefile, module directory in the M variable ,the kernel Makefile knows how to compile a module.

, ​​ Arm architecture or machine, configured kernel Makefile , .

needs access to the kernel headers, containing the defnitions of functions, types and constants.

Can it be build solely?

, , , , , . toplevel Makefile of configured kernel.

+2

, , , make

        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

-C makefile. , make , /lib/modules/ $(shell uname -r)/build.

Linux - , .

make .

+1

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


All Articles