2011-12-15 109 views
0

我想編譯一個簡單的hello世界內核模塊,但在make命令之後,我收到下面的警告,並且不生成moduleName.ko文件。問題的原因是什麼?警告是否阻止生成.ko文件?我該如何解決這個問題?謝謝。生成命令後不生成.ko文件

make命令後輸出:

make -C /lib/modules/2.6.20.15-custom/build SUBDIRS= modules 
make[1]: Entering directory `/usr/src/linux-2.6.20.15' 
CHK  include/linux/version.h 
CHK  include/linux/utsrelease.h 
Building modules, stage 2. 
MODPOST 1595 modules 
WARNING: vmlinux - Section mismatch: reference to .init.data:boot_params from .text be tween '_text' (at offset 0xc0100036) and 'startup_32_smp' 
WARNING: vmlinux - Section mismatch: reference to .init.data:boot_params from .text between '_text' (at offset 0xc0100044) and 'startup_32_smp' 
WARNING: vmlinux - Section mismatch: reference to .init.data:init_pg_tables_end from .text between '_text' (at offset 0xc01000a6) and 'startup_32_smp' 
WARNING: vmlinux - Section mismatch: reference to .init.text:start_kernel from .text between 'is386' (at offset 0xc0100221) and 'check_x87' 
WARNING: vmlinux - Section mismatch: reference to .init.text:smp_prepare_cpus from .text between 'init' (at offset 0xc0100438) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:migration_init from .text between 'init' (at offset 0xc010043d) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:spawn_ksoftirqd from .text between 'init' (at offset 0xc0100442) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:spawn_softlockup_task from .text between 'init' (at offset 0xc0100447) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:smp_cpus_done from .text between 'init' (at offset 0xc01004bf) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:sched_init_smp from .text between 'init' (at offset 0xc01004c4) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:cpuset_init_smp from .text between 'init' (at offset 0xc01004c9) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:usermodehelper_init from .text between 'init' (at offset 0xc01004d6) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:driver_init from .text between 'init' (at offset 0xc01004db) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:sysctl_init from .text between 'init' (at offset 0xc01004e1) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.data: from .text between 'init' (at offset 0xc0100507) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.data: from .text between 'init' (at offset 0xc0100524) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:prepare_namespace from .text between 'init' (at offset 0xc010070f) and 'rest_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:__alloc_bootmem from .text between 'init_gdt' (at offset 0xc010a1fb) and 'cpu_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:__alloc_bootmem from .text between 'init_gdt' (at offset 0xc010a211) and 'cpu_init' 
WARNING: vmlinux - Section mismatch: reference to .init.text:sysenter_setup from .text between 'identify_cpu' (at offset 0xc010a8de) and 'display_cacheinfo' 
WARNING: vmlinux - Section mismatch: reference to .init.text:mtrr_bp_init from .text between 'identify_cpu' (at offset 0xc010a8e8) and 'display_cacheinfo' 
WARNING: vmlinux - Section mismatch: reference to .init.text:trap_init_f00f_bug from .text between 'init_intel' (at offset 0xc010c7f5) and 'cpuid4_cache_lookup' 
WARNING: vmlinux - Section mismatch: reference to .init.data:initkmem_list3 from .text between 'set_up_list3s' (at offset 0xc0170e0f) and 's_start' 
WARNING: vmlinux - Section mismatch: reference to .init.text:eisa_root_register from .text between 'pci_eisa_init' (at offset 0xc0263ebb) and 'virtual_eisa_release' 
WARNING: vmlinux - Section mismatch: reference to .init.text:eisa_root_register from .text between 'virtual_eisa_root_init' (at offset 0xc0263f1f) and 'cpufreq_unregister_driver' 
WARNING: vmlinux - Section mismatch: reference to .init.text: from .text between 'iret_exc' (at offset 0xc02e8dbb) and '_etext' 
WARNING: vmlinux - Section mismatch: reference to .init.text:start_kernel from .paravirtprobe between '__start_paravirtprobe' (at offset 0xc03b34b0) and '__stop_paravirtprobe' 
make[1]: Leaving directory `/usr/src/linux-2.6.20.15' 

回答

0

我覺得可變中號中缺少您的命令 - 它應該指向路徑模塊的源代碼位於:

make -C path-to-linux-src M=path-to-module-src modules 
+0

我使用SUBDIRS而不是M.我試着用M,但在輸出中我用M代替SUBDIRS得到了相同的結果。 – stedkka 2011-12-15 19:56:39

+0

@stedkka在你的輸出中你沒有賦值給SUBDIR - 它應該是SUBDIR =路徑到你的模塊src – dimba 2011-12-15 20:05:59

2

使用make -C /lib/modules/2.6.20.15-custom/build M=$$PWD$$PWD,也不需要modules)。