Merge tag 'nfs-for-6.12-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
[linux-block.git] / include / linux / export-internal.h
CommitLineData
7b453719
MY
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
ddb5cdba
MY
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 */
f6847807 19#define __KSYM_ALIGN ".balign 4"
ddb5cdba
MY
20#define __KSYM_REF(sym) ".long " #sym "- ."
21#elif defined(CONFIG_64BIT)
f6847807 22#define __KSYM_ALIGN ".balign 8"
ddb5cdba
MY
23#define __KSYM_REF(sym) ".quad " #sym
24#else
f6847807 25#define __KSYM_ALIGN ".balign 4"
ddb5cdba
MY
26#define __KSYM_REF(sym) ".long " #sym
27#endif
28
29/*
30 * For every exported symbol, do the following:
31 *
32 * - Put the name of the symbol and namespace (empty string "" for none) in
33 * __ksymtab_strings.
34 * - Place a struct kernel_symbol entry in the __ksymtab section.
35 *
36 * Note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
37 * section flag requires it. Use '%progbits' instead of '@progbits' since the
38 * former apparently works on all arches according to the binutils source.
39 */
40#define __KSYMTAB(name, sym, sec, ns) \
41 asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1" "\n" \
42 "__kstrtab_" #name ":" "\n" \
43 " .asciz \"" #name "\"" "\n" \
44 "__kstrtabns_" #name ":" "\n" \
45 " .asciz \"" ns "\"" "\n" \
46 " .previous" "\n" \
47 " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \
f6847807 48 __KSYM_ALIGN "\n" \
ddb5cdba
MY
49 "__ksymtab_" #name ":" "\n" \
50 __KSYM_REF(sym) "\n" \
51 __KSYM_REF(__kstrtab_ ##name) "\n" \
52 __KSYM_REF(__kstrtabns_ ##name) "\n" \
53 " .previous" "\n" \
54 )
55
9e0be3f5 56#if defined(CONFIG_PARISC) && defined(CONFIG_64BIT)
08700ec7 57#define KSYM_FUNC(name) P%name
ddb5cdba
MY
58#else
59#define KSYM_FUNC(name) name
60#endif
61
62#define KSYMTAB_FUNC(name, sec, ns) __KSYMTAB(name, KSYM_FUNC(name), sec, ns)
63#define KSYMTAB_DATA(name, sec, ns) __KSYMTAB(name, name, sec, ns)
64
7b453719 65#define SYMBOL_CRC(sym, crc, sec) \
f3304ecd 66 asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \
753547de 67 ".balign 4" "\n" \
f3304ecd
MY
68 "__crc_" #sym ":" "\n" \
69 ".long " #crc "\n" \
70 ".previous" "\n")
7b453719
MY
71
72#endif /* __LINUX_EXPORT_INTERNAL_H__ */