moduleloader.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _LINUX_MODULELOADER_H
  2. #define _LINUX_MODULELOADER_H
  3. /* The stuff needed for archs to support modules. */
  4. #include <linux/module.h>
  5. #include <linux/elf.h>
  6. /* These may be implemented by architectures that need to hook into the
  7. * module loader code. Architectures that don't need to do anything special
  8. * can just rely on the 'weak' default hooks defined in kernel/module.c.
  9. * Note, however, that at least one of apply_relocate or apply_relocate_add
  10. * must be implemented by each architecture.
  11. */
  12. /* Adjust arch-specific sections. Return 0 on success. */
  13. int module_frob_arch_sections(Elf_Ehdr *hdr,
  14. Elf_Shdr *sechdrs,
  15. char *secstrings,
  16. struct module *mod);
  17. /* Additional bytes needed by arch in front of individual sections */
  18. unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
  19. /* Allocator used for allocating struct module, core sections and init
  20. sections. Returns NULL on failure. */
  21. void *module_alloc(unsigned long size);
  22. /* Free memory returned from module_alloc. */
  23. void module_free(struct module *mod, void *module_region);
  24. /* Apply the given relocation to the (simplified) ELF. Return -error
  25. or 0. */
  26. int apply_relocate(Elf_Shdr *sechdrs,
  27. const char *strtab,
  28. unsigned int symindex,
  29. unsigned int relsec,
  30. struct module *mod);
  31. /* Apply the given add relocation to the (simplified) ELF. Return
  32. -error or 0 */
  33. int apply_relocate_add(Elf_Shdr *sechdrs,
  34. const char *strtab,
  35. unsigned int symindex,
  36. unsigned int relsec,
  37. struct module *mod);
  38. /* Any final processing of module before access. Return -error or 0. */
  39. int module_finalize(const Elf_Ehdr *hdr,
  40. const Elf_Shdr *sechdrs,
  41. struct module *mod);
  42. /* Any cleanup needed when module leaves. */
  43. void module_arch_cleanup(struct module *mod);
  44. #endif