| 1 | #ifndef _LINUX_MODULELOADER_H
|
| 2 | #define _LINUX_MODULELOADER_H
|
| 3 |
|
| 4 |
|
| 5 | #include <linux/module.h>
|
| 6 | #include <linux/elf.h>
|
| 7 |
|
| 8 | |
| 9 | * module loader code. Architectures that don't need to do anything special
|
| 10 | * can just rely on the 'weak' default hooks defined in kernel/module.c.
|
| 11 | * Note, however, that at least one of apply_relocate or apply_relocate_add
|
| 12 | * must be implemented by each architecture.
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 | int module_frob_arch_sections(Elf_Ehdr *hdr,
|
| 17 | Elf_Shdr *sechdrs,
|
| 18 | char *secstrings,
|
| 19 | struct module *mod);
|
| 20 |
|
| 21 |
|
| 22 | unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
|
| 23 |
|
| 24 | |
| 25 | sections. Returns NULL on failure.
|
| 26 | void *module_alloc(unsigned long size);
|
| 27 |
|
| 28 |
|
| 29 | void module_free(struct module *mod, void *module_region);
|
| 30 |
|
| 31 | |
| 32 | * Apply the given relocation to the (simplified) ELF. Return -error
|
| 33 | * or 0.
|
| 34 |
|
| 35 | #ifdef CONFIG_MODULES_USE_ELF_REL
|
| 36 | int apply_relocate(Elf_Shdr *sechdrs,
|
| 37 | const char *strtab,
|
| 38 | unsigned int symindex,
|
| 39 | unsigned int relsec,
|
| 40 | struct module *mod);
|
| 41 | #else
|
| 42 | static inline int apply_relocate(Elf_Shdr *sechdrs,
|
| 43 | const char *strtab,
|
| 44 | unsigned int symindex,
|
| 45 | unsigned int relsec,
|
| 46 | struct module *me)
|
| 47 | {
|
| 48 | printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
|
| 49 | return -ENOEXEC;
|
| 50 | }
|
| 51 | #endif
|
| 52 |
|
| 53 | |
| 54 | * Apply the given add relocation to the (simplified) ELF. Return
|
| 55 | * -error or 0
|
| 56 |
|
| 57 | #ifdef CONFIG_MODULES_USE_ELF_RELA
|
| 58 | int apply_relocate_add(Elf_Shdr *sechdrs,
|
| 59 | const char *strtab,
|
| 60 | unsigned int symindex,
|
| 61 | unsigned int relsec,
|
| 62 | struct module *mod);
|
| 63 | #else
|
| 64 | static inline int apply_relocate_add(Elf_Shdr *sechdrs,
|
| 65 | const char *strtab,
|
| 66 | unsigned int symindex,
|
| 67 | unsigned int relsec,
|
| 68 | struct module *me)
|
| 69 | {
|
| 70 | printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
|
| 71 | return -ENOEXEC;
|
| 72 | }
|
| 73 | #endif
|
| 74 |
|
| 75 |
|
| 76 | int module_finalize(const Elf_Ehdr *hdr,
|
| 77 | const Elf_Shdr *sechdrs,
|
| 78 | struct module *mod);
|
| 79 |
|
| 80 |
|
| 81 | void module_arch_cleanup(struct module *mod);
|
| 82 |
|
| 83 | #endif
|