0001
0002 #ifndef __ASM_GENERIC_EXPORT_H
0003 #define __ASM_GENERIC_EXPORT_H
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef KSYM_FUNC
0014 #define KSYM_FUNC(x) x
0015 #endif
0016 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
0017 #define KSYM_ALIGN 4
0018 #elif defined(CONFIG_64BIT)
0019 #define KSYM_ALIGN 8
0020 #else
0021 #define KSYM_ALIGN 4
0022 #endif
0023
0024 .macro __put, val, name
0025 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
0026 .long \val - ., \name - ., 0
0027 #elif defined(CONFIG_64BIT)
0028 .quad \val, \name, 0
0029 #else
0030 .long \val, \name, 0
0031 #endif
0032 .endm
0033
0034
0035
0036
0037
0038
0039
0040 .macro ___EXPORT_SYMBOL name,val,sec
0041 #if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS)
0042 .section ___ksymtab\sec+\name,"a"
0043 .balign KSYM_ALIGN
0044 __ksymtab_\name:
0045 __put \val, __kstrtab_\name
0046 .previous
0047 .section __ksymtab_strings,"aMS",%progbits,1
0048 __kstrtab_\name:
0049 .asciz "\name"
0050 .previous
0051 #endif
0052 .endm
0053
0054 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
0055
0056 #include <linux/kconfig.h>
0057 #include <generated/autoksyms.h>
0058
0059 .macro __ksym_marker sym
0060 .section ".discard.ksym","a"
0061 __ksym_marker_\sym:
0062 .previous
0063 .endm
0064
0065 #define __EXPORT_SYMBOL(sym, val, sec) \
0066 __ksym_marker sym; \
0067 __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
0068 #define __cond_export_sym(sym, val, sec, conf) \
0069 ___cond_export_sym(sym, val, sec, conf)
0070 #define ___cond_export_sym(sym, val, sec, enabled) \
0071 __cond_export_sym_##enabled(sym, val, sec)
0072 #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
0073 #define __cond_export_sym_0(sym, val, sec)
0074
0075 #else
0076 #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
0077 #endif
0078
0079 #define EXPORT_SYMBOL(name) \
0080 __EXPORT_SYMBOL(name, KSYM_FUNC(name),)
0081 #define EXPORT_SYMBOL_GPL(name) \
0082 __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
0083 #define EXPORT_DATA_SYMBOL(name) \
0084 __EXPORT_SYMBOL(name, name,)
0085 #define EXPORT_DATA_SYMBOL_GPL(name) \
0086 __EXPORT_SYMBOL(name, name,_gpl)
0087
0088 #endif