Merge tag 'kbuild-v4.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[linux-2.6-microblaze.git] / include / linux / export.h
index b768d6d..ce764a5 100644 (file)
  * hackers place grumpy comments in header files.
  */
 
-#define __VMLINUX_SYMBOL(x) x
-#define __VMLINUX_SYMBOL_STR(x) #x
-
-/* Indirect, so macros are expanded before pasting. */
-#define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x)
-#define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
-
 #ifndef __ASSEMBLY__
-struct kernel_symbol
-{
-       unsigned long value;
-       const char *name;
-};
-
 #ifdef MODULE
 extern struct module __this_module;
 #define THIS_MODULE (&__this_module)
@@ -54,19 +41,58 @@ extern struct module __this_module;
 #define __CRC_SYMBOL(sym, sec)
 #endif
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#include <linux/compiler.h>
+/*
+ * Emit the ksymtab entry as a pair of relative references: this reduces
+ * the size by half on 64-bit architectures, and eliminates the need for
+ * absolute relocations that require runtime processing on relocatable
+ * kernels.
+ */
+#define __KSYMTAB_ENTRY(sym, sec)                                      \
+       __ADDRESSABLE(sym)                                              \
+       asm("   .section \"___ksymtab" sec "+" #sym "\", \"a\"  \n"     \
+           "   .balign 8                                       \n"     \
+           "__ksymtab_" #sym ":                                \n"     \
+           "   .long   " #sym "- .                             \n"     \
+           "   .long   __kstrtab_" #sym "- .                   \n"     \
+           "   .previous                                       \n")
+
+struct kernel_symbol {
+       int value_offset;
+       int name_offset;
+};
+#else
+#define __KSYMTAB_ENTRY(sym, sec)                                      \
+       static const struct kernel_symbol __ksymtab_##sym               \
+       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
+       = { (unsigned long)&sym, __kstrtab_##sym }
+
+struct kernel_symbol {
+       unsigned long value;
+       const char *name;
+};
+#endif
+
 /* For every exported symbol, place a struct in the __ksymtab section */
 #define ___EXPORT_SYMBOL(sym, sec)                                     \
        extern typeof(sym) sym;                                         \
        __CRC_SYMBOL(sym, sec)                                          \
        static const char __kstrtab_##sym[]                             \
-       __attribute__((section("__ksymtab_strings"), aligned(1)))       \
+       __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
        = #sym;                                                         \
-       static const struct kernel_symbol __ksymtab_##sym               \
-       __used                                                          \
-       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
-       = { (unsigned long)&sym, __kstrtab_##sym }
+       __KSYMTAB_ENTRY(sym, sec)
+
+#if defined(__DISABLE_EXPORTS)
+
+/*
+ * Allow symbol exports to be disabled completely so that C code may
+ * be reused in other execution contexts such as the UEFI stub or the
+ * decompressor.
+ */
+#define __EXPORT_SYMBOL(sym, sec)
 
-#if defined(__KSYM_DEPS__)
+#elif defined(__KSYM_DEPS__)
 
 /*
  * For fine grained build dependencies, we want to tell the build system