xref: /linux/include/linux/moduleloader.h (revision 367b8112fe2ea5c39a7bb4d263dcdd9b612fae18)
1 #ifndef _LINUX_MODULELOADER_H
2 #define _LINUX_MODULELOADER_H
3 /* The stuff needed for archs to support modules. */
4 
5 #include <linux/module.h>
6 #include <linux/elf.h>
7 
8 /* These must be implemented by the specific architecture */
9 
10 /* Adjust arch-specific sections.  Return 0 on success.  */
11 int module_frob_arch_sections(Elf_Ehdr *hdr,
12 			      Elf_Shdr *sechdrs,
13 			      char *secstrings,
14 			      struct module *mod);
15 
16 /* Allocator used for allocating struct module, core sections and init
17    sections.  Returns NULL on failure. */
18 void *module_alloc(unsigned long size);
19 
20 /* Free memory returned from module_alloc. */
21 void module_free(struct module *mod, void *module_region);
22 
23 /* Apply the given relocation to the (simplified) ELF.  Return -error
24    or 0. */
25 int apply_relocate(Elf_Shdr *sechdrs,
26 		   const char *strtab,
27 		   unsigned int symindex,
28 		   unsigned int relsec,
29 		   struct module *mod);
30 
31 /* Apply the given add relocation to the (simplified) ELF.  Return
32    -error or 0 */
33 int apply_relocate_add(Elf_Shdr *sechdrs,
34 		       const char *strtab,
35 		       unsigned int symindex,
36 		       unsigned int relsec,
37 		       struct module *mod);
38 
39 /* Any final processing of module before access.  Return -error or 0. */
40 int module_finalize(const Elf_Ehdr *hdr,
41 		    const Elf_Shdr *sechdrs,
42 		    struct module *mod);
43 
44 /* Any cleanup needed when module leaves. */
45 void module_arch_cleanup(struct module *mod);
46 
47 #endif
48