1 #ifndef _LINUX_MODULELOADER_H
2 #define _LINUX_MODULELOADER_H
3 /* The stuff needed for archs to support modules. */
5 #include <linux/module.h>
8 /* These may be implemented by architectures that need to hook into the
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.
15 /* Adjust arch-specific sections. Return 0 on success. */
16 int module_frob_arch_sections(Elf_Ehdr *hdr,
21 /* Additional bytes needed by arch in front of individual sections */
22 unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
24 /* Allocator used for allocating struct module, core sections and init
25 sections. Returns NULL on failure. */
26 void *module_alloc(unsigned long size);
28 /* Free memory returned from module_alloc. */
29 void module_free(struct module *mod, void *module_region);
32 * Apply the given relocation to the (simplified) ELF. Return -error
35 #ifdef CONFIG_MODULES_USE_ELF_REL
36 int apply_relocate(Elf_Shdr *sechdrs,
38 unsigned int symindex,
42 static inline int apply_relocate(Elf_Shdr *sechdrs,
44 unsigned int symindex,
48 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
54 * Apply the given add relocation to the (simplified) ELF. Return
57 #ifdef CONFIG_MODULES_USE_ELF_RELA
58 int apply_relocate_add(Elf_Shdr *sechdrs,
60 unsigned int symindex,
64 static inline int apply_relocate_add(Elf_Shdr *sechdrs,
66 unsigned int symindex,
70 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75 /* Any final processing of module before access. Return -error or 0. */
76 int module_finalize(const Elf_Ehdr *hdr,
77 const Elf_Shdr *sechdrs,
80 /* Any cleanup needed when module leaves. */
81 void module_arch_cleanup(struct module *mod);