2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _LINUX_MODULELOADER_H
|
|
|
|
#define _LINUX_MODULELOADER_H
|
|
|
|
/* The stuff needed for archs to support modules. */
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/elf.h>
|
|
|
|
|
2011-07-01 02:22:11 +07:00
|
|
|
/* 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.
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Adjust arch-specific sections. Return 0 on success. */
|
|
|
|
int module_frob_arch_sections(Elf_Ehdr *hdr,
|
|
|
|
Elf_Shdr *sechdrs,
|
|
|
|
char *secstrings,
|
|
|
|
struct module *mod);
|
|
|
|
|
2008-12-31 18:31:18 +07:00
|
|
|
/* Additional bytes needed by arch in front of individual sections */
|
|
|
|
unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Allocator used for allocating struct module, core sections and init
|
|
|
|
sections. Returns NULL on failure. */
|
|
|
|
void *module_alloc(unsigned long size);
|
|
|
|
|
|
|
|
/* Free memory returned from module_alloc. */
|
|
|
|
void module_free(struct module *mod, void *module_region);
|
|
|
|
|
2012-09-28 12:01:03 +07:00
|
|
|
/*
|
|
|
|
* Apply the given relocation to the (simplified) ELF. Return -error
|
|
|
|
* or 0.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_MODULES_USE_ELF_REL
|
2005-04-17 05:20:36 +07:00
|
|
|
int apply_relocate(Elf_Shdr *sechdrs,
|
|
|
|
const char *strtab,
|
|
|
|
unsigned int symindex,
|
|
|
|
unsigned int relsec,
|
|
|
|
struct module *mod);
|
2012-09-28 12:01:03 +07:00
|
|
|
#else
|
|
|
|
static inline int apply_relocate(Elf_Shdr *sechdrs,
|
|
|
|
const char *strtab,
|
|
|
|
unsigned int symindex,
|
|
|
|
unsigned int relsec,
|
|
|
|
struct module *me)
|
|
|
|
{
|
2014-07-27 04:53:01 +07:00
|
|
|
printk(KERN_ERR "module %s: REL relocation unsupported\n",
|
|
|
|
module_name(me));
|
2012-09-28 12:01:03 +07:00
|
|
|
return -ENOEXEC;
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-09-28 12:01:03 +07:00
|
|
|
/*
|
|
|
|
* Apply the given add relocation to the (simplified) ELF. Return
|
|
|
|
* -error or 0
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_MODULES_USE_ELF_RELA
|
2005-04-17 05:20:36 +07:00
|
|
|
int apply_relocate_add(Elf_Shdr *sechdrs,
|
|
|
|
const char *strtab,
|
|
|
|
unsigned int symindex,
|
|
|
|
unsigned int relsec,
|
|
|
|
struct module *mod);
|
2012-09-28 12:01:03 +07:00
|
|
|
#else
|
|
|
|
static inline int apply_relocate_add(Elf_Shdr *sechdrs,
|
|
|
|
const char *strtab,
|
|
|
|
unsigned int symindex,
|
|
|
|
unsigned int relsec,
|
|
|
|
struct module *me)
|
|
|
|
{
|
2014-07-27 04:53:01 +07:00
|
|
|
printk(KERN_ERR "module %s: REL relocation unsupported\n",
|
|
|
|
module_name(me));
|
2012-09-28 12:01:03 +07:00
|
|
|
return -ENOEXEC;
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Any final processing of module before access. Return -error or 0. */
|
|
|
|
int module_finalize(const Elf_Ehdr *hdr,
|
|
|
|
const Elf_Shdr *sechdrs,
|
|
|
|
struct module *mod);
|
|
|
|
|
|
|
|
/* Any cleanup needed when module leaves. */
|
|
|
|
void module_arch_cleanup(struct module *mod);
|
|
|
|
|
|
|
|
#endif
|