Kernel - loadable module 작성하기
external loadable module 작성하기
기본 소스코드
- example_module.c
#include <linux/init.h>
#include <linux/module.h>
int example_init(void)
{
return 0;
{
void example_exit(void)
{
}
module_init(example_init);
module_exit(example_exit);
- Makefile
obj-m := example_module.o
obj-m := <module_name>.o
The kbuild system will build <module_name>.o from <module_name>.c
<module_name>-y := <src1>.o <src2>.o ...
When the module is built from multiple sources, an additional line is needed listing the files:
만약 여러 소스코드를 같이 빌드해야한다면
obj-m := example_module.o
example_module-y := additional_src1.o additional_src2.o
빌드
- build using Kbuild
$ make -C <path_to_kernel_src> M=$PWD <target>
빌드할때 커널 소스코드가 필요(-C옵션), M는 생성되는 module 위치
마지막 에 modules를 넣으면 됨 (자세한 내용은 아래 2.3 Targets 확인)
https://www.kernel.org/doc/html/latest/kbuild/modules.html
Load 모듈
$
docs
https://www.kernel.org/doc/html/latest/kbuild/modules.html
Author And Source
이 문제에 관하여(Kernel - loadable module 작성하기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@soopsaram/Kernel-loadable-module-작성하기저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)