powerpc/ftrace: Minimise number of #ifdefs
[linux-2.6-block.git] / arch / powerpc / include / asm / module.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
a37c8875 2#ifndef _ASM_POWERPC_MODULE_H
3#define _ASM_POWERPC_MODULE_H
88ced031 4#ifdef __KERNEL__
6b9269ab 5
6b9269ab
JL
6#include <linux/list.h>
7#include <asm/bug.h>
786d35d4 8#include <asm-generic/module.h>
6b9269ab 9
6b9269ab
JL
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
446957ba 15 * modules are further away than this. So, we jump to a table of
6b9269ab
JL
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 unsigned int toc_section; /* What section is the TOC? */
4edebbea 31 bool toc_fixed; /* Have we fixed up .TOC.? */
f48cb8b4 32
5633e85b
SS
33 /* For module function descriptor dereference */
34 unsigned long start_opd;
35 unsigned long end_opd;
7cc45e64 36#else /* powerpc64 */
6b9269ab
JL
37 /* Indices of PLT sections within module. */
38 unsigned int core_plt_section;
39 unsigned int init_plt_section;
8ce621e1
JP
40#endif /* powerpc64 */
41
7cc45e64
SR
42#ifdef CONFIG_DYNAMIC_FTRACE
43 unsigned long tramp;
8ce621e1 44 unsigned long tramp_regs;
6b9269ab
JL
45#endif
46
47 /* List of BUG addresses, source line numbers and filenames */
48 struct list_head bug_list;
49 struct bug_entry *bug_table;
50 unsigned int num_bugs;
51};
52
6b9269ab
JL
53/*
54 * Select ELF headers.
55 * Make empty section for module_frob_arch_sections to expand.
56 */
57
58#ifdef __powerpc64__
6b9269ab
JL
59# ifdef MODULE
60 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
61# endif
62#else
6b9269ab
JL
63# ifdef MODULE
64 asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
65 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
66# endif /* MODULE */
67#endif
68
f48cb8b4
SR
69#ifdef CONFIG_DYNAMIC_FTRACE
70# ifdef MODULE
71 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
72# endif /* MODULE */
f48cb8b4 73
f17c4e01 74int module_trampoline_target(struct module *mod, unsigned long trampoline,
dd9fa162 75 unsigned long *target);
136cd345
ME
76int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
77#else
78static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
79{
80 return 0;
81}
82#endif
83
88ced031 84#endif /* __KERNEL__ */
a37c8875 85#endif /* _ASM_POWERPC_MODULE_H */