~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/moduleloader.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_MODULELOADER_H
  3 #define _LINUX_MODULELOADER_H
  4 /* The stuff needed for archs to support modules. */
  5 
  6 #include <linux/module.h>
  7 #include <linux/elf.h>
  8 
  9 /* These may be implemented by architectures that need to hook into the
 10  * module loader code.  Architectures that don't need to do anything special
 11  * can just rely on the 'weak' default hooks defined in kernel/module.c.
 12  * Note, however, that at least one of apply_relocate or apply_relocate_add
 13  * must be implemented by each architecture.
 14  */
 15 
 16 /* arch may override to do additional checking of ELF header architecture */
 17 bool module_elf_check_arch(Elf_Ehdr *hdr);
 18 
 19 /* Adjust arch-specific sections.  Return 0 on success.  */
 20 int module_frob_arch_sections(Elf_Ehdr *hdr,
 21                               Elf_Shdr *sechdrs,
 22                               char *secstrings,
 23                               struct module *mod);
 24 
 25 /* Additional bytes needed by arch in front of individual sections */
 26 unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
 27 
 28 /* Determines if the section name is an init section (that is only used during
 29  * module loading).
 30  */
 31 bool module_init_section(const char *name);
 32 
 33 /* Determines if the section name is an exit section (that is only used during
 34  * module unloading)
 35  */
 36 bool module_exit_section(const char *name);
 37 
 38 /* Describes whether within_module_init() will consider this an init section
 39  * or not. This behaviour changes with CONFIG_MODULE_UNLOAD.
 40  */
 41 bool module_init_layout_section(const char *sname);
 42 
 43 /*
 44  * Apply the given relocation to the (simplified) ELF.  Return -error
 45  * or 0.
 46  */
 47 #ifdef CONFIG_MODULES_USE_ELF_REL
 48 int apply_relocate(Elf_Shdr *sechdrs,
 49                    const char *strtab,
 50                    unsigned int symindex,
 51                    unsigned int relsec,
 52                    struct module *mod);
 53 #else
 54 static inline int apply_relocate(Elf_Shdr *sechdrs,
 55                                  const char *strtab,
 56                                  unsigned int symindex,
 57                                  unsigned int relsec,
 58                                  struct module *me)
 59 {
 60         printk(KERN_ERR "module %s: REL relocation unsupported\n",
 61                module_name(me));
 62         return -ENOEXEC;
 63 }
 64 #endif
 65 
 66 /*
 67  * Apply the given add relocation to the (simplified) ELF.  Return
 68  * -error or 0
 69  */
 70 #ifdef CONFIG_MODULES_USE_ELF_RELA
 71 int apply_relocate_add(Elf_Shdr *sechdrs,
 72                        const char *strtab,
 73                        unsigned int symindex,
 74                        unsigned int relsec,
 75                        struct module *mod);
 76 #ifdef CONFIG_LIVEPATCH
 77 /*
 78  * Some architectures (namely x86_64 and ppc64) perform sanity checks when
 79  * applying relocations.  If a patched module gets unloaded and then later
 80  * reloaded (and re-patched), klp re-applies relocations to the replacement
 81  * function(s).  Any leftover relocations from the previous loading of the
 82  * patched module might trigger the sanity checks.
 83  *
 84  * To prevent that, when unloading a patched module, clear out any relocations
 85  * that might trigger arch-specific sanity checks on a future module reload.
 86  */
 87 void clear_relocate_add(Elf_Shdr *sechdrs,
 88                    const char *strtab,
 89                    unsigned int symindex,
 90                    unsigned int relsec,
 91                    struct module *me);
 92 #endif
 93 #else
 94 static inline int apply_relocate_add(Elf_Shdr *sechdrs,
 95                                      const char *strtab,
 96                                      unsigned int symindex,
 97                                      unsigned int relsec,
 98                                      struct module *me)
 99 {
100         printk(KERN_ERR "module %s: REL relocation unsupported\n",
101                module_name(me));
102         return -ENOEXEC;
103 }
104 #endif
105 
106 /* Any final processing of module before access.  Return -error or 0. */
107 int module_finalize(const Elf_Ehdr *hdr,
108                     const Elf_Shdr *sechdrs,
109                     struct module *mod);
110 
111 #ifdef CONFIG_MODULES
112 void flush_module_init_free_work(void);
113 #else
114 static inline void flush_module_init_free_work(void)
115 {
116 }
117 #endif
118 
119 /* Any cleanup needed when module leaves. */
120 void module_arch_cleanup(struct module *mod);
121 
122 /* Any cleanup before freeing mod->module_init */
123 void module_arch_freeing_init(struct module *mod);
124 
125 #endif
126 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php