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 be used?
Asked
Active
Viewed 7,495 times
8
-
I would hope the compile of the kernel fails with a duplicate error. – stsquad Aug 11 '10 at 11:38
-
You should consider selecting an answer as correct. You know, be a good stackoverflow citizen. – Noah Watkins Aug 23 '10 at 14:40
1 Answers
11
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)

Noah Watkins
- 5,446
- 3
- 34
- 47