LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Kernel module compilation problem (https://www.linuxquestions.org/questions/programming-9/kernel-module-compilation-problem-700652/)

marcintom 01-28-2009 06:50 PM

Kernel module compilation problem
 
Hi
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

Code:

lib1.h
lib1.c

mod.c

mod.c works fine normally but when I divide into several files
and try to compile with this makefile

Code:

obj-m := mod.o
mod-objs := lib1.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

I get this

Code:


zet modulANDlibs # make
make -C /lib/modules/2.6.18-gentoo-r2/build SUBDIRS=/root/modulANDlibs modules
make[1]: 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.
MODPOST
CC /root/modulANDlibs/mod.mod.o
LD [M] /root/modulANDlibs/mod.ko
make[1]: 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 ?


All times are GMT -5. The time now is 05:50 PM.