at v6.14-rc5 2.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2#ifndef _LINUX_EXPORT_H 3#define _LINUX_EXPORT_H 4 5#include <linux/compiler.h> 6#include <linux/linkage.h> 7#include <linux/stringify.h> 8 9/* 10 * This comment block is used by fixdep. Please do not remove. 11 * 12 * When CONFIG_MODVERSIONS is changed from n to y, all source files having 13 * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a 14 * side effect of the *.o build rule. 15 */ 16 17#ifdef CONFIG_64BIT 18#define __EXPORT_SYMBOL_REF(sym) \ 19 .balign 8 ASM_NL \ 20 .quad sym 21#else 22#define __EXPORT_SYMBOL_REF(sym) \ 23 .balign 4 ASM_NL \ 24 .long sym 25#endif 26 27#define ___EXPORT_SYMBOL(sym, license, ns) \ 28 .section ".export_symbol","a" ASM_NL \ 29 __export_symbol_##sym: ASM_NL \ 30 .asciz license ASM_NL \ 31 .asciz ns ASM_NL \ 32 __EXPORT_SYMBOL_REF(sym) ASM_NL \ 33 .previous 34 35#if defined(__DISABLE_EXPORTS) 36 37/* 38 * Allow symbol exports to be disabled completely so that C code may 39 * be reused in other execution contexts such as the UEFI stub or the 40 * decompressor. 41 */ 42#define __EXPORT_SYMBOL(sym, license, ns) 43 44#elif defined(__GENKSYMS__) 45 46#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym) 47 48#elif defined(__ASSEMBLY__) 49 50#define __EXPORT_SYMBOL(sym, license, ns) \ 51 ___EXPORT_SYMBOL(sym, license, ns) 52 53#else 54 55#ifdef CONFIG_GENDWARFKSYMS 56/* 57 * With CONFIG_GENDWARFKSYMS, ensure the compiler emits debugging 58 * information for all exported symbols, including those defined in 59 * different TUs, by adding a __gendwarfksyms_ptr_<symbol> pointer 60 * that's discarded during the final link. 61 */ 62#define __GENDWARFKSYMS_EXPORT(sym) \ 63 static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ 64 __section(".discard.gendwarfksyms") = &sym; 65#else 66#define __GENDWARFKSYMS_EXPORT(sym) 67#endif 68 69#define __EXPORT_SYMBOL(sym, license, ns) \ 70 extern typeof(sym) sym; \ 71 __ADDRESSABLE(sym) \ 72 __GENDWARFKSYMS_EXPORT(sym) \ 73 asm(__stringify(___EXPORT_SYMBOL(sym, license, ns))) 74 75#endif 76 77#ifdef DEFAULT_SYMBOL_NAMESPACE 78#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE) 79#else 80#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "") 81#endif 82 83#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") 84#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL") 85#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns) 86#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns) 87 88#endif /* _LINUX_EXPORT_H */