0

I'm trying to write a Linux kernel module, but I'm stuck just writing some stub code. I've compiled this code in Ubuntu:

#include <linux/module.h>
int init_module(void){ printk("<1> hellp"); return 0;}
void cleanup_module(void){ printk("<1> bye");}

However, when I try to insmod it I get the error:

Invalid module format

After googling I figured it may be some problem with version compatibility, but I'm not sure. What am I doing wrong?

0

1 Answer 1

2

You're missing the MODULE_ parameters, here's an empty kernel project:

#include <linux/module.h>
#include <linux/kernel.h>

static void __exit cleanup(void)
{
}


static int __init startup(void)
{
}

module_init(startup);
module_exit(cleanup);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Someone Like You");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.