diff options
-rw-r--r-- | include/linux/moduleloader.h | 7 | ||||
-rw-r--r-- | kernel/module.c | 49 |
2 files changed, 55 insertions, 1 deletions
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h index c1f40c2f7ffb..b2be02ebf453 100644 --- a/include/linux/moduleloader.h +++ b/include/linux/moduleloader.h | |||
@@ -5,7 +5,12 @@ | |||
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <linux/elf.h> | 6 | #include <linux/elf.h> |
7 | 7 | ||
8 | /* These must be implemented by the specific architecture */ | 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. | ||
13 | */ | ||
9 | 14 | ||
10 | /* Adjust arch-specific sections. Return 0 on success. */ | 15 | /* Adjust arch-specific sections. Return 0 on success. */ |
11 | int module_frob_arch_sections(Elf_Ehdr *hdr, | 16 | int module_frob_arch_sections(Elf_Ehdr *hdr, |
diff --git a/kernel/module.c b/kernel/module.c index 795bdc7f5c3f..6301d6e173ca 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1697,6 +1697,15 @@ static void unset_module_core_ro_nx(struct module *mod) { } | |||
1697 | static void unset_module_init_ro_nx(struct module *mod) { } | 1697 | static void unset_module_init_ro_nx(struct module *mod) { } |
1698 | #endif | 1698 | #endif |
1699 | 1699 | ||
1700 | void __weak module_free(struct module *mod, void *module_region) | ||
1701 | { | ||
1702 | vfree(module_region); | ||
1703 | } | ||
1704 | |||
1705 | void __weak module_arch_cleanup(struct module *mod) | ||
1706 | { | ||
1707 | } | ||
1708 | |||
1700 | /* Free a module, remove from lists, etc. */ | 1709 | /* Free a module, remove from lists, etc. */ |
1701 | static void free_module(struct module *mod) | 1710 | static void free_module(struct module *mod) |
1702 | { | 1711 | { |
@@ -1851,6 +1860,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info) | |||
1851 | return ret; | 1860 | return ret; |
1852 | } | 1861 | } |
1853 | 1862 | ||
1863 | int __weak apply_relocate(Elf_Shdr *sechdrs, | ||
1864 | const char *strtab, | ||
1865 | unsigned int symindex, | ||
1866 | unsigned int relsec, | ||
1867 | struct module *me) | ||
1868 | { | ||
1869 | pr_err("module %s: REL relocation unsupported\n", me->name); | ||
1870 | return -ENOEXEC; | ||
1871 | } | ||
1872 | |||
1873 | int __weak apply_relocate_add(Elf_Shdr *sechdrs, | ||
1874 | const char *strtab, | ||
1875 | unsigned int symindex, | ||
1876 | unsigned int relsec, | ||
1877 | struct module *me) | ||
1878 | { | ||
1879 | pr_err("module %s: RELA relocation unsupported\n", me->name); | ||
1880 | return -ENOEXEC; | ||
1881 | } | ||
1882 | |||
1854 | static int apply_relocations(struct module *mod, const struct load_info *info) | 1883 | static int apply_relocations(struct module *mod, const struct load_info *info) |
1855 | { | 1884 | { |
1856 | unsigned int i; | 1885 | unsigned int i; |
@@ -2235,6 +2264,11 @@ static void dynamic_debug_remove(struct _ddebug *debug) | |||
2235 | ddebug_remove_module(debug->modname); | 2264 | ddebug_remove_module(debug->modname); |
2236 | } | 2265 | } |
2237 | 2266 | ||
2267 | void * __weak module_alloc(unsigned long size) | ||
2268 | { | ||
2269 | return size == 0 ? NULL : vmalloc_exec(size); | ||
2270 | } | ||
2271 | |||
2238 | static void *module_alloc_update_bounds(unsigned long size) | 2272 | static void *module_alloc_update_bounds(unsigned long size) |
2239 | { | 2273 | { |
2240 | void *ret = module_alloc(size); | 2274 | void *ret = module_alloc(size); |
@@ -2645,6 +2679,14 @@ static void flush_module_icache(const struct module *mod) | |||
2645 | set_fs(old_fs); | 2679 | set_fs(old_fs); |
2646 | } | 2680 | } |
2647 | 2681 | ||
2682 | int __weak module_frob_arch_sections(Elf_Ehdr *hdr, | ||
2683 | Elf_Shdr *sechdrs, | ||
2684 | char *secstrings, | ||
2685 | struct module *mod) | ||
2686 | { | ||
2687 | return 0; | ||
2688 | } | ||
2689 | |||
2648 | static struct module *layout_and_allocate(struct load_info *info) | 2690 | static struct module *layout_and_allocate(struct load_info *info) |
2649 | { | 2691 | { |
2650 | /* Module within temporary copy. */ | 2692 | /* Module within temporary copy. */ |
@@ -2716,6 +2758,13 @@ static void module_deallocate(struct module *mod, struct load_info *info) | |||
2716 | module_free(mod, mod->module_core); | 2758 | module_free(mod, mod->module_core); |
2717 | } | 2759 | } |
2718 | 2760 | ||
2761 | int __weak module_finalize(const Elf_Ehdr *hdr, | ||
2762 | const Elf_Shdr *sechdrs, | ||
2763 | struct module *me) | ||
2764 | { | ||
2765 | return 0; | ||
2766 | } | ||
2767 | |||
2719 | static int post_relocation(struct module *mod, const struct load_info *info) | 2768 | static int post_relocation(struct module *mod, const struct load_info *info) |
2720 | { | 2769 | { |
2721 | /* Sort exception table now relocations are done. */ | 2770 | /* Sort exception table now relocations are done. */ |