| 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 | * module loader code. Architectures that don't need to do anything special
|
| 11 | * can just rely on the 'weak' default hooks defined in kernel/module.c.
|
| 12 | * Note, however, that at least one of apply_relocate or apply_relocate_add
|
| 13 | * must be implemented by each architecture.
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 | bool module_elf_check_arch(Elf_Ehdr *hdr);
|
| 18 |
|
| 19 |
|
| 20 | int module_frob_arch_sections(Elf_Ehdr *hdr,
|
| 21 | Elf_Shdr *sechdrs,
|
| 22 | char *secstrings,
|
| 23 | struct module *mod);
|
| 24 |
|
| 25 |
|
| 26 | unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
|
| 27 |
|
| 28 | |
| 29 | sections. Returns NULL on failure.
|
| 30 | void *module_alloc(unsigned long size);
|
| 31 |
|
| 32 |
|
| 33 | void module_memfree(void *module_region);
|
| 34 |
|
| 35 | |
| 36 | * module loading).
|
| 37 |
|
| 38 | bool module_init_section(const char *name);
|
| 39 |
|
| 40 | |
| 41 | * module unloading)
|
| 42 |
|
| 43 | bool module_exit_section(const char *name);
|
| 44 |
|
| 45 | |
| 46 | * Apply the given relocation to the (simplified) ELF. Return -error
|
| 47 | * or 0.
|
| 48 |
|
| 49 | #ifdef CONFIG_MODULES_USE_ELF_REL
|
| 50 | int apply_relocate(Elf_Shdr *sechdrs,
|
| 51 | const char *strtab,
|
| 52 | unsigned int symindex,
|
| 53 | unsigned int relsec,
|
| 54 | struct module *mod);
|
| 55 | #else
|
| 56 | static inline int apply_relocate(Elf_Shdr *sechdrs,
|
| 57 | const char *strtab,
|
| 58 | unsigned int symindex,
|
| 59 | unsigned int relsec,
|
| 60 | struct module *me)
|
| 61 | {
|
| 62 | printk(KERN_ERR "module %s: REL relocation unsupported\n",
|
| 63 | module_name(me));
|
| 64 | return -ENOEXEC;
|
| 65 | }
|
| 66 | #endif
|
| 67 |
|
| 68 | |
| 69 | * Apply the given add relocation to the (simplified) ELF. Return
|
| 70 | * -error or 0
|
| 71 |
|
| 72 | #ifdef CONFIG_MODULES_USE_ELF_RELA
|
| 73 | int apply_relocate_add(Elf_Shdr *sechdrs,
|
| 74 | const char *strtab,
|
| 75 | unsigned int symindex,
|
| 76 | unsigned int relsec,
|
| 77 | struct module *mod);
|
| 78 | #else
|
| 79 | static inline int apply_relocate_add(Elf_Shdr *sechdrs,
|
| 80 | const char *strtab,
|
| 81 | unsigned int symindex,
|
| 82 | unsigned int relsec,
|
| 83 | struct module *me)
|
| 84 | {
|
| 85 | printk(KERN_ERR "module %s: REL relocation unsupported\n",
|
| 86 | module_name(me));
|
| 87 | return -ENOEXEC;
|
| 88 | }
|
| 89 | #endif
|
| 90 |
|
| 91 |
|
| 92 | int module_finalize(const Elf_Ehdr *hdr,
|
| 93 | const Elf_Shdr *sechdrs,
|
| 94 | struct module *mod);
|
| 95 |
|
| 96 |
|
| 97 | void module_arch_cleanup(struct module *mod);
|
| 98 |
|
| 99 |
|
| 100 | void module_arch_freeing_init(struct module *mod);
|
| 101 |
|
| 102 | #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
|
| 103 | !defined(CONFIG_KASAN_VMALLOC)
|
| 104 | #include <linux/kasan.h>
|
| 105 | #define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
|
| 106 | #else
|
| 107 | #define MODULE_ALIGN PAGE_SIZE
|
| 108 | #endif
|
| 109 |
|
| 110 | #endif
|