1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 #ifndef _ASM_POWERPC_MODULE_H 3 #define _ASM_POWERPC_MODULE_H 4 #ifdef __KERNEL__ 5 6 #include <linux/list.h> 7 #include <asm/bug.h> 8 #include <asm-generic/module.h> 9 10 #ifndef __powerpc64__ 11 /* 12 * Thanks to Paul M for explaining this. 13 * 14 * PPC can only do rel jumps += 32MB, and often the kernel and other 15 * modules are further away than this. So, we jump to a table of 16 * trampolines attached to the module (the Procedure Linkage Table) 17 * whenever that happens. 18 */ 19 20 struct ppc_plt_entry { 21 /* 16 byte jump instruction sequence (4 instructions) */ 22 unsigned int jump[4]; 23 }; 24 #endif /* __powerpc64__ */ 25 26 27 struct mod_arch_specific { 28 #ifdef __powerpc64__ 29 unsigned int stubs_section; /* Index of stubs section in module */ 30 #ifdef CONFIG_PPC_KERNEL_PCREL 31 unsigned int got_section; /* What section is the GOT? */ 32 unsigned int pcpu_section; /* .data..percpu section */ 33 #else 34 unsigned int toc_section; /* What section is the TOC? */ 35 bool toc_fixed; /* Have we fixed up .TOC.? */ 36 #endif 37 38 #ifdef CONFIG_PPC64_ELF_ABI_V1 39 /* For module function descriptor dereference */ 40 unsigned long start_opd; 41 unsigned long end_opd; 42 #endif 43 #else /* powerpc64 */ 44 /* Indices of PLT sections within module. */ 45 unsigned int core_plt_section; 46 unsigned int init_plt_section; 47 #endif /* powerpc64 */ 48 49 #ifdef CONFIG_DYNAMIC_FTRACE 50 unsigned long tramp; 51 unsigned long tramp_regs; 52 #ifdef CONFIG_PPC_FTRACE_OUT_OF_LINE 53 struct ftrace_ool_stub *ool_stubs; 54 unsigned int ool_stub_count; 55 unsigned int ool_stub_index; 56 #endif 57 #endif 58 }; 59 60 /* 61 * Select ELF headers. 62 * Make empty sections for module_frob_arch_sections to expand. 63 */ 64 65 #ifdef __powerpc64__ 66 # ifdef MODULE 67 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous"); 68 # ifdef CONFIG_PPC_KERNEL_PCREL 69 asm(".section .mygot,\"a\",@nobits; .align 3; .previous"); 70 # endif 71 # endif 72 #else 73 # ifdef MODULE 74 asm(".section .plt,\"ax\",@nobits; .align 3; .previous"); 75 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous"); 76 # endif /* MODULE */ 77 #endif 78 79 #ifdef CONFIG_DYNAMIC_FTRACE 80 int module_trampoline_target(struct module *mod, unsigned long trampoline, 81 unsigned long *target); 82 int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs); 83 #else 84 static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs) 85 { 86 return 0; 87 } 88 #endif 89 90 #endif /* __KERNEL__ */ 91 #endif /* _ASM_POWERPC_MODULE_H */ 92