I want to compiling my own kernel loadable module.
I have one big module 2.6.18 kernel mod.c
I want to divide this to several files.
The problem is to write right Makefile
mod.c works fine normally but when I divide into several files
and try to compile with this makefile
obj-m := mod.o
mod-objs := lib1.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
I get this
zet modulANDlibs # make
make -C /lib/modules/2.6.18-gentoo-r2/build SUBDIRS=/root/modulANDlibs modules
make: Entering directory `/usr/src/linux-2.6.18-gentoo-r2'
CC [M] /root/modulANDlibs/lib1.o
LD [M] /root/modulANDlibs/mod.o
Building modules, stage 2.
LD [M] /root/modulANDlibs/mod.ko
make: Leaving directory `/usr/src/linux-2.6.18-gentoo-r2'
zet modulANDlibs #
so this is ok but when I load this module there are no any operation
this mean mod.ko is loaded but dont work - before dividing it print to KERN_INFO "Hello world" ( dmesg )
There is one more thing. When I compile mod.c without lib* mod.ko have about 5.5Kb
but if I compile with mod-objs variable doesnt matter what is in mod.c and in lib1.c
compilation is ok loading is ok and size mod.ko is about 1.6 Kb constatntly
The questin is WHY ?