.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | #ifndef __ASM_GENERIC_EXPORT_H |
---|
2 | 3 | #define __ASM_GENERIC_EXPORT_H |
---|
3 | 4 | |
---|
4 | 5 | #ifndef KSYM_FUNC |
---|
5 | 6 | #define KSYM_FUNC(x) x |
---|
6 | 7 | #endif |
---|
7 | | -#ifdef CONFIG_64BIT |
---|
8 | | -#ifndef KSYM_ALIGN |
---|
9 | | -#define KSYM_ALIGN 8 |
---|
10 | | -#endif |
---|
11 | | -#else |
---|
12 | | -#ifndef KSYM_ALIGN |
---|
| 8 | +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
---|
13 | 9 | #define KSYM_ALIGN 4 |
---|
14 | | -#endif |
---|
| 10 | +#elif defined(CONFIG_64BIT) |
---|
| 11 | +#define KSYM_ALIGN 8 |
---|
| 12 | +#else |
---|
| 13 | +#define KSYM_ALIGN 4 |
---|
15 | 14 | #endif |
---|
16 | 15 | #ifndef KCRC_ALIGN |
---|
17 | 16 | #define KCRC_ALIGN 4 |
---|
.. | .. |
---|
19 | 18 | |
---|
20 | 19 | .macro __put, val, name |
---|
21 | 20 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
---|
22 | | - .long \val - ., \name - . |
---|
| 21 | + .long \val - ., \name - ., 0 |
---|
23 | 22 | #elif defined(CONFIG_64BIT) |
---|
24 | | - .quad \val, \name |
---|
| 23 | + .quad \val, \name, 0 |
---|
25 | 24 | #else |
---|
26 | | - .long \val, \name |
---|
| 25 | + .long \val, \name, 0 |
---|
27 | 26 | #endif |
---|
28 | 27 | .endm |
---|
29 | 28 | |
---|
30 | 29 | /* |
---|
31 | | - * note on .section use: @progbits vs %progbits nastiness doesn't matter, |
---|
32 | | - * since we immediately emit into those sections anyway. |
---|
| 30 | + * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) |
---|
| 31 | + * section flag requires it. Use '%progbits' instead of '@progbits' since the |
---|
| 32 | + * former apparently works on all arches according to the binutils source. |
---|
33 | 33 | */ |
---|
| 34 | + |
---|
34 | 35 | .macro ___EXPORT_SYMBOL name,val,sec |
---|
35 | | -#ifdef CONFIG_MODULES |
---|
36 | | - .globl __ksymtab_\name |
---|
| 36 | +#if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS) |
---|
37 | 37 | .section ___ksymtab\sec+\name,"a" |
---|
38 | 38 | .balign KSYM_ALIGN |
---|
39 | 39 | __ksymtab_\name: |
---|
40 | 40 | __put \val, __kstrtab_\name |
---|
41 | 41 | .previous |
---|
42 | | - .section __ksymtab_strings,"a" |
---|
| 42 | + .section __ksymtab_strings,"aMS",%progbits,1 |
---|
43 | 43 | __kstrtab_\name: |
---|
44 | 44 | .asciz "\name" |
---|
45 | 45 | .previous |
---|
46 | 46 | #ifdef CONFIG_MODVERSIONS |
---|
47 | 47 | .section ___kcrctab\sec+\name,"a" |
---|
48 | 48 | .balign KCRC_ALIGN |
---|
49 | | -__kcrctab_\name: |
---|
50 | 49 | #if defined(CONFIG_MODULE_REL_CRCS) |
---|
51 | 50 | .long __crc_\name - . |
---|
52 | 51 | #else |
---|
.. | .. |
---|
57 | 56 | #endif |
---|
58 | 57 | #endif |
---|
59 | 58 | .endm |
---|
60 | | -#undef __put |
---|
61 | 59 | |
---|
62 | | -#if defined(__KSYM_DEPS__) |
---|
63 | | - |
---|
64 | | -#define __EXPORT_SYMBOL(sym, val, sec) === __KSYM_##sym === |
---|
65 | | - |
---|
66 | | -#elif defined(CONFIG_TRIM_UNUSED_KSYMS) |
---|
| 60 | +#if defined(CONFIG_TRIM_UNUSED_KSYMS) |
---|
67 | 61 | |
---|
68 | 62 | #include <linux/kconfig.h> |
---|
69 | 63 | #include <generated/autoksyms.h> |
---|
70 | 64 | |
---|
| 65 | +.macro __ksym_marker sym |
---|
| 66 | + .section ".discard.ksym","a" |
---|
| 67 | +__ksym_marker_\sym: |
---|
| 68 | + .previous |
---|
| 69 | +.endm |
---|
| 70 | + |
---|
71 | 71 | #define __EXPORT_SYMBOL(sym, val, sec) \ |
---|
| 72 | + __ksym_marker sym; \ |
---|
72 | 73 | __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) |
---|
73 | 74 | #define __cond_export_sym(sym, val, sec, conf) \ |
---|
74 | 75 | ___cond_export_sym(sym, val, sec, conf) |
---|