Masahiro Yamada | bf49d9d | 2019-10-18 13:50:53 +0900 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 2 | #ifndef __ASM_GENERIC_EXPORT_H |
| 3 | #define __ASM_GENERIC_EXPORT_H |
| 4 | |
| 5 | #ifndef KSYM_FUNC |
| 6 | #define KSYM_FUNC(x) x |
| 7 | #endif |
Matthias Maennich | ed13fc3 | 2019-09-06 11:32:26 +0100 | [diff] [blame] | 8 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 9 | #define KSYM_ALIGN 4 |
Matthias Maennich | ed13fc3 | 2019-09-06 11:32:26 +0100 | [diff] [blame] | 10 | #elif defined(CONFIG_64BIT) |
| 11 | #define KSYM_ALIGN 8 |
| 12 | #else |
| 13 | #define KSYM_ALIGN 4 |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 14 | #endif |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 15 | #ifndef KCRC_ALIGN |
| 16 | #define KCRC_ALIGN 4 |
| 17 | #endif |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 18 | |
Ard Biesheuvel | 7290d58 | 2018-08-21 21:56:09 -0700 | [diff] [blame] | 19 | .macro __put, val, name |
| 20 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
Will Deacon | 069e1c0 | 2019-09-11 13:26:46 +0100 | [diff] [blame] | 21 | .long \val - ., \name - ., 0 |
Ard Biesheuvel | 7290d58 | 2018-08-21 21:56:09 -0700 | [diff] [blame] | 22 | #elif defined(CONFIG_64BIT) |
Matthias Maennich | 8651ec0 | 2019-09-06 11:32:27 +0100 | [diff] [blame] | 23 | .quad \val, \name, 0 |
Ard Biesheuvel | 7290d58 | 2018-08-21 21:56:09 -0700 | [diff] [blame] | 24 | #else |
Matthias Maennich | 8651ec0 | 2019-09-06 11:32:27 +0100 | [diff] [blame] | 25 | .long \val, \name, 0 |
Ard Biesheuvel | 7290d58 | 2018-08-21 21:56:09 -0700 | [diff] [blame] | 26 | #endif |
| 27 | .endm |
| 28 | |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 29 | /* |
Jessica Yu | ce2b617 | 2019-11-12 12:35:59 +0100 | [diff] [blame] | 30 | * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) |
| 31 | * section flag requires it. Use '%progbits' instead of '@progbits' since the |
| 32 | * former apparently works on all arches according to the binutils source. |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 33 | */ |
Jessica Yu | ce2b617 | 2019-11-12 12:35:59 +0100 | [diff] [blame] | 34 | |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 35 | .macro ___EXPORT_SYMBOL name,val,sec |
Quentin Perret | ae24286 | 2021-02-03 14:19:30 +0000 | [diff] [blame] | 36 | #if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS) |
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 |
Jessica Yu | ce2b617 | 2019-11-12 12:35:59 +0100 | [diff] [blame] | 42 | .section __ksymtab_strings,"aMS",%progbits,1 |
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 |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 49 | #if defined(CONFIG_MODULE_REL_CRCS) |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 50 | .long __crc_\name - . |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 51 | #else |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 52 | .long __crc_\name |
Ard Biesheuvel | 71810db | 2017-02-03 09:54:06 +0000 | [diff] [blame] | 53 | #endif |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 54 | .weak __crc_\name |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 55 | .previous |
| 56 | #endif |
| 57 | #endif |
| 58 | .endm |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 59 | |
Masahiro Yamada | bbda5ec | 2018-11-30 10:05:26 +0900 | [diff] [blame] | 60 | #if defined(CONFIG_TRIM_UNUSED_KSYMS) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 61 | |
| 62 | #include <linux/kconfig.h> |
| 63 | #include <generated/autoksyms.h> |
| 64 | |
Masahiro Yamada | bbda5ec | 2018-11-30 10:05:26 +0900 | [diff] [blame] | 65 | .macro __ksym_marker sym |
| 66 | .section ".discard.ksym","a" |
| 67 | __ksym_marker_\sym: |
| 68 | .previous |
| 69 | .endm |
| 70 | |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 71 | #define __EXPORT_SYMBOL(sym, val, sec) \ |
Masahiro Yamada | bbda5ec | 2018-11-30 10:05:26 +0900 | [diff] [blame] | 72 | __ksym_marker sym; \ |
Masahiro Yamada | c0a0aba | 2016-10-27 17:46:38 -0700 | [diff] [blame] | 73 | __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 74 | #define __cond_export_sym(sym, val, sec, conf) \ |
| 75 | ___cond_export_sym(sym, val, sec, conf) |
| 76 | #define ___cond_export_sym(sym, val, sec, enabled) \ |
| 77 | __cond_export_sym_##enabled(sym, val, sec) |
| 78 | #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec |
| 79 | #define __cond_export_sym_0(sym, val, sec) /* nothing */ |
| 80 | |
| 81 | #else |
| 82 | #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec |
| 83 | #endif |
| 84 | |
| 85 | #define EXPORT_SYMBOL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 86 | __EXPORT_SYMBOL(name, KSYM_FUNC(name),) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 87 | #define EXPORT_SYMBOL_GPL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 88 | __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 89 | #define EXPORT_DATA_SYMBOL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 90 | __EXPORT_SYMBOL(name, name,) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 91 | #define EXPORT_DATA_SYMBOL_GPL(name) \ |
Masahiro Yamada | 94e58e0 | 2018-05-09 16:23:49 +0900 | [diff] [blame] | 92 | __EXPORT_SYMBOL(name, name,_gpl) |
Al Viro | 22823ab | 2016-01-11 10:54:54 -0500 | [diff] [blame] | 93 | |
| 94 | #endif |