Im trying to build and insert a kernel module that uses precompiled object file. The precompiled object file was compiled with asm (GNU assembler).
Here is the Makefile:
obj-m += klm.o
klm-objs := a.o
klm.o:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
and klm.c:
#define LINUX
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
extern volatile unsigned long peak_create();
int init_module(void)
{
printk("<1>Hello world 1.\n");
peak_create();
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
EXPORT_SYMBOL_GPL(peak_create);
MODULE_LICENSE("GPL");
But when I’m trying to insert the ko file (using insmod klm.ko) dmesg shows the error:
klm: Unknown symbol peak_create (err 0)
the source file of a.o contains global deceleration of peak_create. (.globl peak_create)
How can I use peak_create in the kernel module ?
Thank you all!
Try modifying the Makefile to this :
obj-m := klm_out.o
klm_out-objs : klm.o a.o
modules:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
# Put the asm compilation command here
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
rm -f a.o
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With