1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __ASM_GENERIC_EXPORT_H
3 #define __ASM_GENERIC_EXPORT_H
6 * This comment block is used by fixdep. Please do not remove.
8 * When CONFIG_MODVERSIONS is changed from n to y, all source files having
9 * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
10 * side effect of the *.o build rule.
14 #define KSYM_FUNC(x) x
16 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
18 #elif defined(CONFIG_64BIT)
24 .macro __put, val, name
25 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
26 .long \val - ., \name - ., 0
27 #elif defined(CONFIG_64BIT)
35 * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
36 * section flag requires it. Use '%progbits' instead of '@progbits' since the
37 * former apparently works on all arches according to the binutils source.
40 .macro ___EXPORT_SYMBOL name,val,sec
41 #if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS)
42 .section ___ksymtab\sec+\name,"a"
45 __put \val, __kstrtab_\name
47 .section __ksymtab_strings,"aMS",%progbits,1
54 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
56 #include <linux/kconfig.h>
57 #include <generated/autoksyms.h>
59 .macro __ksym_marker sym
60 .section ".discard.ksym","a"
65 #define __EXPORT_SYMBOL(sym, val, sec) \
67 __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
68 #define __cond_export_sym(sym, val, sec, conf) \
69 ___cond_export_sym(sym, val, sec, conf)
70 #define ___cond_export_sym(sym, val, sec, enabled) \
71 __cond_export_sym_##enabled(sym, val, sec)
72 #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
73 #define __cond_export_sym_0(sym, val, sec) /* nothing */
76 #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
79 #define EXPORT_SYMBOL(name) \
80 __EXPORT_SYMBOL(name, KSYM_FUNC(name),)
81 #define EXPORT_SYMBOL_GPL(name) \
82 __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
83 #define EXPORT_DATA_SYMBOL(name) \
84 __EXPORT_SYMBOL(name, name,)
85 #define EXPORT_DATA_SYMBOL_GPL(name) \
86 __EXPORT_SYMBOL(name, name,_gpl)