help required for KBUILD
Sudo Code for kernel module compilation using KBUILD SYSTEM.
If module versioing is enabled.
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
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.
And what is .tmp_<module name>.ver file.
Chat on a cool, new interface. No download required. Go to http://in.messenger.yahoo.com/webmessengerpromo.php
Hi Murtuja.
Quoted 4 lines · murtuja bharmal
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.
Quoted 15 lines
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; thengcc -D GENKSYMS
..............|scripts/genksyms/genksyms >
.tmp_<module name>.ver
Quoted 7 lines
ld -m
elf_i386-r -o <module name>.o .tmp_<module
name>.o .tmp_<module name>.verelse
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
Quoted 19 lines
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
Quoted 7 lines
In step 2 it is checking for
__ksymtabon .tmp_<module name>.o header.Can anybody tell me when
__ksymtabin included in module object header.
Is it only added when we haveEXPORT_SYMBOLMacro 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_*.
Quoted 1 line
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