Dear All,

I have written a small sample code for testing the EXPORT_SYMBOL macro
which exports the symbols to the global kernel symbol table. The sample
code is working fine in 2.6.9-1.667 kernel version, however it does not
works fine in 2.6.28 kernel version. I am getting the following errors
in 2.6.28 kernel version only.

insmod: error inserting 'import_func.ko': -1 Unknown symbol in module

When I see the /var/log/messages through dmesg command, I got the
following.

import_func: no symbol version for myexportfun
import_func: Unknown symbol myexportfun

The procedure I used for testing is as follows.

1)    Insert the export_func module as 
      insmod export_func.ko
2)    Check whether the symbols are exported or not
      cat /proc/kallsyms | grep myexp
3)    The function was exported fine and able to see the names in the
global kernel symbol table.
4)    Now, insert the import_func module as 
      insmod import_func.ko

Then I got the above errors. But the same code is working fine in
2.6.9-1.667 kernel version without any errors. Please some one correct
me what am I doing wrong.

Thanks in advance.

With Regards,
Srinivas G

The following C file code exports the symbols to the kernel symbol
table.
-------------------------------------------------------------
#include <linux/init.h>       /* for explicit init & exit */
#include <linux/kernel.h>     /* for printk */
#include <linux/module.h>     /* for MODULE_ definitions */
#include "expfunc.h"

MODULE_AUTHOR("Srinivas G");
MODULE_LICENSE("GPL");

void myexportfun(void) {
      printk("<%s> I am a exported function - NEW!\n",__FUNCTION__); }

EXPORT_SYMBOL(myexportfun);

static int exp_init(void) {
      printk("<%s> Module to demo export of symbols!\n",__FUNCTION__);
      return 0;
}

static void exp_cleanup(void) {
      printk("<%s> exiting symbol export demo module!\n",__FUNCTION__);
}

module_init(exp_init);
module_exit(exp_cleanup);
---------------------------------------------------------------
The header file contents are as follows.

#ifndef __EXPFUNC_H
#define __EXPFUNC_H

//extern void myexportfun(void);
void myexportfun(void);

#endif
----------------------------------------------------------------
The Makefile contents are as follows.
#
# Makefile to export a function name into the kernel symbol table #
Author: Srinivas G.
#
KDIR:=/lib/modules/$(shell uname -r)/build TRGT:=export_func
OBJS:=expfunc.o

EXTRA_CFLAGS +=-DEXPORT_SYMTAB -Wno-unused-variable -Wno-implicit

obj-m += $(TRGT).o
$(TRGT)-objs := $(OBJS)

default:
      $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
      $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
---------------------------------------------------------------
The contents of the import module as follows. 

#include <linux/init.h>       /* for explicit init & exit */
#include <linux/kernel.h>     /* for printk */
#include <linux/module.h>     /* for MODULE_ definitions */

#include "../export/expfunc.h"

MODULE_AUTHOR("Srinivas G");
MODULE_LICENSE("GPL");

static int my_init(void) {    
      int i;

      printk("<%s> Module to demo export of symbols\n",__FUNCTION__);
      myexportfun();

      return 0;
}

static void my_cleanup(void) {
      printk("<%s> exiting symbol export demo module \n",__FUNCTION__);
}

module_init(my_init);
module_exit(my_cleanup);
----------------------------------------------------------------
The contents of the makefile as follows.

#
# Makefile for the demo of the import module program # Author: Srinivas
G.
#
KDIR:=/lib/modules/$(shell uname -r)/build TRGT:=import_func
OBJS:=impfunc.o

EXTRA_CFLAGS +=-DEXPORT_SYMTAB -Wno-unused-variable -Wno-implicit

obj-m += $(TRGT).o
$(TRGT)-objs := $(OBJS)

default:
      $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
      $(RM) *.ko *.o *.mod.* .*.cmd -r .tmp*
----------------------------------------------------------------

_______________________________________________
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to