at v6.5 2.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Please do not include this explicitly. 4 * This is used by C files generated by modpost. 5 */ 6 7#ifndef __LINUX_EXPORT_INTERNAL_H__ 8#define __LINUX_EXPORT_INTERNAL_H__ 9 10#include <linux/compiler.h> 11#include <linux/types.h> 12 13#if defined(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS) 14/* 15 * relative reference: this reduces the size by half on 64-bit architectures, 16 * and eliminates the need for absolute relocations that require runtime 17 * processing on relocatable kernels. 18 */ 19#define __KSYM_REF(sym) ".long " #sym "- ." 20#elif defined(CONFIG_64BIT) 21#define __KSYM_REF(sym) ".quad " #sym 22#else 23#define __KSYM_REF(sym) ".long " #sym 24#endif 25 26/* 27 * For every exported symbol, do the following: 28 * 29 * - Put the name of the symbol and namespace (empty string "" for none) in 30 * __ksymtab_strings. 31 * - Place a struct kernel_symbol entry in the __ksymtab section. 32 * 33 * Note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) 34 * section flag requires it. Use '%progbits' instead of '@progbits' since the 35 * former apparently works on all arches according to the binutils source. 36 */ 37#define __KSYMTAB(name, sym, sec, ns) \ 38 asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1" "\n" \ 39 "__kstrtab_" #name ":" "\n" \ 40 " .asciz \"" #name "\"" "\n" \ 41 "__kstrtabns_" #name ":" "\n" \ 42 " .asciz \"" ns "\"" "\n" \ 43 " .previous" "\n" \ 44 " .section \"___ksymtab" sec "+" #name "\", \"a\"" "\n" \ 45 " .balign 4" "\n" \ 46 "__ksymtab_" #name ":" "\n" \ 47 __KSYM_REF(sym) "\n" \ 48 __KSYM_REF(__kstrtab_ ##name) "\n" \ 49 __KSYM_REF(__kstrtabns_ ##name) "\n" \ 50 " .previous" "\n" \ 51 ) 52 53#ifdef CONFIG_IA64 54#define KSYM_FUNC(name) @fptr(name) 55#else 56#define KSYM_FUNC(name) name 57#endif 58 59#define KSYMTAB_FUNC(name, sec, ns) __KSYMTAB(name, KSYM_FUNC(name), sec, ns) 60#define KSYMTAB_DATA(name, sec, ns) __KSYMTAB(name, name, sec, ns) 61 62#define SYMBOL_CRC(sym, crc, sec) \ 63 asm(".section \"___kcrctab" sec "+" #sym "\",\"a\"" "\n" \ 64 "__crc_" #sym ":" "\n" \ 65 ".long " #crc "\n" \ 66 ".previous" "\n") 67 68#endif /* __LINUX_EXPORT_INTERNAL_H__ */