Loading...
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#ifndef __powerpc64__
18/*
19 * Thanks to Paul M for explaining this.
20 *
21 * PPC can only do rel jumps += 32MB, and often the kernel and other
22 * modules are further away than this. So, we jump to a table of
23 * trampolines attached to the module (the Procedure Linkage Table)
24 * whenever that happens.
25 */
26
27struct ppc_plt_entry {
28 /* 16 byte jump instruction sequence (4 instructions) */
29 unsigned int jump[4];
30};
31#endif /* __powerpc64__ */
32
33
34struct mod_arch_specific {
35#ifdef __powerpc64__
36 unsigned int stubs_section; /* Index of stubs section in module */
37 unsigned int toc_section; /* What section is the TOC? */
38 bool toc_fixed; /* Have we fixed up .TOC.? */
39#ifdef CONFIG_DYNAMIC_FTRACE
40 unsigned long toc;
41 unsigned long tramp;
42#endif
43
44#else /* powerpc64 */
45 /* Indices of PLT sections within module. */
46 unsigned int core_plt_section;
47 unsigned int init_plt_section;
48#ifdef CONFIG_DYNAMIC_FTRACE
49 unsigned long tramp;
50#endif
51#endif /* powerpc64 */
52
53 /* List of BUG addresses, source line numbers and filenames */
54 struct list_head bug_list;
55 struct bug_entry *bug_table;
56 unsigned int num_bugs;
57};
58
59/*
60 * Select ELF headers.
61 * Make empty section for module_frob_arch_sections to expand.
62 */
63
64#ifdef __powerpc64__
65# ifdef MODULE
66 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
67# endif
68#else
69# ifdef MODULE
70 asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
71 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
72# endif /* MODULE */
73#endif
74
75#ifdef CONFIG_DYNAMIC_FTRACE
76# ifdef MODULE
77 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
78# endif /* MODULE */
79#endif
80
81int module_trampoline_target(struct module *mod, unsigned long trampoline,
82 unsigned long *target);
83
84#ifdef CONFIG_DYNAMIC_FTRACE
85int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
86#else
87static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
88{
89 return 0;
90}
91#endif
92
93struct exception_table_entry;
94void sort_ex_table(struct exception_table_entry *start,
95 struct exception_table_entry *finish);
96
97#if defined(CONFIG_MODVERSIONS) && defined(CONFIG_PPC64)
98#define ARCH_RELOCATES_KCRCTAB
99#define reloc_start PHYSICAL_START
100#endif
101#endif /* __KERNEL__ */
102#endif /* _ASM_POWERPC_MODULE_H */
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 unsigned int toc_section; /* What section is the TOC? */
31 bool toc_fixed; /* Have we fixed up .TOC.? */
32
33 /* For module function descriptor dereference */
34 unsigned long start_opd;
35 unsigned long end_opd;
36#else /* powerpc64 */
37 /* Indices of PLT sections within module. */
38 unsigned int core_plt_section;
39 unsigned int init_plt_section;
40#endif /* powerpc64 */
41
42#ifdef CONFIG_DYNAMIC_FTRACE
43 unsigned long tramp;
44#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
45 unsigned long tramp_regs;
46#endif
47#endif
48
49 /* List of BUG addresses, source line numbers and filenames */
50 struct list_head bug_list;
51 struct bug_entry *bug_table;
52 unsigned int num_bugs;
53};
54
55/*
56 * Select ELF headers.
57 * Make empty section for module_frob_arch_sections to expand.
58 */
59
60#ifdef __powerpc64__
61# ifdef MODULE
62 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
63# endif
64#else
65# ifdef MODULE
66 asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
67 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
68# endif /* MODULE */
69#endif
70
71#ifdef CONFIG_DYNAMIC_FTRACE
72# ifdef MODULE
73 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
74# endif /* MODULE */
75
76int module_trampoline_target(struct module *mod, unsigned long trampoline,
77 unsigned long *target);
78int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
79#else
80static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
81{
82 return 0;
83}
84#endif
85
86#endif /* __KERNEL__ */
87#endif /* _ASM_POWERPC_MODULE_H */