1
2#ifndef _LINUX_MODULELOADER_H
3#define _LINUX_MODULELOADER_H
4
5
6#include <linux/module.h>
7#include <linux/elf.h>
8
9
10
11
12
13
14
15
16
17int module_frob_arch_sections(Elf_Ehdr *hdr,
18 Elf_Shdr *sechdrs,
19 char *secstrings,
20 struct module *mod);
21
22
23unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
24
25
26
27void *module_alloc(unsigned long size);
28
29
30void module_memfree(void *module_region);
31
32
33
34
35bool module_init_section(const char *name);
36
37
38
39
40bool module_exit_section(const char *name);
41
42
43
44
45
46#ifdef CONFIG_MODULES_USE_ELF_REL
47int apply_relocate(Elf_Shdr *sechdrs,
48 const char *strtab,
49 unsigned int symindex,
50 unsigned int relsec,
51 struct module *mod);
52#else
53static inline int apply_relocate(Elf_Shdr *sechdrs,
54 const char *strtab,
55 unsigned int symindex,
56 unsigned int relsec,
57 struct module *me)
58{
59 printk(KERN_ERR "module %s: REL relocation unsupported\n",
60 module_name(me));
61 return -ENOEXEC;
62}
63#endif
64
65
66
67
68
69#ifdef CONFIG_MODULES_USE_ELF_RELA
70int apply_relocate_add(Elf_Shdr *sechdrs,
71 const char *strtab,
72 unsigned int symindex,
73 unsigned int relsec,
74 struct module *mod);
75#else
76static inline int apply_relocate_add(Elf_Shdr *sechdrs,
77 const char *strtab,
78 unsigned int symindex,
79 unsigned int relsec,
80 struct module *me)
81{
82 printk(KERN_ERR "module %s: REL relocation unsupported\n",
83 module_name(me));
84 return -ENOEXEC;
85}
86#endif
87
88
89int module_finalize(const Elf_Ehdr *hdr,
90 const Elf_Shdr *sechdrs,
91 struct module *mod);
92
93
94void module_arch_cleanup(struct module *mod);
95
96
97void module_arch_freeing_init(struct module *mod);
98
99#if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
100 !defined(CONFIG_KASAN_VMALLOC)
101#include <linux/kasan.h>
102#define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
103#else
104#define MODULE_ALIGN PAGE_SIZE
105#endif
106
107#endif
108