xref: /openbmc/linux/include/asm-generic/export.h (revision bbda5ec671d3fe62faefa1cab7270aa586042a4b)
122823ab4SAl Viro #ifndef __ASM_GENERIC_EXPORT_H
222823ab4SAl Viro #define __ASM_GENERIC_EXPORT_H
322823ab4SAl Viro 
422823ab4SAl Viro #ifndef KSYM_FUNC
522823ab4SAl Viro #define KSYM_FUNC(x) x
622823ab4SAl Viro #endif
722823ab4SAl Viro #ifdef CONFIG_64BIT
822823ab4SAl Viro #ifndef KSYM_ALIGN
922823ab4SAl Viro #define KSYM_ALIGN 8
1022823ab4SAl Viro #endif
1122823ab4SAl Viro #else
1222823ab4SAl Viro #ifndef KSYM_ALIGN
1322823ab4SAl Viro #define KSYM_ALIGN 4
1422823ab4SAl Viro #endif
1571810db2SArd Biesheuvel #endif
1622823ab4SAl Viro #ifndef KCRC_ALIGN
1722823ab4SAl Viro #define KCRC_ALIGN 4
1822823ab4SAl Viro #endif
1922823ab4SAl Viro 
207290d580SArd Biesheuvel .macro __put, val, name
217290d580SArd Biesheuvel #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
227290d580SArd Biesheuvel 	.long	\val - ., \name - .
237290d580SArd Biesheuvel #elif defined(CONFIG_64BIT)
247290d580SArd Biesheuvel 	.quad	\val, \name
257290d580SArd Biesheuvel #else
267290d580SArd Biesheuvel 	.long	\val, \name
277290d580SArd Biesheuvel #endif
287290d580SArd Biesheuvel .endm
297290d580SArd Biesheuvel 
3022823ab4SAl Viro /*
3122823ab4SAl Viro  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
3222823ab4SAl Viro  * since we immediately emit into those sections anyway.
3322823ab4SAl Viro  */
3422823ab4SAl Viro .macro ___EXPORT_SYMBOL name,val,sec
3522823ab4SAl Viro #ifdef CONFIG_MODULES
3694e58e0aSMasahiro Yamada 	.globl __ksymtab_\name
3722823ab4SAl Viro 	.section ___ksymtab\sec+\name,"a"
3822823ab4SAl Viro 	.balign KSYM_ALIGN
3994e58e0aSMasahiro Yamada __ksymtab_\name:
4094e58e0aSMasahiro Yamada 	__put \val, __kstrtab_\name
4122823ab4SAl Viro 	.previous
4222823ab4SAl Viro 	.section __ksymtab_strings,"a"
4394e58e0aSMasahiro Yamada __kstrtab_\name:
4422823ab4SAl Viro 	.asciz "\name"
4522823ab4SAl Viro 	.previous
4622823ab4SAl Viro #ifdef CONFIG_MODVERSIONS
4722823ab4SAl Viro 	.section ___kcrctab\sec+\name,"a"
4822823ab4SAl Viro 	.balign KCRC_ALIGN
4994e58e0aSMasahiro Yamada __kcrctab_\name:
5071810db2SArd Biesheuvel #if defined(CONFIG_MODULE_REL_CRCS)
5194e58e0aSMasahiro Yamada 	.long __crc_\name - .
5271810db2SArd Biesheuvel #else
5394e58e0aSMasahiro Yamada 	.long __crc_\name
5471810db2SArd Biesheuvel #endif
5594e58e0aSMasahiro Yamada 	.weak __crc_\name
5622823ab4SAl Viro 	.previous
5722823ab4SAl Viro #endif
5822823ab4SAl Viro #endif
5922823ab4SAl Viro .endm
6022823ab4SAl Viro #undef __put
6122823ab4SAl Viro 
62*bbda5ec6SMasahiro Yamada #if defined(CONFIG_TRIM_UNUSED_KSYMS)
6322823ab4SAl Viro 
6422823ab4SAl Viro #include <linux/kconfig.h>
6522823ab4SAl Viro #include <generated/autoksyms.h>
6622823ab4SAl Viro 
67*bbda5ec6SMasahiro Yamada .macro __ksym_marker sym
68*bbda5ec6SMasahiro Yamada 	.section ".discard.ksym","a"
69*bbda5ec6SMasahiro Yamada __ksym_marker_\sym:
70*bbda5ec6SMasahiro Yamada 	 .previous
71*bbda5ec6SMasahiro Yamada .endm
72*bbda5ec6SMasahiro Yamada 
7322823ab4SAl Viro #define __EXPORT_SYMBOL(sym, val, sec)				\
74*bbda5ec6SMasahiro Yamada 	__ksym_marker sym;					\
75c0a0aba8SMasahiro Yamada 	__cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
7622823ab4SAl Viro #define __cond_export_sym(sym, val, sec, conf)			\
7722823ab4SAl Viro 	___cond_export_sym(sym, val, sec, conf)
7822823ab4SAl Viro #define ___cond_export_sym(sym, val, sec, enabled)		\
7922823ab4SAl Viro 	__cond_export_sym_##enabled(sym, val, sec)
8022823ab4SAl Viro #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
8122823ab4SAl Viro #define __cond_export_sym_0(sym, val, sec) /* nothing */
8222823ab4SAl Viro 
8322823ab4SAl Viro #else
8422823ab4SAl Viro #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
8522823ab4SAl Viro #endif
8622823ab4SAl Viro 
8722823ab4SAl Viro #define EXPORT_SYMBOL(name)					\
8894e58e0aSMasahiro Yamada 	__EXPORT_SYMBOL(name, KSYM_FUNC(name),)
8922823ab4SAl Viro #define EXPORT_SYMBOL_GPL(name) 				\
9094e58e0aSMasahiro Yamada 	__EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
9122823ab4SAl Viro #define EXPORT_DATA_SYMBOL(name)				\
9294e58e0aSMasahiro Yamada 	__EXPORT_SYMBOL(name, name,)
9322823ab4SAl Viro #define EXPORT_DATA_SYMBOL_GPL(name)				\
9494e58e0aSMasahiro Yamada 	__EXPORT_SYMBOL(name, name,_gpl)
9522823ab4SAl Viro 
9622823ab4SAl Viro #endif
97