Problem with module spanning from multiple files

aleksey lexa at cfotr.com
Wed Jul 18 03:34:37 EDT 2012


Hello. 

I want to build kernel module which consist from two files. 

test.c: 
#include <linux/kernel.h>
#include <linux/module.h>

int my_module_init(void)
{
	pr_emerg("Hello, world - this is the kernel speaking\n" ) ;
	return 0;
}

MODULE_DESCRIPTION("test driver" ) ;
MODULE_LICENSE("GPL v2" ) ;
MODULE_VERSION("0.1" ) ;

module_init(my_module_init) ;
module_exit(my_module_exit) ;

test_sub.c: 
#include <linux/kernel.h>  
#include <linux/module.h>  
	
void my_module_exit()
{
	pr_emerg("Short is the life of a kernel module\n" ) ;
}
Makefile: 
obj-m = test.o 
test-objs = test_sub.o
all: 
		$(MAKE) -C $(KDIR) M=$(shell pwd) modules

The module is building without any warnings. 

When i execute insmod none of message is appear. It's look like
my_module_init function does not executed at all. 






More information about the Kernelnewbies mailing list