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 20struct ppc_plt_entry { 21 /* 16 byte jump instruction sequence (4 instructions) */ 22 unsigned int jump[4]; 23}; 24#endif /* __powerpc64__ */ 25 26 27struct 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 /* For module function descriptor dereference */ 39 unsigned long start_opd; 40 unsigned long end_opd; 41#else /* powerpc64 */ 42 /* Indices of PLT sections within module. */ 43 unsigned int core_plt_section; 44 unsigned int init_plt_section; 45#endif /* powerpc64 */ 46 47#ifdef CONFIG_DYNAMIC_FTRACE 48 unsigned long tramp; 49 unsigned long tramp_regs; 50#endif 51 52 /* List of BUG addresses, source line numbers and filenames */ 53 struct list_head bug_list; 54 struct bug_entry *bug_table; 55 unsigned int num_bugs; 56}; 57 58/* 59 * Select ELF headers. 60 * Make empty sections for module_frob_arch_sections to expand. 61 */ 62 63#ifdef __powerpc64__ 64# ifdef MODULE 65 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous"); 66# ifdef CONFIG_PPC_KERNEL_PCREL 67 asm(".section .mygot,\"a\",@nobits; .align 3; .previous"); 68# endif 69# endif 70#else 71# ifdef MODULE 72 asm(".section .plt,\"ax\",@nobits; .align 3; .previous"); 73 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous"); 74# endif /* MODULE */ 75#endif 76 77#ifdef CONFIG_DYNAMIC_FTRACE 78int module_trampoline_target(struct module *mod, unsigned long trampoline, 79 unsigned long *target); 80int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs); 81#else 82static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs) 83{ 84 return 0; 85} 86#endif 87 88#endif /* __KERNEL__ */ 89#endif /* _ASM_POWERPC_MODULE_H */ 90