1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Please do not include this explicitly.
4 * This is used by C files generated by modpost.
7 #ifndef __LINUX_EXPORT_INTERNAL_H__
8 #define __LINUX_EXPORT_INTERNAL_H__
10 #include <linux/compiler.h>
11 #include <linux/types.h>
13 #if defined(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)
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.
19 #define __KSYM_REF(sym) ".long " #sym "- ."
20 #elif defined(CONFIG_64BIT)
21 #define __KSYM_REF(sym) ".quad " #sym
23 #define __KSYM_REF(sym) ".long " #sym
27 * For every exported symbol, do the following:
29 * - Put the name of the symbol and namespace (empty string "" for none) in
31 * - Place a struct kernel_symbol entry in the __ksymtab section.
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.
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" \
44 " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \
46 "__ksymtab_" #name ":" "\n" \
47 __KSYM_REF(sym) "\n" \
48 __KSYM_REF(__kstrtab_ ##name) "\n" \
49 __KSYM_REF(__kstrtabns_ ##name) "\n" \
54 #define KSYM_FUNC(name) @fptr(name)
55 #elif defined(CONFIG_PARISC) && defined(CONFIG_64BIT)
56 #define KSYM_FUNC(name) P%name
58 #define KSYM_FUNC(name) name
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)
64 #define SYMBOL_CRC(sym, crc, sec) \
65 asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \
66 "__crc_" #sym ":" "\n" \
70 #endif /* __LINUX_EXPORT_INTERNAL_H__ */