[ 리눅스 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

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

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.