Problem with module spanning from multiple files
From: aleksey <hidden>
Date: 2012-07-18 08:40:52
Hi Philipp. On Wed, 2012-07-18 at 10:14 +0200, Philipp Ittershagen wrote:
Hi aleksey, On Wed, Jul 18, 2012 at 9:34 AM, aleksey [off-list ref] wrote:quoted
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) ;this should not compile. How does the compiler know the symbol "my_module_exit"?
I'm terribly sorry by this mistake. i rewrite my code, now it look like:
test.c:
#include <linux/kernel.h>
#include <linux/module.h>
#include "test_sub.h"
int my_module_init(void)
{
pr_emerg("Hello, world module is loading\n");
print_message();
return 0;
}
void my_module_exit(void)
{
pr_emerg("Short is the life of a kernel module\n");
}
MODULE_DESCRIPTION("test driver");
MODULE_LICENSE("GPL v2");
MODULE_VERSION("0.1");
module_init(my_module_init);
module_exit(my_module_exit);
test_sub.h:
void print_message(void);
test_sub.c:
#include <linux/kernel.h>
#include <linux/module.h>
void print_message(void)
{
pr_emerg("This is the message from kernel module\n");
}
Makefile:
obj-m = test.o
test-objs = test_sub.o
all:
$(MAKE) -C $(KDIR) M=$(shell pwd) modules
But the problem is stay. i don't receive any message on module load.
Greetings, Philipp