Use Symbols exported from other modules in the Linux driver

Source: Internet
Author: User

========================================================== ====
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.