[] undefined!" - any way to get rid of them?-compiler-errors">

[ACCEPTED]-linux kernel module linker warnings: "*** Warning: <function> [<module>] undefined!" - any way to get rid of them?-compiler-errors

Accepted answer
Score: 16

Use KBUILD_EXTRA_SYMBOLS as below: KBUILD_EXTRA_SYMBOLS='your 1 module path'/Module.symvers

Score: 9

Finally, I got it. Thanks to shodanex for 18 putting me on the right track.

Update: Be very careful 17 when applying this fix to builds for older 16 versions of kernel, as there is a bug in 15 Makefile.modpost file in older versions of the kernel which 14 makes your build misbehave and build wrong 13 targets when you specify KBUILD_EXTMOD option.

You have 12 to specify the paths to the source of the 11 modules you depend on in KBUILD_EXTMOD make parameter.

Say, you 10 have a module foo that depends on symbols from 9 module bar.

Source files for foo are in foo/module/ and source 8 files for bar are in bar/module/

The make command in 7 Makefile for foo probably looks like

make ARCH=$$ARCH CROSS_COMPILE=$$CROSS_COMPILE -C $$LINUX_DIR \
    M=`pwd`/module \
    modules

(the exact line 6 may differ in your project).

Change it to 5

make ARCH=$$ARCH CROSS_COMPILE=$$CROSS_COMPILE -C $$LINUX_DIR \
    M=`pwd`/module \
    KBUILD_EXTMOD=`pwd`/../bar/module \
    modules

(we added the KBUILD_EXTMOD=pwd/../bar/module 4 \ line, where pwd/../bar/module is a path 3 to sources of kernel module we depend on.

One 2 would expect KBUILD_EXTRA_SYMBOLS parameter to work this way, however 1 it's KBUILD_EXTMOD.

Score: 3

No they are not. Wheter you build your code 7 in-tree or out of tree, this message should 6 not be displayed.I think you should fix 5 your Makefile. Here is an example makefile. Not 4 perfect, but used to work (until 2.6.26, did 3 not try it since) :

ifneq ($(KERNELRELEASE),)
# We were called by kbuild

obj-m += mymodule.o 
mymodule-objs := mymodule_usb.o a.o b.o c.o

else  # We were called from command line

KDIR := /lib/modules/$(shell uname -r)/build
PWD  := $(shell pwd)

default:
    @echo '    Building FOO drivers for 2.6 kernel.'
    @echo '    PLEASE IGNORE THE "Overriding SUBDIRS" WARNING'
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

install:
    ./do_install.sh *.ko

endif  # End kbuild check

clean:
    rm -f -r *.o *.ko .*cmd .tmp* core *.i

For further documentation, you 2 can check the kernel tree, the kbuild process 1 is documented

Score: 1

Related to the above technique of using 2 KBUILD_EXTMOD, and the question of which 1 kernel versions it works under:

  • andycjw indicated it didn't work for him in 2.6.12
  • It didn't work for me in 2.6.15 (broke my module build)
  • Looking through the kernel commits, I see a number of changes to Makefile.modpost that seem related in 2.6.26 and 2.6.28, so I expect one of those is the limit.
Score: 0

My need to be tailored to your tree. In 3 our source we created a SYMBOLSDIR that 2 is a path to all the modules

SYMBOLSDIR = 'some 1 path'

make (same as above example) $(KERNELDIR) MODVERDIR=$(SYMBOLSDIR) modules

More Related questions