Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I posted the same post in "programming & scripting" forum but I think this forum is a more appropriate place to post questions about Linux kernel so I created ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2006
    Posts
    25

    Module does not load into Suse Enterprise Server 11 kernel


    Hello,

    I posted the same post in "programming & scripting" forum but I think this forum is a more appropriate place to post questions about Linux kernel so I created another thread here. Sorry for that.

    Here is my problem:

    I have 2 simple modules. The first one exports 2 functions and the second one uses those exported functions. These work perfectly on Redhat 5.0 or Suse Enterprise Server10 but not on Suse Enterprise Server 11.

    In order to be able to compile the modules on Suse Enterprise Server 11, I do "make cloneconfig" then "make modules_prepare" in /usr/src/linux.

    At first the kernel of Suse Enterprise 11 complains "invalid module format" when I insert the first module in using "insmod mod1.ko". so I recompile the modules using modversions (copy Module.symvers from /usr/src/linux-2.6.27.19-5-obj/i386/pae to /usr/src/linux and do "make" again). This time the first module loads OK but the second module does not load. The kernel displays these error messages:
    "insmod: error inserting 'mod2.ko': -1 Unknown symbol in module"
    "mod2: no symbol version for export1"
    "mod2: Unknown symbol export1"

    My questions are: does the way to export symbol change in kernel version 2.6.26 and later (SuSe Enterprise server has kernel 2.6.27)? Is there an extra step to prepare for compiling kernel module (usually I do "make cloneconfig" then "make modules_prepare" in /usr/src/linux)? Is there anyone out there that ran into this problem before? Is there a solution for this? The source files are shown below.

    Your help is greatly appreciated. Thank you.

    /***********/
    /* module1.c */
    /***********/

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

    MODULE_LICENSE ("Proprietary");

    void export1(void);
    void export2(void);

    static int hello_init(void)
    {
    printk(KERN_ALERT "Hello, world\n");
    return 0;
    }
    static void hello_exit(void)
    {
    printk(KERN_ALERT "Goodbye, cruel world\n");
    }

    void export1(void)
    {
    printk(KERN_ALERT "Hello, there\n");
    }

    void export2(void)
    {
    printk(KERN_ALERT "Poor you, goodbye\n");
    }

    EXPORT_SYMBOL(export1);
    EXPORT_SYMBOL(export2);

    module_init(hello_init);
    module_exit(hello_exit);

    /********************/
    /* Makefile of module1.c */
    /********************/
    EXTRA_CFLAGS += -DMODVERSIONS

    KVERSION = $(shell uname -r)
    KDIR = /usr/src/linux

    obj-m += mod1.o
    mod1-objs := module1.o

    all:
    make -C $(KDIR) M=$(PWD) modules
    clean:
    make -C $(KDIR) M=$(PWD) clean

    /***********/
    /* module2.c */
    /***********/
    #include <linux/init.h>
    #include <linux/module.h>

    MODULE_LICENSE ("Proprietary");

    extern void export1(void);
    extern void export2(void);


    static int hello_init(void)
    {
    export1();
    return 0;
    }
    static void hello_exit(void)
    {
    export2();
    }

    module_init(hello_init);
    module_exit(hello_exit);

    /********************/
    /* Makefile of module2.c */
    /********************/
    EXTRA_CFLAGS += -DMODVERSIONS

    KVERSION = $(shell uname -r)
    KDIR = /usr/src/linux

    obj-m += mod2.o
    mod2-objs := module2.o

    all:
    make -C $(KDIR) M=$(PWD) modules
    clean:
    make -C $(KDIR) M=$(PWD) clean

  2. #2
    Just Joined!
    Join Date
    Mar 2006
    Posts
    25
    Hello all, when I copy the Module.symvers(contains the info of exported symbols), generated when building the first module, to the directory of the second module and build the second module again. Then the second module can load into the kernel of Suse Enterprise Server 11. Am I doing the right thing? Is this a new way of exporting the symbols from a module in kernel 2.6.26 and later? Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •