In the Kbuild tree, when we are writing a simple hello.ko program then why do we need to use -C /lib/module/ in the build rule. Why this is required? Can it be build solely? What is the purpose of it?
相关问题
- Kernel oops Oops: 80000005 on arm embedded system
- Linux kernel behaviour on heap overrun or stack ov
- Where is the standard kernel libraries to let kern
- What is the difference between /dev/mem, /dev/kmem
- Conditional compilation based on functionality in
相关文章
- How do I get to see DbgPrint output from my kernel
- Enable dynamic debug for multiple files at boot
- Is it possible to run 16 bit code in an operating
- How to arrange a Makefile to compile a kernel modu
- Difference in ABI between x86_64 Linux functions a
- Why are there no debug symbols in my vmlinux when
- Tool to Debug Guest OS in Virtual Box
- ccflag option in Makefile
while building kernel modules why do we need /lib/modules?
Its not a compulsory to give above option i.e
/lib/modules
The main intention is toget configured source-code directory
.You can set to directly configured source-code or u can provide above i.e /lib/modules/ which having softlink for built source-code.
KDIR,
you can either set full kernel source directory (configured and compiled) or just kernel headers directory (minimum needed). Two solutions
1)Full kernel sources
2)Only kernel headers (linux-headers-* packages in Debian/Ubuntu distributions)
where in both case The sources or headers must be
configured
.Manymacros or functions depend on the configuration
-C
option calls thekernel Makefile
, passing themodule directory in the M variable ,the kernel Makefile knows how to compile a module
.for e.g if you configure your kernel for
Arm architecture or machine
thenconfigured kernel Makefile
will tell how to compile and for which arhitecture your modules should be built.To be compiled, a kernel module
needs access to the kernel headers, containing the defnitions of functions, types and constants
.Can it be build solely?
No you cant build solely since you module should should know for which kernel you want to build it and which configuration it needs to be compiled so that while inserting your module All respective symbols and configuration should be matched. All this can be done through
toplevel Makefile of configured kernel
.To Build a module usually following command you write in the make file
In the above -C is used to change the directory before reading the makefile. So when make executes it go to the directory /lib/modules/$(shell uname -r)/build.
In Linux usually build is a soft link to the kernel source or source need to build a module.
From that source, make command read the kernel make file and build your module.