I'm trying to compile a kernel module from multiple source files. When using the make, I'm getting the following error,
make -C /lib/modules/5.4.0-47-generic/build M=/path_to_source_file modules
...
LD [M] /path_to_source_file/test.o
Building modules, stage 2.
MODPOST 1 modules
ERROR: "__udivti3" [/path_to_source_file/test.ko] undefined!
scripts/Makefile.modpost:93: recipe for target '__modpost' failed
make[2]: *** [__modpost] Error 1
I'm guessing the problem is with my Makefile. Here is the Makefile that I'm using,
obj-m += test.o
test-objs := rtmModule.o aes.o bignum.o rsa.o memset1.o memory.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
sudo insmod test.ko
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
sudo rmmod test.ko
My simple module source code rtmModule.c is,
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/random.h>
#include <linux/string.h>
#include "cacheCryptoMain.h"
#include "config.h"
#include "aes.h"
#include "bignum.h"
#include "rsa.h"
MODULE_AUTHOR("XXX");
MODULE_DESCRIPTION("kernel");
MODULE_LICENSE("GPL");
static int __init hello_init(void) {
printk(KERN_INFO "Module Loaded!\n");
return 0;
}
static void __exit hello_cleanup(void) {
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(hello_init);
module_exit(hello_cleanup);
As my source code shows that, I'm just including some other source files into the main module source code file. As I said, my best guess is, the problem is with the Makefile I just can't figure how to fix it. Any help?