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
35
36#ifdef CONFIG_MODULES_USE_ELF_REL
37int apply_relocate(Elf_Shdr *sechdrs,
38 const char *strtab,
39 unsigned int symindex,
40 unsigned int relsec,
41 struct module *mod);
42#else
43static inline int apply_relocate(Elf_Shdr *sechdrs,
44 const char *strtab,
45 unsigned int symindex,
46 unsigned int relsec,
47 struct module *me)
48{
49 printk(KERN_ERR "module %s: REL relocation unsupported\n",
50 module_name(me));
51 return -ENOEXEC;
52}
53#endif
54
55
56
57
58
59#ifdef CONFIG_MODULES_USE_ELF_RELA
60int apply_relocate_add(Elf_Shdr *sechdrs,
61 const char *strtab,
62 unsigned int symindex,
63 unsigned int relsec,
64 struct module *mod);
65#else
66static inline int apply_relocate_add(Elf_Shdr *sechdrs,
67 const char *strtab,
68 unsigned int symindex,
69 unsigned int relsec,
70 struct module *me)
71{
72 printk(KERN_ERR "module %s: REL relocation unsupported\n",
73 module_name(me));
74 return -ENOEXEC;
75}
76#endif
77
78
79int module_finalize(const Elf_Ehdr *hdr,
80 const Elf_Shdr *sechdrs,
81 struct module *mod);
82
83
84void module_arch_cleanup(struct module *mod);
85
86
87void module_arch_freeing_init(struct module *mod);
88
89#if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
90 !defined(CONFIG_KASAN_VMALLOC)
91#include <linux/kasan.h>
92#define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
93#else
94#define MODULE_ALIGN PAGE_SIZE
95#endif
96
97#endif
98