[ 리눅스 2.6 ] extended module 문제

hie의 이미지

안녕하세요. 최근 2.6 커널에 extended module을 학습을
하고 있는데.. 첨부터 난관에...
저와 같은 문제를 많은 사람들이 겪은 것 같은데.. 그런데
아직 명쾌한 답변을 찾지 못해 이렇게 글을 올립니다.

# ls -al
total 20
drwxr-xr-x   2 root root 4096 2005-09-25 19:04 .
drwxr-xr-x  24 root root 4096 2005-09-23 11:21 ..
-rw-r--r--   1 root root  285 2005-09-25 18:56 hello_module.c
-rw-r--r--   1 root root 1632 2005-09-25 16:37 kernel-driver-2.6.tar.tar
-rw-r--r--   1 root root  232 2005-09-25 19:02 Makefile

# ls -al /lib/modules/2.6.12
total 564
drwxr-xr-x  3 root root   4096 2005-08-01 01:30 .
drwxr-xr-x  6 root root   4096 2005-09-25 18:12 ..
lrwxrwxrwx  1 root root     21 2005-08-04 17:58 build -> /usr/src/linux-2.6.12
drwxr-xr-x  9 root root   4096 2005-08-01 01:30 kernel
-rw-r--r--  1 root root 116373 2005-08-01 01:30 modules.alias
-rw-r--r--  1 root root     69 2005-08-01 01:30 modules.ccwmap
-rw-r--r--  1 root root  72191 2005-08-01 01:30 modules.dep
-rw-r--r--  1 root root    813 2005-08-01 01:30 modules.ieee1394map
-rw-r--r--  1 root root    132 2005-08-01 01:30 modules.inputmap
-rw-r--r--  1 root root   1852 2005-08-01 01:30 modules.isapnpmap
-rw-r--r--  1 root root  84820 2005-08-01 01:30 modules.pcimap
-rw-r--r--  1 root root  49137 2005-08-07 03:34 modules.symbols
-rw-r--r--  1 root root 204538 2005-08-01 01:30 modules.usbmap
lrwxrwxrwx  1 root root     21 2005-08-04 17:58 source -> /usr/src/linux-2.6.12

컴파일을 하였습니다.

# make
make -C /lib/modules/2.6.12/build -I/lib/modules/2.6.12/build/include SUBDIRS=/my_test modules
make[1]: Entering directory `/usr/src/linux-2.6.12'
  CC [M]  /my_test/hello_module.o
/my_test/hello_module.c:5: warning: function declaration isn't a prototype
/my_test/hello_module.c:11: warning: function declaration isn't a prototype
  Building modules, stage 2.
  MODPOST
  CC      /my_test/hello_module.mod.o
  LD [M]  /my_test/hello_module.ko
make[1]: Leaving directory `/usr/src/linux-2.6.12'

컴파일이 잘 끝났네요..

# ls -al
total 60
drwxr-xr-x   3 root root 4096 2005-09-25 19:05 .
drwxr-xr-x  24 root root 4096 2005-09-23 11:21 ..
-rw-r--r--   1 root root  285 2005-09-25 18:56 hello_module.c
-rw-r--r--   1 root root 2359 2005-09-25 19:05 hello_module.ko
-rw-r--r--   1 root root  130 2005-09-25 19:05 .hello_module.ko.cmd
-rw-r--r--   1 root root  632 2005-09-25 19:05 hello_module.mod.c
-rw-r--r--   1 root root 1828 2005-09-25 19:05 hello_module.mod.o
-rw-r--r--   1 root root 7869 2005-09-25 19:05 .hello_module.mod.o.cmd
-rw-r--r--   1 root root 1120 2005-09-25 19:05 hello_module.o
-rw-r--r--   1 root root 7780 2005-09-25 19:05 .hello_module.o.cmd
-rw-r--r--   1 root root 1632 2005-09-25 16:37 kernel-driver-2.6.tar.tar
-rw-r--r--   1 root root  232 2005-09-25 19:02 Makefile
drwxr-xr-x   2 root root 4096 2005-09-25 19:05 .tmp_versions

참고로 제가 사용한 insmod 버젼은..

# insmod --version
module-init-tools version 3.2-pre1

# uname -r
2.6.12

# modinfo hello_module.ko
filename:       hello_module.ko
license:        Dual BSD/GPL
vermagic:       2.6.12 preempt 586 gcc-3.3
depends:

그런데 모듈 삽입시 다음과 같은 에러가.. ㅡ.ㅡ;;

# insmod hello_module.ko
insmod: error inserting 'hello_module.ko': -1 Invalid module format

# dmesg
hello_module: disagrees about version of symbol struct_module

사용한 코드 및 Makefile은 다음과 같습니다.

# cat hello_module.c
#include <linux/kernel.h>
#include <linux/module.h>

static int hello_init()
{
    printk("Hello Module! I'm in Kernel\n");
    return 0;
}

static void hello_exit()
{
    printk("Bye Module!!\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("Dual BSD/GPL");

# cat Makefile

ifneq (${KERNELRELEASE},)

obj-m   := hello_module.o

else

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

default:
        $(MAKE) -C $(KDIR) -I$(KDIR)/include SUBDIRS=$(PWD) modules

clean:
        rm -rf *.ko
        rm -rf *.mod.*
        rm -rf .*.cmd
        rm -rf *.o

endif

제가 무엇을 착각하고 있는 것일까요??
고수님들의 고견 부탁드립니다.