linux存在哪些东西,Linux:modpost没有构建任何东西

我在使用我的机器上构建任何内核模块时遇到问题.每当我构建一个模块时,modpost总是说零模块:

MODPOST 0 modules

为了解决这个问题,我编写了一个测试模块(hello.c):

#include /* Needed by all modules */

#include /* Needed for KERN_INFO */

#include /* Needed for the macros */

static int __init hello_start(void)

{

printk(KERN_INFO "Loading hello module...

");

printk(KERN_INFO "Hello world

");

return 0;

}

static void __exit hello_end(void)

{

printk(KERN_INFO "Goodbye Mr.

");

}

module_init(hello_start);

module_exit(hello_end);

这是模块的Makefile:

obj-m = hello.o

KVERSION = $(shell uname -r)

all:

make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) modules

clean:

make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) clean

当我在我的机器上构建它时,我得到以下输出:

make -C /lib/modules/2.6.32-27-generic/build M=/home/waffleman/tmp/mod-test modules

make[1]: Entering directory `/usr/src/linux-headers-2.6.32-27-generic'

CC [M] /home/waffleman/tmp/mod-test/hello.o

Building modules, stage 2.

MODPOST 0 modules

make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-27-generic'

当我在另一台机器上制作模块时,它是成功的:

make -C /lib/modules/2.6.24-27-generic/build M=/home/somedude/tmp/mod-test modules

make[1]: Entering directory `/usr/src/linux-headers-2.6.24-27-generic'

CC [M] /home/somedude/tmp/mod-test/hello.o

Building modules, stage 2.

MODPOST 1 modules

CC /home/somedude/tmp/mod-test/hello.mod.o

LD [M] /home/somedude/tmp/mod-test/hello.ko

make[1]: Leaving directory `/usr/src/linux-headers-2.6.24-27-generic'

我找了关于modpost的任何相关文档,但发现很少.任何人都知道modpost如何决定构建什么?我可能缺少一个环境吗?

BTW在这里是我正在运行的:

uname -a

Linux waffleman-desktop 2.6.32-27-generic #49-Ubuntu SMP Wed Dec 1 23:52:12 UTC 2010 i686 GNU/Linux

编辑

这是使用V = 1的make run:

make -C /lib/modules/2.6.32-27-generic/build M=/home/waffleman/tmp/mod-test modules

make[1]: Entering directory `/usr/src/linux-headers-2.6.32-27-generic'

test -e include/linux/autoconf.h -a -e include/config/auto.conf || ( \n echo; \n echo " ERROR: Kernel configuration is invalid."; \n echo " include/linux/autoconf.h or include/config/auto.conf are missing."; \n echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \n echo; \n /bin/false)

mkdir -p /home/waffleman/tmp/mod-test/.tmp_versions ; rm -f /home/waffleman/tmp/mod-test/.tmp_versions/*

make -f scripts/Makefile.build obj=/home/waffleman/tmp/mod-test

gcc -Wp,-MD,/home/waffleman/tmp/mod-test/.hello.o.d -nostdinc -isystem /usr/lib/gcc/i486-linux-gnu/4.4.3/include -Iinclude -I/usr/src/linux-headers-2.6.32-27-generic/arch/x86/include -include include/linux/autoconf.h -Iubuntu/include -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -m32 -msoft-float -mregparm=3 -freg-struct-return -mpreferred-stack-boundary=2 -march=i586 -mtune=generic -maccumulate-outgoing-args -Wa,-mtune=generic32 -ffreestanding -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=1024 -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(hello)" -D"KBUILD_MODNAME=KBUILD_STR(hello)" -c -o /home/waffleman/tmp/mod-test/.tmp_hello.o /home/waffleman/tmp/mod-test/hello.c

set -e ; perl /usr/src/linux-headers-2.6.32-27-generic/scripts/recordmcount.pl "i386" "32" "objdump" "objcopy" "gcc" "ld" "nm" "" "" "1" "/home/waffleman/tmp/mod-test/hello.o";

(cat /dev/null; echo kernel//home/waffleman/tmp/mod-test/hello.ko;) > /home/waffleman/tmp/mod-test/modules.order

make -f /usr/src/linux-headers-2.6.32-27-generic/scripts/Makefile.modpost

scripts/mod/modpost -m -a -i /usr/src/linux-headers-2.6.32-27-generic/Module.symvers -I /home/waffleman/tmp/mod-test/Module.symvers -o /home/waffleman/tmp/mod-test/Module.symvers -S -w -s

make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-27-generic'

waffleman@waffleman-desktop:~/tmp/mod-test$cat /home/waffleman/tmp/mod-test/modules.order

kernel//home/waffleman/tmp/mod-test/hello.ko

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值