Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 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 |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 8 | #ifndef KSYM_ALIGN |
| 9 | #define KSYM_ALIGN 8 |
| 10 | #endif |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 11 | #else |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 12 | #ifndef KSYM_ALIGN |
| 13 | #define KSYM_ALIGN 4 |
| 14 | #endif |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 15 | #endif |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 16 | #ifndef KCRC_ALIGN |
| 17 | #define KCRC_ALIGN 4 |
| 18 | #endif |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 19 | |
Ard Biesheuvel | 7290d58 | 2018-08-21 21:56:09 -0700 | [diff] [blame] | 20 | .macro __put, val, name |
| 21 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
| 22 | .long \val - ., \name - . |
| 23 | #elif defined(CONFIG_64BIT) |
| 24 | .quad \val, \name |
| 25 | #else |
| 26 | .long \val, \name |
| 27 | #endif |
| 28 | .endm |
| 29 | |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 30 | /* |
| 31 | * note on .section use: @progbits vs %progbits nastiness doesn't matter, |
| 32 | * since we immediately emit into those sections anyway. |
| 33 | */ |
| 34 | .macro ___EXPORT_SYMBOL name,val,sec |
| 35 | #ifdef CONFIG_MODULES |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 36 | .globl __ksymtab_\name |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 37 | .section ___ksymtab\sec+\name,"a" |
| 38 | .balign KSYM_ALIGN |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 39 | __ksymtab_\name: |
| 40 | __put \val, __kstrtab_\name |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 41 | .previous |
| 42 | .section __ksymtab_strings,"a" |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 43 | __kstrtab_\name: |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 44 | .asciz "\name" |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 45 | .previous |
| 46 | #ifdef CONFIG_MODVERSIONS |
| 47 | .section ___kcrctab\sec+\name,"a" |
| 48 | .balign KCRC_ALIGN |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 49 | __kcrctab_\name: |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 50 | #if defined(CONFIG_MODULE_REL_CRCS) |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 51 | .long __crc_\name - . |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 52 | #else |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 53 | .long __crc_\name |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 54 | #endif |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 55 | .weak __crc_\name |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 56 | .previous |
| 57 | #endif |
| 58 | #endif |
| 59 | .endm |
| 60 | #undef __put |
| 61 | |
| 62 | #if defined(__KSYM_DEPS__) |
| 63 | |
| 64 | #define __EXPORT_SYMBOL(sym, val, sec) === __KSYM_##sym === |
| 65 | |
| 66 | #elif defined(CONFIG_TRIM_UNUSED_KSYMS) |
| 67 | |
| 68 | #include <linux/kconfig.h> |
| 69 | #include <generated/autoksyms.h> |
| 70 | |
| 71 | #define __EXPORT_SYMBOL(sym, val, sec) \ |
Masahiro Yamada | c0a0aba | 2016-10-27 17:46:38 -0700 | [diff] [blame] | 72 | __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 73 | #define __cond_export_sym(sym, val, sec, conf) \ |
| 74 | ___cond_export_sym(sym, val, sec, conf) |
| 75 | #define ___cond_export_sym(sym, val, sec, enabled) \ |
| 76 | __cond_export_sym_##enabled(sym, val, sec) |
| 77 | #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec |
| 78 | #define __cond_export_sym_0(sym, val, sec) /* nothing */ |
| 79 | |
| 80 | #else |
| 81 | #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec |
| 82 | #endif |
| 83 | |
| 84 | #define EXPORT_SYMBOL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 85 | __EXPORT_SYMBOL(name, KSYM_FUNC(name),) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 86 | #define EXPORT_SYMBOL_GPL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 87 | __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 88 | #define EXPORT_DATA_SYMBOL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 89 | __EXPORT_SYMBOL(name, name,) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 90 | #define EXPORT_DATA_SYMBOL_GPL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 91 | __EXPORT_SYMBOL(name, name,_gpl) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 92 | |
| 93 | #endif |