Merge tag 'perf-tools-for-v6.4-3-2023-05-06' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / include / asm-generic / export.h
CommitLineData
bf49d9dd 1/* SPDX-License-Identifier: GPL-2.0-only */
22823ab4
AV
2#ifndef __ASM_GENERIC_EXPORT_H
3#define __ASM_GENERIC_EXPORT_H
4
7b453719
MY
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
22823ab4
AV
13#ifndef KSYM_FUNC
14#define KSYM_FUNC(x) x
15#endif
ed13fc33
MM
16#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
17#define KSYM_ALIGN 4
18#elif defined(CONFIG_64BIT)
22823ab4 19#define KSYM_ALIGN 8
22823ab4 20#else
22823ab4
AV
21#define KSYM_ALIGN 4
22#endif
22823ab4 23
7290d580
AB
24.macro __put, val, name
25#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
069e1c07 26 .long \val - ., \name - ., 0
7290d580 27#elif defined(CONFIG_64BIT)
8651ec01 28 .quad \val, \name, 0
7290d580 29#else
8651ec01 30 .long \val, \name, 0
7290d580
AB
31#endif
32.endm
33
22823ab4 34/*
ce2b617c
JY
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.
22823ab4 38 */
ce2b617c 39
22823ab4 40.macro ___EXPORT_SYMBOL name,val,sec
54effa65 41#if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS)
22823ab4
AV
42 .section ___ksymtab\sec+\name,"a"
43 .balign KSYM_ALIGN
94e58e0a
MY
44__ksymtab_\name:
45 __put \val, __kstrtab_\name
22823ab4 46 .previous
ce2b617c 47 .section __ksymtab_strings,"aMS",%progbits,1
94e58e0a 48__kstrtab_\name:
22823ab4 49 .asciz "\name"
22823ab4 50 .previous
22823ab4
AV
51#endif
52.endm
22823ab4 53
bbda5ec6 54#if defined(CONFIG_TRIM_UNUSED_KSYMS)
22823ab4
AV
55
56#include <linux/kconfig.h>
57#include <generated/autoksyms.h>
58
bbda5ec6
MY
59.macro __ksym_marker sym
60 .section ".discard.ksym","a"
61__ksym_marker_\sym:
62 .previous
63.endm
64
22823ab4 65#define __EXPORT_SYMBOL(sym, val, sec) \
bbda5ec6 66 __ksym_marker sym; \
c0a0aba8 67 __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
22823ab4
AV
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) \
94e58e0a 80 __EXPORT_SYMBOL(name, KSYM_FUNC(name),)
22823ab4 81#define EXPORT_SYMBOL_GPL(name) \
94e58e0a 82 __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
22823ab4 83#define EXPORT_DATA_SYMBOL(name) \
94e58e0a 84 __EXPORT_SYMBOL(name, name,)
22823ab4 85#define EXPORT_DATA_SYMBOL_GPL(name) \
94e58e0a 86 __EXPORT_SYMBOL(name, name,_gpl)
22823ab4
AV
87
88#endif