I write a linux-kernel module, but when I run this command insmod ./...ko
, the kernel posts an error: Undefined symbol ...
After that, I searched for a long time, all the solutions are to use EXPORT_SYMBOL()
, so I write it in kernel codes and rebuild the kernel. Interesting things happen, the kernel says exports duplicate symbol ... (owned by kernel)
. It seems that the symbol is exported more than once, but if so, why can I not use it before?
This is related code in my module:
extern struct task_struct *find_task_by_vpid(pid_t nr);
target_tsk = pid == -1 ? current : find_task_by_vpid(pid);
and I changed the kernel file linux/sched.h
to this format:
extern struct task_struct *find_task_by_vpid(pid_t nr);
EXPORT_SYMBOL_GPL(find_task_by_vpid);
Symbol exporting ( EXPORT_SYMBOL
) should be performed in a source file ( .c
), not in a header file ( .h
).
This is because exporting symbol is a definition of (some other) symbol, and header files a not suitable for such things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.