aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJonas Bonn <jonas@southpole.se>2011-06-30 15:22:11 -0400
committerRusty Russell <rusty@rustcorp.com.au>2011-07-24 08:36:04 -0400
commit74e08fcf7bef973512a1f813700f802a93678670 (patch)
tree467868e281ee7768c0124009340c0a5a1850de98 /kernel
parent81c7413650fbbf881bcb9e567be61a6717eb1876 (diff)
modules: add default loader hook implementations
The module loader code allows architectures to hook into the code by providing a small number of entry points that each arch must implement. This patch provides __weakly linked generic implementations of these entry points for architectures that don't need to do anything special. Signed-off-by: Jonas Bonn <jonas@southpole.se> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c49
1 files changed, 49 insertions, 0 deletions
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) { }
1697static void unset_module_init_ro_nx(struct module *mod) { } 1697static void unset_module_init_ro_nx(struct module *mod) { }
1698#endif 1698#endif
1699 1699
1700void __weak module_free(struct module *mod, void *module_region)
1701{
1702 vfree(module_region);
1703}
1704
1705void __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. */
1701static void free_module(struct module *mod) 1710static 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
1863int __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
1873int __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
1854static int apply_relocations(struct module *mod, const struct load_info *info) 1883static 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
2267void * __weak module_alloc(unsigned long size)
2268{
2269 return size == 0 ? NULL : vmalloc_exec(size);
2270}
2271
2238static void *module_alloc_update_bounds(unsigned long size) 2272static 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
2682int __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
2648static struct module *layout_and_allocate(struct load_info *info) 2690static 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
2761int __weak module_finalize(const Elf_Ehdr *hdr,
2762 const Elf_Shdr *sechdrs,
2763 struct module *me)
2764{
2765 return 0;
2766}
2767
2719static int post_relocation(struct module *mod, const struct load_info *info) 2768static 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. */