开发者

What will happen if two kernel module export same symbol

If two kernel module contain EXPORT_SYMBOL(a), a is defined as: int a, what will happen if two module was inserted? which "a" will b开发者_运维问答e used?


You can't insert duplicate symbols into the kernel. Example:

The xor module loaded in my kernel

nwatkins@kyoto:~$ lsmod | grep xor
xor                     4685  1 async_xor

The exported xor_blocks symbol in the xor module

nwatkins@kyoto:~$ nm /lib/modules/2.6.32-24-generic/kernel/crypto/xor.ko  | grep xor_blocks
0000000000000000 r __kcrctab_xor_blocks
0000000000000000 r __kstrtab_xor_blocks
0000000000000000 r __ksymtab_xor_blocks
0000000000000bb0 T xor_blocks

Another exported xor_blocks symbol in a module I created

nwatkins@kyoto:~$ nm mod-t1.ko  | grep xor
0000000000000000 r __kcrctab_xor_blocks
0000000000000000 r __kstrtab_xor_blocks
0000000000000000 r __ksymtab_xor_blocks
0000000000000000 T xor_blocks

Error reported from insmod

nwatkins@kyoto:~$ sudo insmod mod-t1.ko 
insmod: error inserting 'mod-t1.ko': -1 Invalid module format

Duplicate error message from dmesg

[422002.174033] mod_t1: exports duplicate symbol xor_blocks (owned by xor)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜