module compile
글쓴이: joyjoj / 작성시간: 화, 2004/06/22 - 4:28오후
module compile을 하려고 하는데요.
hello.c를 다음과 같이 작성했구요.
#include <linux/module.h> #include <linux/tty.h> #include <linux/init.h> #include <linux/kernel.h> int hello_init(void) { printk(KERN_ALERT "HELLO, World\n"); return 0; } void hello_exit(void) { printk(KERN_ALERT "bye bye\n"); } module_init(hello_init); module_exit(hello_exit);
Makefile을 다음과 같이 만들었습니다.
KERNEL_SRC = /usr/src/linux SUBDIR = $(KERNEL_SRC)/net/hello/ all: modules obj-m := module.o hello-objs := hello.o EXTRA_FLAGS += -DDEBUG=1 modules: $(MAKE) -C $(KERNEL_SRC) SUBDIR=$(SUBDIR) modules
커널 버전은 2.6.5이구요. make하면 다음처럼 결과가 나오는데요.
make -C /usr/src/linux-2.6.5 SUBDIR=/usr/src/linux-2.6.5/net/hello/ modules make[1]: Entering directory '/usr/src/linux-2.6.5' CHK include/linux/version.h make[2]: 'arch/i386/kernel/asm-offsets.s' is up to date. CHK include/asm-i386/asm_offsets.h drivers/net/wireless/acx100/Makefile:3: ACX_DEBUG was not defined, assuming 1 Building modules, stage 2. MODPOST make[1]: Leaving directory '/usr/src/linux-2.6.5'
make가 제대로 안된 것 같은데... object 파일이 생성되지 않아서요. 무슨 문제가 있는거죠? compile이 된 다음에 load하려면 insmod명령을 사용하면 되나요? 2.4하고 다른 명령이 생긴것 같기도 하던데...
고수님들의 답을 부탁드립니다.
Forums:
$(KERNEL_SRC)/drivers/char/hello/ 요세
$(KERNEL_SRC)/drivers/char/hello/
요세 2.6에서 모듈 만들일이 없어 기억이 가물가물 하지만.
저 폴더 안에 ko가 생성되지 않았을까 해서요..
(혹시나 아니면...... 윽..=0= )
https://nicesj.com
https://blog.nicesj.com
그 부분은
sub directory로 path를 바꾸어주었습니다. module compile하려는 source가 들어있는 폴더거든요. make 결과는 문제가 없는건가요?
[code:1]sjpark mod2.6 # make -C /usr/s
간단한 코드만들어서 컴파일 해 보았습니다.
(갖은 협박을 다 하고 있는것 같지만..훗.. 다 무시해버렸지요. 훗)
ps. 앞서 포스팅한 제 글은 틀린것으로 ... 되새겼습니당;
https://nicesj.com
https://blog.nicesj.com
[code:1]sjpark mod2.6 # make -C /usr/s
사실 2.6 모듈 컴파일의 가장 기본은
Makefile에
이렇게만 놔두고
make -C (linux 경로) SUBDIR=(모듈.c의 경로) modules
이렇게 실행을 하는겁니다.
위의 makefile은 제가 봤던 문서에도 예제로 나온 코드인데,
makefile을 좀 조작해서 trick을 쓴거구요.
위 경우에는, makefile내에서 SUBDIR과 KERNEL_SRC 경로를
적당히 정해주신 뒤에,
make만 하면, all: 에서 modules:를 부르고 이게
make -C ... SUBDIR=... modules라는 커맨드를 실행시키게 하는거죠.
즉, 위와 같이 makefile을 만드셨으면, 변수 셋팅 하고 "make" 만 치시면 됩니다.
위 경우에는 컴파일은 제대로 된 것으로 보이는데,
make -C .. SUBDIR=... modules 해주셨기 때문에,
makefile내부의 SUBDIR과 충돌이 난 것 같군요.
Easy come, easy go.
댓글 달기