Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Pb when compiling an external module that uses symbols from another module


    I'm trying to compile 2 external kernel-modules and want to use, in my second module, some symbols exported by the first module. Unfortunately, it doesn't work, but I can't figure out why ?
    Here is what I'm doing in details and the error (a little bit long but simple ):

    For module mod1.ko, , composed by one c-file mod1.c, I use such Makefile:

    EXTRA_CFLAGS += -Wall -Werror -I$(PWD)/../common
    obj-m   := mod1.o
            $(MAKE) ARCH=arm CROSS_COMPILE=arm-linux-  -C $(KERNEL_BUILD_DIR) M=$(PWD) V=1 modules
    This module exports two symbols:
    => this module compiles and works fine.

    Now I want to build my second module in another directory, which use foo() and bar().
    I'm using a Makefile, similar to the previous one, except that it is composed by several c-file Thus, I use:
    obj-m   := mod2.o
    mod2-objs := file1.c file.c ...
    All files compile fine, but modpost claims that:
    scripts/mod/modpost -m -i /my_kernel_dir/Module.symvers -I /my_module_dir/src/driver/Module.symvers -o /my_module_dir/src/driver/Module.symvers -S -w -c -s
    WARNING: "foo" [/my_module_dir/src/driver/mod2.ko] undefined!
    WARNING: "bar" [/my_module_dir/src/driver/mod2.ko] undefined!
    And of course, when I 'insmod mod2.ko', it does work and claim that:
    $ insmod mod2.ko
    mod2: no symbol version for foo
    mod2: Unknown symbol foo
    mod2: no symbol version for bar
    mod2: Unknown symbol bar
    even if mod1 is inserted.

    But if I 'grep foo /proc/kallsyms', I see my symbol:
    $ grep foo /proc/kallsyms
    bf0007e9 r __kstrtab_foo [mod1]
    bf00087c r __ksymtab_foo [mod1]
    bf0008e4 r __kcrctab_foo [mod1]
    bf00014c T foo [mod1]
    1e4dbb64 a __crc_foo [mod1]
    What am I missing ? How do I tell my driver, that these symbols have to be searched in module mod1 ?
    (Note: I'm using kernel 2.6.27)


  2. #2
    And the answer is in the Documention directory of the kernel source tree (I missed this one), in file .../Documentation/kbuild/modules.txt , section 7.2-7.3.


Posting Permissions

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