0
votes

In my linux header files folder on my Kali kernal 5.7.0 headers included in include directory /usr/src/linux-headers-5.7.0-kali1-common/include. Inside this folders I have header files contained in sub-folders like asm-generic,linux,uapi,acpi,crypto,etc.. But inside header files, i.e. inside linux/module.h there there is one header file reference included like

    #include <asm/module.h>  // top of linux/module.h

But Actually I don't have asm folder that got included with my header files when I installed them. So one solution that came to mind is. Probably solution: Change the references from asm/* to asm-generic/* as in from asm/module.h to asm-generic/module.h inside linux/module.h and other files which I may use. I like to know is asm and asm-generic are same? meaning they contains same files and structure or is there any difference i can cause problem

If I correct the directory name in include reference than Does it make sense, or I will get into problems when I compile the module if I change headers sub directories names in include list of header files from asm to asm-generic? If I dont do this the header files will be missing

1
I do not know kali-linux. I think it includes the headers also in an other place (arch specific). Linux kernel link asm to the relevant architecture (so you may need it, but also with the kernel configuration you are using). asm-generic are templates which new architectures could use (if they do not want to implement all) -- in My Debian kernel have headers are in /usr/include/asm and /usr/include/linuxGiacomo Catenazzi
@GiacomoCatenazzi what if I create asm folder in include/ and copied to it everything from asm-generic. It may compile if names were really wrong (I doubt this). Or not compile if asm-generic is really something exists and is separate from asm and internal to kernal (since there is asm directory but I think its in some other folder like uapi or etc. in include/). I will try both. Wish I could get any specific info. is there any forum that talks about kali kernal internals or where I can get info on is asm-generic same as asm. which version of kernal u are using. is it ubantu?user786
If you want to compile a module, you need the exact same headers has the kernel used (and with complete configuration of the kernel). generic has not all files, and you need architecture specific data. I would check a package which build external modules, and I would look that package on how to get correct headers and compiler flags.Giacomo Catenazzi
If you think you need to edit the kernel header files to change asm/ to asm-generic/, you must be doing something wrong. #include <asm/module.h> should actually include the file /usr/src/linux-headers-5.7.0-kali1-common/arch/x86/include/asm/module.h on your system (assuming your system architecture is x86).Ian Abbott
These header files are only needed for building external kernel modules using the kbuild system. They should never be needed for building code that runs in user-space.Ian Abbott

1 Answers

1
votes

Short answer

They are not the same.

kernel developer might include asm-generic headers in a asm header while asm headers are the headers required for kernel modules.

You may get more info from following post

Take this question in another way.

It seems you're trying to make a kernel module.

To build a kernel module you need kernel-headers or compiled kernel source code. However I don't know kali linux, so I just provide generic suggestions here.

Where to get them

  • Some of distributions, like Ubuntu, have prebuilt linux-headers.

    • Eg: Ubuntu has it in /usr/src/linux-headers-$(uname -r)/include
  • Download it by sudo apt-get install linux-headers-$(uname -r)

    • It seems kali linux 2.0 might need more operations. Found this post might help.
  • Build it yourself

    1. Checkout linux kernel code of your desired distro.
    2. Set up kernel config with make menuconfig ( You might get stumbled here a while.. many packages might be required )
    3. Compile kernel with make modules_prepare to compile essential Module.symvers for drivers. It take significant less time than compiling a full kernel.

I presume you already found a kernel module build example. If not, you may consult offical kernel module documentation. It helps a lot if you take a while to read first two chapters.

Or another example