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