What I mean by that is that we’re planning to write the simplest, most unproductive, content free loadable kernel module imaginable.
While everything that follows in a few of this course is nothing more than adding way more features to our modules, only after we can do that, It will have no actual purpose and it will do nothing when it’s loaded that’s fine as long as.
Everything else from that point on is just learning what else you can add to it, when you can load and unload a kernel module that you wrote yourself. There should be a lot to add. Pick a location to start writing modules somewhere in your home directory we shall say a brand new directory named mod1″, where we’ll write our first module named mod1″. I’m sure it sounds familiar. Your module is not in a kernel source tree.
Now that you understand that the simple act of compiling your new module requires a wholly new build environment, how do you get that environment?
It gonna be obvious that build environment is supplied by the kernel source tree specifically, the Makefiles scattered throughout the tree that control what gets built, and when, and where to search for headers files, and where to find library routines and all most of it.
How does that whenever again, in kernel space, that means it’s not simply planning to send output to your screen. Not in user space.
Take a look at your module Makefile again, without getting into tedious detail. Keeping Now, a long story short, what that Makefile does is note the source file that you look for to compile, at which point it follows a reference to where it can find a kernel source tree that contains everything required to build a module, at which point you’ve supplied enough information for the kernel build infrastructure to come back to your module and compile it properly. Wait. There’s nothing you can do, you have to track one down somewhere, without one. That said, let me repeat what I wrote above to compile even the simplest kernel module, you need a kernel source tree somewhere against which to compile it.
So compiling their program and getting a resulting executable which, readers who are used to standard userspace programming know that writing very straightforward C program involves including some header files will typically link dynamically against the routines in the standard C library. Your new module isn’t planning to run in userspace. Of course those header files will come from the kernel header files, when you include header files in your module source code. Actually, when your module is loaded and starts to run, it going to be running entirely in kernel space and will have to link against the kernel library routines.
It will have nothing to do with the standard C library header files, and it shan’t link against the C library.