Hi everybody,
I'm trying to write a kernel module. Actually it's written. Even more, I
can compile it without warnings.
However, when I'm loading it I get the following error message:
mymodule.o: Relocation overflow of type 4 for printk
Do you have any ideas?
Thanks in advance and best regards,
George
George Agasandian
E-Mail:� [EMAIL PROTECTED]
P.S.
Compilation command line: gcc -c mysyscall.c -o mymodule.o -Wall
Source file:
-----------
#ifndef MODULE
#define MODULE
#endif
#ifndef __KERNEL__
#define __KERNEL__
#endif
/* Standard headers for LKMs */
#include <linux/module.h>
#define _LOOSE_KERNEL_NAMES
/* With some combinations of Linux and gcc, tty.h will not compile if
you don't define _LOOSE_KERNEL_NAMES. It's a bug somewhere.
*/
#include <linux/tty.h> /* console_print() interface */
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <asm/fcntl.h>
#include <asm/errno.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/slab.h>
extern void* sys_call_table[]; /*sys_call_table is exported, so we
can access it*/
//#define PRINTK console_print
#define PRINTK printk
int (*orig_lkm_sys_call)(const char *path); /*the original systemcall*/
int hacked_lkm_sys_call(const char *path)
{
PRINTK("My SysCall\n");
return 0; /*everything is ok, but he new
systemcall
does nothing*/
}
int init_module(void) /*module setup*/
{
orig_lkm_sys_call=sys_call_table[__NR_unused150];
sys_call_table[__NR_unused150]=hacked_lkm_sys_call;
PRINTK("Hello World\n");
return 0;
}
void cleanup_module(void) /*module shutdown*/
{
/*set lkm_sys_call syscall to the origal one*/
sys_call_table[__NR_unused150]=orig_lkm_sys_call;
PRINTK("Bye World\n");
}
/*module_init(mysyscall_init);
module_exit(mysyscall_exit);
*/
MODULE_LICENSE("GPL");
================================================================To unsubscribe, send
mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]