Re: help required for KBUILD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Murtuja.

On Mon, Feb 11, 2008 at 07:25:06AM +0000, murtuja bharmal wrote:
> Sudo Code for kernel module compilation using KBUILD
> SYSTEM. 
> 
> If module versioing is enabled. 

I assume you are aware that all these steps are taken care
of by kbuild and that you do not need to do them manually
neither to understand them to use them?

This is also true for external modules.

> 
> step1. 
> 
> create a .tmp_<moudule name>.o file from <module
> name>.c using gcc. 
> 
> step2. 
> 
> if objdump -h .tmp_<module name>.o | grep -q
> __ksymtab; then 
> 
> gcc -D GENKSYMS
> ..............|scripts/genksyms/genksyms >
> .tmp_<module name>.ver 
> 
> ld -m elf_i386 -r -o <module name>.o .tmp_<module
> name>.o .tmp_<module name>.ver 
> 
> else 
> 
> mv -f .tmp_<module name>.o <module name>.o 
> 

Correct -this is also explained in Makefile.build like this:
# When module versioning is enabled the following steps are executed:
# o compile a .tmp_<file>.o from <file>.c
# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
#   not export symbols, we just rename .tmp_<file>.o to <file>.o and
#   are done.
# o otherwise, we calculate symbol versions using the good old
#   genksyms on the preprocessed source and postprocess them in a way
#   that they are usable as a linker script
# o generate <file>.o from .tmp_<file>.o using the linker to
#   replace the unresolved symbols __crc_exported_symbol with
#   the actual value of the checksum generated by genksyms


> Step 3. 
> 
> LINUXDIR/scripts/mod/modpost .............. vmlinux
> <module name>.o 
> 
> #the above command create file <module name>.mod.c 
> 
> Step 4. 
> 
> gcc ....................... - o <module name>.mod.o
> <module name>.mod.c 
> 
> Step 5. 
> 
> ld -m elf_i386 -r -o <module name>.ko <module name>.o
> <module name>.mod.o 
> 
> 
> 
> In step 2 it is checking for 
> __ksymtab on .tmp_<module name>.o header.
> 
> Can anybody tell me when __ksymtab in included in
> module object header.
> Is it only added when we have EXPORT_SYMBOL Macro in
> kernel module code or any other reason.
Correct - it is only included if there is an exported symbol,
as an exported symbol place some info in a section named ksymtab_*.

> And what is .tmp_<module name>.ver file.
If you look at it you will see it caontains the CRC values for the
exported symbols - the values are then checked later when the module
is loaded by the module for consitency.

	Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux