Module and variable Export

Source: Internet
Author: User

Today, the infrared module found a strange phenomenon. When we compile the infrared source code in the module mode, we cannot say hkvs_root_dir undefined, but there is no problem in compiling in the build-in mode. At first we couldn't figure it out, I just bought this new book ildd. The first chapter is about the kernel module loading principle. I looked at it and understood that the original kernel build-in can be regarded as a big module, if the infrared module is compiled in build-in mode, it is of course no problem. He can access all global variables in this module. However, when the infrared module is compiled in this module, because hkvs_root_dir is only the global variable of the built-in kernel module, this global variable does not have an export and cannot be used by other modules, the above problem occurs. If the above conclusion is correct, the same is true for the functions of the build-in module. If you do not need to use the export, you only need to define the function without static. If you need to use the extern statement, you can declare that the kernel is a large module, different drivers are considered to be different modules. The ildd figure above shows the search path of the find_symbol symbol when the module is loaded to know that the kernel is a module, the exported symbols are all placed in the same section. The system suddenly occurred. the map content is indeed like this. The address of the exported symbol is connected. I didn't think about this in map.

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