1 #ifndef __ASM_GENERIC_EXPORT_H 2 #define __ASM_GENERIC_EXPORT_H 3 4 #ifndef KSYM_FUNC 5 #define KSYM_FUNC(x) x 6 #endif 7 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 8 #define KSYM_ALIGN 4 9 #elif defined(CONFIG_64BIT) 10 #define KSYM_ALIGN 8 11 #else 12 #define KSYM_ALIGN 4 13 #endif 14 #ifndef KCRC_ALIGN 15 #define KCRC_ALIGN 4 16 #endif 17 18 .macro __put, val, name 19 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 20 .long \val - ., \name - ., 0 21 #elif defined(CONFIG_64BIT) 22 .quad \val, \name, 0 23 #else 24 .long \val, \name, 0 25 #endif 26 .endm 27 28 /* 29 * note on .section use: @progbits vs %progbits nastiness doesn't matter, 30 * since we immediately emit into those sections anyway. 31 */ 32 .macro ___EXPORT_SYMBOL name,val,sec 33 #ifdef CONFIG_MODULES 34 .section ___ksymtab\sec+\name,"a" 35 .balign KSYM_ALIGN 36 __ksymtab_\name: 37 __put \val, __kstrtab_\name 38 .previous 39 .section __ksymtab_strings,"a" 40 __kstrtab_\name: 41 .asciz "\name" 42 .previous 43 #ifdef CONFIG_MODVERSIONS 44 .section ___kcrctab\sec+\name,"a" 45 .balign KCRC_ALIGN 46 #if defined(CONFIG_MODULE_REL_CRCS) 47 .long __crc_\name - . 48 #else 49 .long __crc_\name 50 #endif 51 .weak __crc_\name 52 .previous 53 #endif 54 #endif 55 .endm 56 57 #if defined(CONFIG_TRIM_UNUSED_KSYMS) 58 59 #include <linux/kconfig.h> 60 #include <generated/autoksyms.h> 61 62 .macro __ksym_marker sym 63 .section ".discard.ksym","a" 64 __ksym_marker_\sym: 65 .previous 66 .endm 67 68 #define __EXPORT_SYMBOL(sym, val, sec) \ 69 __ksym_marker sym; \ 70 __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) 71 #define __cond_export_sym(sym, val, sec, conf) \ 72 ___cond_export_sym(sym, val, sec, conf) 73 #define ___cond_export_sym(sym, val, sec, enabled) \ 74 __cond_export_sym_##enabled(sym, val, sec) 75 #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec 76 #define __cond_export_sym_0(sym, val, sec) /* nothing */ 77 78 #else 79 #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec 80 #endif 81 82 #define EXPORT_SYMBOL(name) \ 83 __EXPORT_SYMBOL(name, KSYM_FUNC(name),) 84 #define EXPORT_SYMBOL_GPL(name) \ 85 __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl) 86 #define EXPORT_DATA_SYMBOL(name) \ 87 __EXPORT_SYMBOL(name, name,) 88 #define EXPORT_DATA_SYMBOL_GPL(name) \ 89 __EXPORT_SYMBOL(name, name,_gpl) 90 91 #endif 92