1 #ifndef _ASM_POWERPC_MODULE_H 2 #define _ASM_POWERPC_MODULE_H 3 #ifdef __KERNEL__ 4 5 /* 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 9 * 2 of the License, or (at your option) any later version. 10 */ 11 12 #include <linux/list.h> 13 #include <asm/bug.h> 14 #include <asm-generic/module.h> 15 16 17 #ifdef CC_USING_MPROFILE_KERNEL 18 #define MODULE_ARCH_VERMAGIC_FTRACE "mprofile-kernel " 19 #else 20 #define MODULE_ARCH_VERMAGIC_FTRACE "" 21 #endif 22 23 #ifdef CONFIG_RELOCATABLE 24 #define MODULE_ARCH_VERMAGIC_RELOCATABLE "relocatable " 25 #else 26 #define MODULE_ARCH_VERMAGIC_RELOCATABLE "" 27 #endif 28 29 #define MODULE_ARCH_VERMAGIC MODULE_ARCH_VERMAGIC_FTRACE MODULE_ARCH_VERMAGIC_RELOCATABLE 30 31 #ifndef __powerpc64__ 32 /* 33 * Thanks to Paul M for explaining this. 34 * 35 * PPC can only do rel jumps += 32MB, and often the kernel and other 36 * modules are further away than this. So, we jump to a table of 37 * trampolines attached to the module (the Procedure Linkage Table) 38 * whenever that happens. 39 */ 40 41 struct ppc_plt_entry { 42 /* 16 byte jump instruction sequence (4 instructions) */ 43 unsigned int jump[4]; 44 }; 45 #endif /* __powerpc64__ */ 46 47 48 struct mod_arch_specific { 49 #ifdef __powerpc64__ 50 unsigned int stubs_section; /* Index of stubs section in module */ 51 unsigned int toc_section; /* What section is the TOC? */ 52 bool toc_fixed; /* Have we fixed up .TOC.? */ 53 #ifdef CONFIG_DYNAMIC_FTRACE 54 unsigned long toc; 55 unsigned long tramp; 56 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS 57 unsigned long tramp_regs; 58 #endif 59 #endif 60 61 /* For module function descriptor dereference */ 62 unsigned long start_opd; 63 unsigned long end_opd; 64 #else /* powerpc64 */ 65 /* Indices of PLT sections within module. */ 66 unsigned int core_plt_section; 67 unsigned int init_plt_section; 68 #ifdef CONFIG_DYNAMIC_FTRACE 69 unsigned long tramp; 70 #endif 71 #endif /* powerpc64 */ 72 73 /* List of BUG addresses, source line numbers and filenames */ 74 struct list_head bug_list; 75 struct bug_entry *bug_table; 76 unsigned int num_bugs; 77 }; 78 79 /* 80 * Select ELF headers. 81 * Make empty section for module_frob_arch_sections to expand. 82 */ 83 84 #ifdef __powerpc64__ 85 # ifdef MODULE 86 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous"); 87 # endif 88 #else 89 # ifdef MODULE 90 asm(".section .plt,\"ax\",@nobits; .align 3; .previous"); 91 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous"); 92 # endif /* MODULE */ 93 #endif 94 95 #ifdef CONFIG_DYNAMIC_FTRACE 96 # ifdef MODULE 97 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous"); 98 # endif /* MODULE */ 99 #endif 100 101 int module_trampoline_target(struct module *mod, unsigned long trampoline, 102 unsigned long *target); 103 104 #ifdef CONFIG_DYNAMIC_FTRACE 105 int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs); 106 #else 107 static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs) 108 { 109 return 0; 110 } 111 #endif 112 113 #endif /* __KERNEL__ */ 114 #endif /* _ASM_POWERPC_MODULE_H */ 115