Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 258110
b: refs/heads/master
c: 74e08fc
h: refs/heads/master
v: v3
  • Loading branch information
Jonas Bonn authored and Rusty Russell committed Jul 24, 2011
1 parent 3445e70 commit ca305e6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 81c7413650fbbf881bcb9e567be61a6717eb1876
refs/heads/master: 74e08fcf7bef973512a1f813700f802a93678670
7 changes: 6 additions & 1 deletion trunk/include/linux/moduleloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
#include <linux/module.h>
#include <linux/elf.h>

/* These must be implemented by the specific architecture */
/* These may be implemented by architectures that need to hook into the
* module loader code. Architectures that don't need to do anything special
* can just rely on the 'weak' default hooks defined in kernel/module.c.
* Note, however, that at least one of apply_relocate or apply_relocate_add
* must be implemented by each architecture.
*/

/* Adjust arch-specific sections. Return 0 on success. */
int module_frob_arch_sections(Elf_Ehdr *hdr,
Expand Down
49 changes: 49 additions & 0 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,15 @@ static void unset_module_core_ro_nx(struct module *mod) { }
static void unset_module_init_ro_nx(struct module *mod) { }
#endif

void __weak module_free(struct module *mod, void *module_region)
{
vfree(module_region);
}

void __weak module_arch_cleanup(struct module *mod)
{
}

/* Free a module, remove from lists, etc. */
static void free_module(struct module *mod)
{
Expand Down Expand Up @@ -1851,6 +1860,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
return ret;
}

int __weak apply_relocate(Elf_Shdr *sechdrs,
const char *strtab,
unsigned int symindex,
unsigned int relsec,
struct module *me)
{
pr_err("module %s: REL relocation unsupported\n", me->name);
return -ENOEXEC;
}

int __weak apply_relocate_add(Elf_Shdr *sechdrs,
const char *strtab,
unsigned int symindex,
unsigned int relsec,
struct module *me)
{
pr_err("module %s: RELA relocation unsupported\n", me->name);
return -ENOEXEC;
}

static int apply_relocations(struct module *mod, const struct load_info *info)
{
unsigned int i;
Expand Down Expand Up @@ -2235,6 +2264,11 @@ static void dynamic_debug_remove(struct _ddebug *debug)
ddebug_remove_module(debug->modname);
}

void * __weak module_alloc(unsigned long size)
{
return size == 0 ? NULL : vmalloc_exec(size);
}

static void *module_alloc_update_bounds(unsigned long size)
{
void *ret = module_alloc(size);
Expand Down Expand Up @@ -2645,6 +2679,14 @@ static void flush_module_icache(const struct module *mod)
set_fs(old_fs);
}

int __weak module_frob_arch_sections(Elf_Ehdr *hdr,
Elf_Shdr *sechdrs,
char *secstrings,
struct module *mod)
{
return 0;
}

static struct module *layout_and_allocate(struct load_info *info)
{
/* Module within temporary copy. */
Expand Down Expand Up @@ -2716,6 +2758,13 @@ static void module_deallocate(struct module *mod, struct load_info *info)
module_free(mod, mod->module_core);
}

int __weak module_finalize(const Elf_Ehdr *hdr,
const Elf_Shdr *sechdrs,
struct module *me)
{
return 0;
}

static int post_relocation(struct module *mod, const struct load_info *info)
{
/* Sort exception table now relocations are done. */
Expand Down

0 comments on commit ca305e6

Please sign in to comment.