restart 发表于 2003-10-19 22:33:38

模块加载时出现unresolved symbol问题

在redhat9.0,内核2.4.20下,用insmod加载模块出现unresolved symbol sys_call_table的错误,但在debian下,同样版本内核(编译时用的选现也差不多)没问题。
有谁知道怎么回事?

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

#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif

extern void *sys_call_table[];

/* Pointer to original chdir function, we must call this
   from our intercept function to allow for normal directory
   changes.This will also be used to restore the syscall pointer
   when this module is unloaded. */
int (*old_sys_chdir)(const char *);

int (*sys_getuid)();

int sys_chdir_intercept(const char *path) {
printk("%d %s\n", sys_getuid(), path);

return old_sys_chdir(path);
}

int init_module() {
// Outputted to your syslog
printk("Module loaded..\n");

old_sys_chdir = sys_call_table[__NR_chdir];
sys_call_table[__NR_chdir] = sys_chdir_intercept;

sys_getuid = sys_call_table[__NR_getuid];

return 0;
}

void cleanup_module() {
// Outputted to your syslog
printk("Module unloaded..\n");

sys_call_table[__NR_chdir] = old_sys_chdir;
}

restart 发表于 2003-10-20 21:07:42

大哥们帮帮忙吧。。。

Dragonfly 发表于 2003-10-21 00:14:28

if u use rh kernel like 2.4.20-8/9 it disable the system_call_table export. u need to reenable it or use a different kernel.
页: [1]
查看完整版本: 模块加载时出现unresolved symbol问题