안드로이드 커널 모듈 작업 중 다음의
글쓴이: ybn100 / 작성시간: 월, 2015/06/22 - 2:19오후
갤럭시 S3, 안드로이드 커널에 모듈을 로드하기 위해
현재 갤럭시S3의 커널버전 및 빌드버전과 동일한 커널 소스를 삼성 오픈소스 홈페이지에서 다운받아
빌드를 진행하였습니다.
커널 모듈 컴파일에는 문제가 없었으며, 루팅된 단말기에 모듈 로드를 시도하였으나
init_module failed 에러가 발생하였고 커널 로그 확인시 다음의 메시지를 출력하고 있었습니다.
unknown symbol __gnu_mcount_nc
소스의 범위를 줄여나가면서 테스트를 해보았는데,
소스내의 넷필터 모듈을 포함 시에 에러메시지가 출력되고 있었습니다.
특히 넷필터 모듈의 핵심인 후킹 함수와 nf_hook_ops 구조체를 선언시 에러가 발생하였고,
소스는 아래와 같은 간단한 넷필터 예제이고 아직 넷필터에 등록 하지도 않은 상황입니다.
#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/netfilter_ipv4.h> #include <linux/netdevice.h> #include <linux/netfilter.h> #include <linux/skbuff.h> static struct nf_hook_ops hook_ops_mclab; static unsigned int func(unsigned int hooknum, struct sk_buff *skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { //printk(KERN_ALERT "[pre routing]"); return 0; } static int __init hello_init(void){ printk(KERN_ALERT " LOADED ============================================================\n\n"); hook_ops_mclab.hook = func; hook_ops_mclab.hooknum = NF_INET_POST_ROUTING; hook_ops_mclab.pf = PF_INET; hook_ops_mclab.priority = NF_IP_PRI_FIRST; printk(KERN_ALERT "hook_ops_mclab"); return 0; } static void __exit hello_exit(void){ printk(KERN_ALERT " UNLOADED ============================================================\n\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("Samsung Proprietary");
어떤 문제로 에러가 발생하였는지 아시는 분 있으신가요?
Forums:
댓글 달기