blob: c1f40c2f7ffbdffae2ff037d17df5a8a6b857957 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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. */
11int module_frob_arch_sections(Elf_Ehdr *hdr,
12 Elf_Shdr *sechdrs,
13 char *secstrings,
14 struct module *mod);
15
Helge Deller088af9a2008-12-31 12:31:18 +010016/* Additional bytes needed by arch in front of individual sections */
17unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019/* Allocator used for allocating struct module, core sections and init
20 sections. Returns NULL on failure. */
21void *module_alloc(unsigned long size);
22
23/* Free memory returned from module_alloc. */
24void module_free(struct module *mod, void *module_region);
25
26/* Apply the given relocation to the (simplified) ELF. Return -error
27 or 0. */
28int apply_relocate(Elf_Shdr *sechdrs,
29 const char *strtab,
30 unsigned int symindex,
31 unsigned int relsec,
32 struct module *mod);
33
34/* Apply the given add relocation to the (simplified) ELF. Return
35 -error or 0 */
36int apply_relocate_add(Elf_Shdr *sechdrs,
37 const char *strtab,
38 unsigned int symindex,
39 unsigned int relsec,
40 struct module *mod);
41
42/* Any final processing of module before access. Return -error or 0. */
43int module_finalize(const Elf_Ehdr *hdr,
44 const Elf_Shdr *sechdrs,
45 struct module *mod);
46
47/* Any cleanup needed when module leaves. */
48void module_arch_cleanup(struct module *mod);
49
50#endif