Merge tag 'for-v6.6-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux...
[platform/kernel/linux-starfive.git] / include / linux / export-internal.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Please do not include this explicitly.
4  * This is used by C files generated by modpost.
5  */
6
7 #ifndef __LINUX_EXPORT_INTERNAL_H__
8 #define __LINUX_EXPORT_INTERNAL_H__
9
10 #include <linux/compiler.h>
11 #include <linux/types.h>
12
13 #if defined(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)
14 /*
15  * relative reference: this reduces the size by half on 64-bit architectures,
16  * and eliminates the need for absolute relocations that require runtime
17  * processing on relocatable kernels.
18  */
19 #define __KSYM_REF(sym)         ".long " #sym "- ."
20 #elif defined(CONFIG_64BIT)
21 #define __KSYM_REF(sym)         ".quad " #sym
22 #else
23 #define __KSYM_REF(sym)         ".long " #sym
24 #endif
25
26 /*
27  * For every exported symbol, do the following:
28  *
29  * - Put the name of the symbol and namespace (empty string "" for none) in
30  *   __ksymtab_strings.
31  * - Place a struct kernel_symbol entry in the __ksymtab section.
32  *
33  * Note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
34  * section flag requires it. Use '%progbits' instead of '@progbits' since the
35  * former apparently works on all arches according to the binutils source.
36  */
37 #define __KSYMTAB(name, sym, sec, ns)                                           \
38         asm("   .section \"__ksymtab_strings\",\"aMS\",%progbits,1"     "\n"    \
39             "__kstrtab_" #name ":"                                      "\n"    \
40             "   .asciz \"" #name "\""                                   "\n"    \
41             "__kstrtabns_" #name ":"                                    "\n"    \
42             "   .asciz \"" ns "\""                                      "\n"    \
43             "   .previous"                                              "\n"    \
44             "   .section \"___ksymtab" sec "+" #name "\", \"a\""        "\n"    \
45             "   .balign 4"                                              "\n"    \
46             "__ksymtab_" #name ":"                                      "\n"    \
47                 __KSYM_REF(sym)                                         "\n"    \
48                 __KSYM_REF(__kstrtab_ ##name)                           "\n"    \
49                 __KSYM_REF(__kstrtabns_ ##name)                         "\n"    \
50             "   .previous"                                              "\n"    \
51         )
52
53 #ifdef CONFIG_IA64
54 #define KSYM_FUNC(name)         @fptr(name)
55 #elif defined(CONFIG_PARISC) && defined(CONFIG_64BIT)
56 #define KSYM_FUNC(name)         P%name
57 #else
58 #define KSYM_FUNC(name)         name
59 #endif
60
61 #define KSYMTAB_FUNC(name, sec, ns)     __KSYMTAB(name, KSYM_FUNC(name), sec, ns)
62 #define KSYMTAB_DATA(name, sec, ns)     __KSYMTAB(name, name, sec, ns)
63
64 #define SYMBOL_CRC(sym, crc, sec)   \
65         asm(".section \"___kcrctab" sec "+" #sym "\",\"a\""     "\n" \
66             "__crc_" #sym ":"                                   "\n" \
67             ".long " #crc                                       "\n" \
68             ".previous"                                         "\n")
69
70 #endif /* __LINUX_EXPORT_INTERNAL_H__ */