1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _ASM_POWERPC_MODULE_H
3 #define _ASM_POWERPC_MODULE_H
9 #include <linux/list.h>
11 #include <asm-generic/module.h>
14 #ifdef CONFIG_MPROFILE_KERNEL
15 #define MODULE_ARCH_VERMAGIC_FTRACE "mprofile-kernel "
17 #define MODULE_ARCH_VERMAGIC_FTRACE ""
20 #ifdef CONFIG_RELOCATABLE
21 #define MODULE_ARCH_VERMAGIC_RELOCATABLE "relocatable "
23 #define MODULE_ARCH_VERMAGIC_RELOCATABLE ""
26 #define MODULE_ARCH_VERMAGIC MODULE_ARCH_VERMAGIC_FTRACE MODULE_ARCH_VERMAGIC_RELOCATABLE
30 * Thanks to Paul M for explaining this.
32 * PPC can only do rel jumps += 32MB, and often the kernel and other
33 * modules are further away than this. So, we jump to a table of
34 * trampolines attached to the module (the Procedure Linkage Table)
35 * whenever that happens.
38 struct ppc_plt_entry
{
39 /* 16 byte jump instruction sequence (4 instructions) */
42 #endif /* __powerpc64__ */
45 struct mod_arch_specific
{
47 unsigned int stubs_section
; /* Index of stubs section in module */
48 unsigned int toc_section
; /* What section is the TOC? */
49 bool toc_fixed
; /* Have we fixed up .TOC.? */
51 /* For module function descriptor dereference */
52 unsigned long start_opd
;
53 unsigned long end_opd
;
55 /* Indices of PLT sections within module. */
56 unsigned int core_plt_section
;
57 unsigned int init_plt_section
;
58 #endif /* powerpc64 */
60 #ifdef CONFIG_DYNAMIC_FTRACE
62 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
63 unsigned long tramp_regs
;
67 /* List of BUG addresses, source line numbers and filenames */
68 struct list_head bug_list
;
69 struct bug_entry
*bug_table
;
70 unsigned int num_bugs
;
75 * Make empty section for module_frob_arch_sections to expand.
80 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
84 asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
85 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
89 #ifdef CONFIG_DYNAMIC_FTRACE
91 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
95 int module_trampoline_target(struct module
*mod
, unsigned long trampoline
,
96 unsigned long *target
);
98 #ifdef CONFIG_DYNAMIC_FTRACE
99 int module_finalize_ftrace(struct module
*mod
, const Elf_Shdr
*sechdrs
);
101 static inline int module_finalize_ftrace(struct module
*mod
, const Elf_Shdr
*sechdrs
)
107 #endif /* __KERNEL__ */
108 #endif /* _ASM_POWERPC_MODULE_H */