开始编译内核模块

时间:2020-12-14 22:25:57

 

http://bbs.nfvdr.com/thread-4917-1-1.html

 

环境:debian 5.00 内核 2.6.26-1-686
问题:使用内核包编译驱动时常常提示如下:
WARNING: Symbol version dump /usr/src/linux-2.6.26/Module.symvers
           is missing; modules will have no dependencies and modversions.

原因:通常头核心包中是没有Module.symvers这个文件的,要想获取这个文件只能到下载相同版本核心(2.6.26-1-686)的头文件,是下载不是apt-get install  !!!,只有下载的头文件中才有这个Module.symvers。把Module.symvers 复制到核心包中,然后执行如下步骤:make oldconfig && make prepare && make scripts。
然后重新编译驱动,将解决这个warning,同时也解决了版本不正确的问题

我不知道有多少人会碰上这样的问题,反正google中我发现没有人能说明白这个问题

 

 

ps:我遇到的问题是则是

 

运行:make -C /usr/src/linux-2.6.34-12 SUBDIRS=$PWD modules
出错如下:

 

make: Entering directory `/usr/src/linux-2.6.34-12'

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.


  WARNING: Symbol version dump /usr/src/linux-2.6.34-12/Module.symvers
           is missing; modules will have no dependencies and modversions.

scripts/Makefile.build:44: /usr/src/linux-2.6.34-12/PWD/Makefile: No such file or directory
make[1]: *** No rule to make target `/usr/src/linux-2.6.34-12/PWD/Makefile'.  Stop.
make: *** [_module_PWD] Error 2
make: Leaving directory `/usr/src/linux-2.6.34-12'

运行:make oldconfig && make prepare

再次出错如下:

 

make: Entering directory `/usr/src/linux-2.6.34-12'

  WARNING: Symbol version dump /usr/src/linux-2.6.34-12/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /home/xxx/test/dr/drhello.o
  Building modules, stage 2.
  MODPOST 1 modules
/bin/sh: scripts/mod/modpost: No such file or directory
make[1]: *** [__modpost] Error 127
make: *** [modules] Error 2
make: Leaving directory `/usr/src/linux-2.6.34-12'

 

加上:make scripts

可以了

 

make: Entering directory `/usr/src/linux-2.6.34-12'

  WARNING: Symbol version dump /usr/src/linux-2.6.34-12/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /home/xxx/test/dr/drhello.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/test/dr/drhello.mod.o
  LD [M]  /home/test/dr/drhello.ko
make: Leaving directory `/usr/src/linux-2.6.34-12'