========================================================== ====
Author: yuanlulu
Http://blog.csdn.net/yuanlulu
No copyright, but please keep this statement for reprinting
========================================================== ====
I wrote a driver. It took a long time to get it done because it was dependent on the symbol exported by another module. Let's summarize my practices.
For ease of expression, I call the depended module Module B, and my own module is module.
Step 1:
Export the symbols to be used in the dependent Module B, such:
Int cat9555_state_get_indium (void)
{
................
}
Export_symbol (cat9555_state_get_indium );
Step 2:
Compile Module B, generate the module. symvers file under the current directory, and copy it to the directory of module.
Open Module. symvers and you will see the following content:
0x3c1007e5 cat9555_add_opt_addr/home/project/meterread/gpio export_symbol
0x20473c2b cat9555_state_get_indium/home/project/meterread/gpio export_symbol
0x3cc81287 cat9555_del_opt_addr/home/project/meterread/gpio export_symbol
0x68be5229 cat9555_release_addr/home/project/meterread/gpio export_symbol
0x743cae4d cat9555_state_as_gpo/home/project/meterread/gpio export_symbol
0x9c89640e cat9555_state_as_gpi/home/project/meterread/gpio export_symbol
0x977f0740 cat9555_open_addr/home/project/meterread/gpio export_symbol
0xf9713bbb cat9555_state_get_outp/home/project/meterread/gpio export_symbol
0x28d7d46f cat9555_state_set_outp/home/project/meterread/gpio export_symbol
This is the file that records the exported symbols.
Step 3:
Reference the exported symbol in the file of module.
Extern
Cat9555_state_get_indium (void); // declare that the referenced symbol is an external variable.
Int F (){
................
Cat9555_state_get_indium (); // reference the exported symbol here
................
}
Compile module.
If I do not have step 2, the following error occurs when I insert module A (the symbol cannot be found ):
Gwsiodrv: No symbol version for cat9555_state_get_indium
Gwsiodrv: Unknown symbol cat9555_state_get_indium
Gwsiodrv: No symbol version for cat9555_state_as_gpi
Gwsiodrv: Unknown symbol cat9555_state_as_gpi
Insmod: cannot insert 'gwsiodrv. Ko ': Unknown symbol in Module
However, some people do not need to use step 2 to guess that it is related to the compiler.