0001
0002 #ifndef _LINUX_MODULELOADER_H
0003 #define _LINUX_MODULELOADER_H
0004
0005
0006 #include <linux/module.h>
0007 #include <linux/elf.h>
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 int module_frob_arch_sections(Elf_Ehdr *hdr,
0018 Elf_Shdr *sechdrs,
0019 char *secstrings,
0020 struct module *mod);
0021
0022
0023 unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
0024
0025
0026
0027 void *module_alloc(unsigned long size);
0028
0029
0030 void module_memfree(void *module_region);
0031
0032
0033
0034
0035 bool module_init_section(const char *name);
0036
0037
0038
0039
0040 bool module_exit_section(const char *name);
0041
0042
0043
0044
0045
0046 #ifdef CONFIG_MODULES_USE_ELF_REL
0047 int apply_relocate(Elf_Shdr *sechdrs,
0048 const char *strtab,
0049 unsigned int symindex,
0050 unsigned int relsec,
0051 struct module *mod);
0052 #else
0053 static inline int apply_relocate(Elf_Shdr *sechdrs,
0054 const char *strtab,
0055 unsigned int symindex,
0056 unsigned int relsec,
0057 struct module *me)
0058 {
0059 printk(KERN_ERR "module %s: REL relocation unsupported\n",
0060 module_name(me));
0061 return -ENOEXEC;
0062 }
0063 #endif
0064
0065
0066
0067
0068
0069 #ifdef CONFIG_MODULES_USE_ELF_RELA
0070 int apply_relocate_add(Elf_Shdr *sechdrs,
0071 const char *strtab,
0072 unsigned int symindex,
0073 unsigned int relsec,
0074 struct module *mod);
0075 #else
0076 static inline int apply_relocate_add(Elf_Shdr *sechdrs,
0077 const char *strtab,
0078 unsigned int symindex,
0079 unsigned int relsec,
0080 struct module *me)
0081 {
0082 printk(KERN_ERR "module %s: REL relocation unsupported\n",
0083 module_name(me));
0084 return -ENOEXEC;
0085 }
0086 #endif
0087
0088
0089 int module_finalize(const Elf_Ehdr *hdr,
0090 const Elf_Shdr *sechdrs,
0091 struct module *mod);
0092
0093
0094 void module_arch_cleanup(struct module *mod);
0095
0096
0097 void module_arch_freeing_init(struct module *mod);
0098
0099 #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
0100 !defined(CONFIG_KASAN_VMALLOC)
0101 #include <linux/kasan.h>
0102 #define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
0103 #else
0104 #define MODULE_ALIGN PAGE_SIZE
0105 #endif
0106
0107 #endif