aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/export.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/export.h')
-rw-r--r--include/linux/export.h64
1 files changed, 45 insertions, 19 deletions
diff --git a/include/linux/export.h b/include/linux/export.h
index b768d6dd3c90..ce764a5d2ee4 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -10,20 +10,7 @@
10 * hackers place grumpy comments in header files. 10 * hackers place grumpy comments in header files.
11 */ 11 */
12 12
13#define __VMLINUX_SYMBOL(x) x
14#define __VMLINUX_SYMBOL_STR(x) #x
15
16/* Indirect, so macros are expanded before pasting. */
17#define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x)
18#define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
19
20#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
21struct kernel_symbol
22{
23 unsigned long value;
24 const char *name;
25};
26
27#ifdef MODULE 14#ifdef MODULE
28extern struct module __this_module; 15extern struct module __this_module;
29#define THIS_MODULE (&__this_module) 16#define THIS_MODULE (&__this_module)
@@ -54,19 +41,58 @@ extern struct module __this_module;
54#define __CRC_SYMBOL(sym, sec) 41#define __CRC_SYMBOL(sym, sec)
55#endif 42#endif
56 43
44#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
45#include <linux/compiler.h>
46/*
47 * Emit the ksymtab entry as a pair of relative references: this reduces
48 * the size by half on 64-bit architectures, and eliminates the need for
49 * absolute relocations that require runtime processing on relocatable
50 * kernels.
51 */
52#define __KSYMTAB_ENTRY(sym, sec) \
53 __ADDRESSABLE(sym) \
54 asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \
55 " .balign 8 \n" \
56 "__ksymtab_" #sym ": \n" \
57 " .long " #sym "- . \n" \
58 " .long __kstrtab_" #sym "- . \n" \
59 " .previous \n")
60
61struct kernel_symbol {
62 int value_offset;
63 int name_offset;
64};
65#else
66#define __KSYMTAB_ENTRY(sym, sec) \
67 static const struct kernel_symbol __ksymtab_##sym \
68 __attribute__((section("___ksymtab" sec "+" #sym), used)) \
69 = { (unsigned long)&sym, __kstrtab_##sym }
70
71struct kernel_symbol {
72 unsigned long value;
73 const char *name;
74};
75#endif
76
57/* For every exported symbol, place a struct in the __ksymtab section */ 77/* For every exported symbol, place a struct in the __ksymtab section */
58#define ___EXPORT_SYMBOL(sym, sec) \ 78#define ___EXPORT_SYMBOL(sym, sec) \
59 extern typeof(sym) sym; \ 79 extern typeof(sym) sym; \
60 __CRC_SYMBOL(sym, sec) \ 80 __CRC_SYMBOL(sym, sec) \
61 static const char __kstrtab_##sym[] \ 81 static const char __kstrtab_##sym[] \
62 __attribute__((section("__ksymtab_strings"), aligned(1))) \ 82 __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
63 = #sym; \ 83 = #sym; \
64 static const struct kernel_symbol __ksymtab_##sym \ 84 __KSYMTAB_ENTRY(sym, sec)
65 __used \ 85
66 __attribute__((section("___ksymtab" sec "+" #sym), used)) \ 86#if defined(__DISABLE_EXPORTS)
67 = { (unsigned long)&sym, __kstrtab_##sym } 87
88/*
89 * Allow symbol exports to be disabled completely so that C code may
90 * be reused in other execution contexts such as the UEFI stub or the
91 * decompressor.
92 */
93#define __EXPORT_SYMBOL(sym, sec)
68 94
69#if defined(__KSYM_DEPS__) 95#elif defined(__KSYM_DEPS__)
70 96
71/* 97/*
72 * For fine grained build dependencies, we want to tell the build system 98 * For fine grained build dependencies, we want to tell the build system