kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS
[linux-2.6-microblaze.git] / include / asm-generic / export.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __ASM_GENERIC_EXPORT_H
3 #define __ASM_GENERIC_EXPORT_H
4
5 /*
6  * This comment block is used by fixdep. Please do not remove.
7  *
8  * When CONFIG_MODVERSIONS is changed from n to y, all source files having
9  * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
10  * side effect of the *.o build rule.
11  */
12
13 #ifndef KSYM_FUNC
14 #define KSYM_FUNC(x) x
15 #endif
16 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
17 #define KSYM_ALIGN 4
18 #elif defined(CONFIG_64BIT)
19 #define KSYM_ALIGN 8
20 #else
21 #define KSYM_ALIGN 4
22 #endif
23
24 .macro __put, val, name
25 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
26         .long   \val - ., \name - ., 0
27 #elif defined(CONFIG_64BIT)
28         .quad   \val, \name, 0
29 #else
30         .long   \val, \name, 0
31 #endif
32 .endm
33
34 /*
35  * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
36  * section flag requires it. Use '%progbits' instead of '@progbits' since the
37  * former apparently works on all arches according to the binutils source.
38  */
39
40 .macro ___EXPORT_SYMBOL name,val,sec
41 #if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS)
42         .section ___ksymtab\sec+\name,"a"
43         .balign KSYM_ALIGN
44 __ksymtab_\name:
45         __put \val, __kstrtab_\name
46         .previous
47         .section __ksymtab_strings,"aMS",%progbits,1
48 __kstrtab_\name:
49         .asciz "\name"
50         .previous
51 #endif
52 .endm
53
54 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
55
56 #include <linux/kconfig.h>
57 #include <generated/autoksyms.h>
58
59 .macro __ksym_marker sym
60         .section ".discard.ksym","a"
61 __ksym_marker_\sym:
62          .previous
63 .endm
64
65 #define __EXPORT_SYMBOL(sym, val, sec)                          \
66         __ksym_marker sym;                                      \
67         __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
68 #define __cond_export_sym(sym, val, sec, conf)                  \
69         ___cond_export_sym(sym, val, sec, conf)
70 #define ___cond_export_sym(sym, val, sec, enabled)              \
71         __cond_export_sym_##enabled(sym, val, sec)
72 #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
73 #define __cond_export_sym_0(sym, val, sec) /* nothing */
74
75 #else
76 #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
77 #endif
78
79 #define EXPORT_SYMBOL(name)                                     \
80         __EXPORT_SYMBOL(name, KSYM_FUNC(name),)
81 #define EXPORT_SYMBOL_GPL(name)                                 \
82         __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
83 #define EXPORT_DATA_SYMBOL(name)                                \
84         __EXPORT_SYMBOL(name, name,)
85 #define EXPORT_DATA_SYMBOL_GPL(name)                            \
86         __EXPORT_SYMBOL(name, name,_gpl)
87
88 #endif