About the kernel symbol table

Source: Internet
Author: User
         in the process of writing a drive, the Export_symbol macro is used to export the defined function name to the kernel symbol table. It was just simple to know that if a function defined in a module is to be supplied to another module call, it must be exported. This time in the compilation of a single module, because did not compile the success of the function is not defined and alarm the situation, so let me have a chance to the kernel symbol table problem for an in-depth study and understanding. We know that if a module uses a function defined in another module, when compiling the module, it is necessary to print out the warning message, indicating that the function is not defined, of course, this will not affect the driving work, can be ignored, as long as the driver is loaded before the driver will be used to load ahead of the function. I have previously compiled a single source file as a driver module, and this warning has occurred, but I ignored him, because I know in other modules defined. But I now compile the module composed of several source files, and actually this problem, all functions are defined in this module, no use of any other modules of the function, at first, I can not think, then found a reason to convince themselves, I think that all the functions called to get the kernel symbol table to find the corresponding function symbol, can not find the alarm, and I just did not export, the alarm is normal. When I added these export statements, the warning disappeared, also let me vaguely feel that this is the reason, but unfortunately, I can not find any other information available to support my idea, and then found that it is really my problem, guess at all not set up, as to why I call the police, this phenomenon is very strange, is my problem, Does not have the universal significance, does not list, only reminds, notices the multiple source file and the single file drive compile time makefile changes is good. The following is a return to the topic, to explain the kernel symbol table this dongdong, and then you can know my guess the problem is where. What we usually call the kernel notation table is actually a narrow concept, it simply refers to the portion of the kernel symbol table that can be used for all the drive modules, and we know that the driver is in the kernel space, and each of its functions has a corresponding symbol, which can also be called a kernel symbol, They do not lead to only for their own use, after export can become public, for the export of that part of the kernel symbol is what we often say the kernel symbol table. Insmod not all functions get the kernel symbol table to find the corresponding symbol, as mentioned above, each driver in its own allocation of space will also have a symbol table, which has about the driver used in the variables and some symbols of the function, the first driver will be found in here, If you find that a symbol is not here, then you will go to the common kernel symbol table search, the element to, then the module loaded successfully, not search the module load lostDefeat. Here also adds that There is a difference between the kernel symbol tables for the 2.4 kernel and the 2.6 kernel, 2.4 the kernel by default, non-static global variables and non-static functions in the module are automatically exported to the kernel symbol table after the module is loaded, and the 2.6 kernel is not automatically exported by default and requires explicit invocation of the macro Export_ Symbol to export. The exported symbol is generally marked with an R tag before it. You can view the symbols in a particular module by Nm-l Xx.ko. Or it can be done by looking at the kernel symbol table file. For 2.4 is: cat/proc/ksyms, for 2.6 is: cat/proc/ Kallsyms. Finally, to the point of summary, for a module, if only rely on their own to achieve their own functions, then you can not export any symbols, only other modules need to use the function provided by the module, you must export operations.

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.