insmod에서 에러 납니다.

kimtakeun의 이미지

안녕하세요?
모듈 컴파일을 하는데 문제가 생겨 질문 드립니다.
다음과 같은 코드를 모듈 컴파일을 하는데, 컴파일 까지는 잘 됩니다. 그런데 insmod 를 하면 insmod: error inserting 'hello.ko': -1 Invalid module format 과 같은 에러가 뜹니다. /var/log/message 에 보면 Mar 19 02:55:27 tesla kernel: hello: disagrees about version of symbol struct_module 과 같은 메세지가 뜨구요.
저 에러로 검색을 해보니 커널 버젼과 소스 버젼이 틀려서 그렇다고 하던데, 둘 다 2.6.10 커널로 맞춰서 컴파일 했는데도 안되네요. CONFIG_MODULEVERSIONS 인가 no로 설정해주면 된다고 해서 해봤는데도 안되구요. (우분투 5.04 - kernel 2.6.10 사용하고 있습니다.)
답변 부탁드립니다 :)

- hello.c

#include <linux/module.h>
#include <linux/kernel.h>
 
int init_module(void) {
                printk(KERN_INFO "Hello World 1.\n");
                return 0;
}
 
void cleanup_module(void) {
                printk(KERN_INFO "Goodbye 1.\n");
}

- build.sh
make -C /usr/src/kernel-source-2.6.10 SUBDIRS=$PWD modules

- makefile
obj-m := hello.o

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

세이군의 이미지

아마도 커널 모듈에 정의되어 있어야 하는 몇개의 변수들이 정의되지 않아서 그런 것 같습니다. 2.6용 커널 모듈 만드는 방법에 관한 글을 찾아보시고 그런 값들을 정의해 주세요.
------------------
한 걸음 더 가까이

suh1978의 이미지

suki1978 style, free style

2.4.x대의 소스같습니다.

2.4.x 용 모듈 소스는 init_module, cleanup_module처럼 함수명이 정해져 있습니다.

하지만 2.6.x대의 모듈 소스는 init_module, cleanup_module에 해당하는 함수의 이름은 원하는데로 정하데, 매크로 함수를 이용해서 등록해주는 차이가 있을것입니다.

열정은 남자의 미래다! - suki1978 style, free style

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.