커널 모듈 작성시 외부 함수 정의

stingray의 이미지

제목이 좀 이상하게 되었는데요..-_-;;
커널 모듈(드라이버)를 작성하는데 한개의 파일에 작성하려니 너무 장황하여 여러개의
파일로 나누어 한개의 모듈을 생성하려고 합니다.
컴파일은 아래와 같이 하면 잘 되는데요..

obj-m += test.o
test.objs := test1.o test2.o test3.o

//////////////////////////////////

test1.c에 test_init() 함수가 정의되어 있고, test.c에서 test_init()을 호출합니다.
문제는 insmod를 하여 커널에 올리면
test: Unknown symbol test_init 하고 test1.c에 정의된 함수 에러가 납니다.
여기저기 찾아본 결과 커널 모듈에서 호출하는 함수는 커널이 외부로 공개한 함수 뿐이라고
LDD 3판 책에 나와있는데요..
그럼 원칙적으로 위처럼 호출이 불가능한건가요?

아시는 분께서 설명좀 해주시면 무지 감사하겠습니다. ^^;

익명사용자의 이미지

제가 보기에는 test1.c, test2.c, test3.c가 각각 드라이버 오브젝트로 컴파일된 것 같네요.

임시 변통으로 쓸 수 있는 방법으로는 test.c에서

#include "test1.c"
#include "test2.c"
#include "test3.c"

이렇게 include 시켜주는 방법도 나름 쓸만합니다. (...)

stingray의 이미지

test: Unknown symbol puts

puts는 사용한적이 없는데...

나는 너에게 너는 나에게
잊혀지지 않는 하나의 의미가 되고 싶다.

익명사용자의 이미지

logging용 매크로 종류를 사용하고 있지 않은지 확인해 보시기 바랍니다.
linker error가 나온다는 것은 해당 함수를 호출하고 있음을 의미합니다.

freemckang의 이미지

EXPORT_SYMBOL 매크로를 사용하지 않고 해결할 수 있는 방법을 찾으시는건가요??

句日新, 日新 日新 又日新.

句日新, 日新 日新 又日新.

stingray의 이미지

kernel의 document를 잘 읽어보라는 말은 언제나 바이블이군요..ㅡㅡ;;

obj-m += test.o <-이 녀석은 소스가 아닙니다. 그냥 이름만 주라고 나와있음..
test.objs := test1.o test2.o test3.o <- 사용되어지는 소스입니다.

결국 test.ko는 test.c를 이용하는게 아니라 test1.c test2.c test3.c를 이용하여 만든다는 의미입니다.

너무해...흑..

나는 너에게 너는 나에게
잊혀지지 않는 하나의 의미가 되고 싶다.

stingray의 이미지

obj-m += test.o - 이 녀석은 소스가 아닙니다. 그냥 이름만 주라고 나와있음..
test.objs := test1.o test2.o test3.o - 사용되어지는 소스입니다.

결국 test.ko는 test.c를 이용하는게 아니라 test1.c test2.c test3.c를 이용하여 만든다는 의미입니다.

너무해...흑..

< - 도 너무하는군요..ㅡㅡ;;

나는 너에게 너는 나에게
잊혀지지 않는 하나의 의미가 되고 싶다.

댓글 달기

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