The difference between the export symbol Export_symbol and EXPORT_SYMBOL_GPL in Linux module __linux

Source: Internet
Author: User

Module Export Symbol
The Linux kernel header file provides a convenient way to manage the visibility of the symbols outside of the module, thereby reducing the pollution of the namespace (the name of the namespace may conflict with the name defined elsewhere in the kernel), and the appropriate information is hidden. If your module requires output symbols to be used by other modules, you should use the following macro definition:
Export_symbol (name);
EXPORT_SYMBOL_GPL (name);
Both macros are used to export the given symbol outside the module. The _GPL version of the macro definition only makes the symbol available to the GPL-licensed module. The symbols must be exported in the global part of the module file and cannot be exported in the function, because these two macros will be extended to a special purpose declaration, and the variable must be global. This variable is stored in a special executable section of the module (an "elf segment"), where the kernel uses this segment to look for variables exported by the module (interested readers can see <linux/module.h> get more detailed information).

In layman's terms: If your module's protocol is not the GPL, then EXPORT_SYMBOL_GPL the symbols you are exporting, you can't use them.

Transfer from embedded Learning network.
Original address: http://www.embedstudy.com/viewnews-8459

In the Linux/module.h

/* For every exported symbol, place a struct under __ksymtab section * *
#define __export_symbol (sym, sec) \
extern typeof (Sym) sym; \
__crc_symbol (sym, sec) \
static const char __kstrtab_# #sym [] \
__attribute__ ((Section ("__ksymtab_strings"), aligned (1)) \
= Module_symbol_prefix #sym; \
static const struct Kernel_symbol __ksymtab_# #sym \
__used \
__attribute__ ((Section ("__ksymtab" sec), unused) \
= {(unsigned long) &sym, __kstrtab_# #sym}

#define EXPORT_SYMBOL (SYM) \
__export_symbol (Sym, "")

#define EXPORT_SYMBOL_GPL (SYM) \
__export_symbol (Sym, "_GPL")

#define EXPORT_SYMBOL_GPL_FUTURE (SYM) \
__export_symbol (Sym, "_gpl_future")

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.