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

TOMOYO Linux Cross Reference
Linux/arch/hexagon/kernel/module.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/hexagon/kernel/module.c (Architecture ppc) and /arch/m68k/kernel/module.c (Architecture m68k)


  1 // SPDX-License-Identifier: GPL-2.0-only       << 
  2 /*                                                  1 /*
  3  * Kernel module loader for Hexagon            !!   2  * This file is subject to the terms and conditions of the GNU General Public
  4  *                                             !!   3  * License.  See the file COPYING in the main directory of this archive
  5  * Copyright (c) 2010-2011, The Linux Foundati !!   4  * for more details.
  6  */                                                 5  */
  7                                                     6 
  8 #include <asm/module.h>                        << 
  9 #include <linux/elf.h>                         << 
 10 #include <linux/module.h>                      << 
 11 #include <linux/moduleloader.h>                     7 #include <linux/moduleloader.h>
                                                   >>   8 #include <linux/elf.h>
 12 #include <linux/vmalloc.h>                          9 #include <linux/vmalloc.h>
                                                   >>  10 #include <linux/fs.h>
                                                   >>  11 #include <linux/string.h>
                                                   >>  12 #include <linux/kernel.h>
 13                                                    13 
 14 #if 0                                              14 #if 0
 15 #define DEBUGP printk                          !!  15 #define DEBUGP(fmt, ...) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 16 #else                                              16 #else
 17 #define DEBUGP(fmt , ...)                      !!  17 #define DEBUGP(fmt, ...) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 18 #endif                                             18 #endif
 19                                                    19 
 20 /*                                             !!  20 #ifdef CONFIG_MODULES
 21  * module_frob_arch_sections - tweak got/plt s !!  21 
 22  * @hdr - pointer to elf header                !!  22 int apply_relocate(Elf32_Shdr *sechdrs,
 23  * @sechdrs - pointer to elf load section head !!  23                    const char *strtab,
 24  * @secstrings - symbol names                  !!  24                    unsigned int symindex,
 25  * @mod - pointer to module                    !!  25                    unsigned int relsec,
 26  */                                            !!  26                    struct module *me)
 27 int module_frob_arch_sections(Elf_Ehdr *hdr, E << 
 28                                 char *secstrin << 
 29                                 struct module  << 
 30 {                                                  27 {
 31         unsigned int i;                            28         unsigned int i;
 32         int found = 0;                         !!  29         Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
 33                                                !!  30         Elf32_Sym *sym;
 34         /* Look for .plt and/or .got.plt and/o !!  31         uint32_t *location;
 35         for (i = 0; i < hdr->e_shnum; i++) {   << 
 36                 DEBUGP("Section %d is %s\n", i << 
 37                        secstrings + sechdrs[i] << 
 38                 if (strcmp(secstrings + sechdr << 
 39                         found = i+1;           << 
 40                 if (strcmp(secstrings + sechdr << 
 41                         found = i+1;           << 
 42                 if (strcmp(secstrings + sechdr << 
 43                         found = i+1;           << 
 44         }                                      << 
 45                                                    32 
 46         /* At this time, we don't support modu !!  33         DEBUGP("Applying relocate section %u to %u\n", relsec,
 47         if (found) {                           !!  34                sechdrs[relsec].sh_info);
 48                 printk(KERN_WARNING            !!  35         for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
 49                         "Module '%s' contains  !!  36                 /* This is where to make the change */
 50                         mod->name);            !!  37                 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
 51                 /*  return -ENOEXEC;  */       !!  38                         + rel[i].r_offset;
                                                   >>  39                 /* This is the symbol it is referring to.  Note that all
                                                   >>  40                    undefined symbols have been resolved.  */
                                                   >>  41                 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
                                                   >>  42                         + ELF32_R_SYM(rel[i].r_info);
                                                   >>  43 
                                                   >>  44                 switch (ELF32_R_TYPE(rel[i].r_info)) {
                                                   >>  45                 case R_68K_32:
                                                   >>  46                         /* We add the value into the location given */
                                                   >>  47                         *location += sym->st_value;
                                                   >>  48                         break;
                                                   >>  49                 case R_68K_PC32:
                                                   >>  50                         /* Add the value, subtract its position */
                                                   >>  51                         *location += sym->st_value - (uint32_t)location;
                                                   >>  52                         break;
                                                   >>  53                 default:
                                                   >>  54                         pr_err("module %s: Unknown relocation: %u\n", me->name,
                                                   >>  55                                ELF32_R_TYPE(rel[i].r_info));
                                                   >>  56                         return -ENOEXEC;
                                                   >>  57                 }
 52         }                                          58         }
 53                                                << 
 54         return 0;                                  59         return 0;
 55 }                                                  60 }
 56                                                    61 
 57 /*                                             !!  62 int apply_relocate_add(Elf32_Shdr *sechdrs,
 58  * apply_relocate_add - perform rela relocatio !!  63                        const char *strtab,
 59  * @sechdrs - pointer to section headers       !!  64                        unsigned int symindex,
 60  * @strtab - some sort of start address?       !!  65                        unsigned int relsec,
 61  * @symindex - symbol index offset or somethin !!  66                        struct module *me)
 62  * @relsec - address to relocate to?           << 
 63  * @module - pointer to module                 << 
 64  *                                             << 
 65  * Perform rela relocations.                   << 
 66  */                                            << 
 67 int apply_relocate_add(Elf_Shdr *sechdrs, cons << 
 68                         unsigned int symindex, << 
 69                         struct module *module) << 
 70 {                                                  67 {
 71         unsigned int i;                            68         unsigned int i;
                                                   >>  69         Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
 72         Elf32_Sym *sym;                            70         Elf32_Sym *sym;
 73         uint32_t *location;                        71         uint32_t *location;
 74         uint32_t value;                        !!  72 
 75         unsigned int nrelocs = sechdrs[relsec] !!  73         DEBUGP("Applying relocate_add section %u to %u\n", relsec,
 76         Elf32_Rela *rela = (void *)sechdrs[rel !!  74                sechdrs[relsec].sh_info);
 77         Elf32_Word sym_info = sechdrs[relsec]. !!  75         for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
 78         Elf32_Sym *sym_base = (Elf32_Sym *) se !!  76                 /* This is where to make the change */
 79         void *loc_base = (void *) sechdrs[sym_ !!  77                 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
 80                                                !!  78                         + rel[i].r_offset;
 81         DEBUGP("Applying relocations in sectio !!  79                 /* This is the symbol it is referring to.  Note that all
 82                relsec, sym_info, loc_base);    !!  80                    undefined symbols have been resolved.  */
 83                                                !!  81                 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
 84         for (i = 0; i < nrelocs; i++) {        !!  82                         + ELF32_R_SYM(rel[i].r_info);
 85                                                !!  83 
 86                 /* Symbol to relocate */       !!  84                 switch (ELF32_R_TYPE(rel[i].r_info)) {
 87                 sym = sym_base + ELF32_R_SYM(r !!  85                 case R_68K_32:
 88                                                !!  86                         /* We add the value into the location given */
 89                 /* Where to make the change */ !!  87                         *location = rel[i].r_addend + sym->st_value;
 90                 location = loc_base + rela[i]. !!  88                         break;
 91                                                !!  89                 case R_68K_PC32:
 92                 /* `Everything is relative'. * !!  90                         /* Add the value, subtract its position */
 93                 value = sym->st_value + rela[i !!  91                         *location = rel[i].r_addend + sym->st_value - (uint32_t)location;
 94                                                << 
 95                 DEBUGP("%d: value=%08x loc=%p  << 
 96                        i, value, location, ELF << 
 97                        sym->st_name ?          << 
 98                        &strtab[sym->st_name] : << 
 99                                                << 
100                 switch (ELF32_R_TYPE(rela[i].r << 
101                 case R_HEXAGON_B22_PCREL: {    << 
102                         int dist = (int)(value << 
103                         if ((dist < -0x0080000 << 
104                             (dist >= 0x0080000 << 
105                                 printk(KERN_ER << 
106                                        "%s: %s << 
107                                        module- << 
108                                        "R_HEXA << 
109                                        dist, v << 
110                                        sym->st << 
111                                        &strtab << 
112                                 return -ENOEXE << 
113                         }                      << 
114                         DEBUGP("B22_PCREL cont << 
115                         *location &= ~0x01ff3f << 
116                         *location |= 0x00003ff << 
117                         *location |= 0x01ff000 << 
118                         DEBUGP("Contents after << 
119                         break;                     92                         break;
120                 }                              << 
121                 case R_HEXAGON_HI16:           << 
122                         value = (value>>16) &  << 
123                         fallthrough;           << 
124                 case R_HEXAGON_LO16:           << 
125                         *location &= ~0x00c03f << 
126                         *location |= value & 0 << 
127                         *location |= (value &  << 
128                         break;                 << 
129                 case R_HEXAGON_32:             << 
130                         *location = value;     << 
131                         break;                 << 
132                 case R_HEXAGON_32_PCREL:       << 
133                         *location = value - (u << 
134                         break;                 << 
135                 case R_HEXAGON_PLT_B22_PCREL:  << 
136                 case R_HEXAGON_GOTOFF_LO16:    << 
137                 case R_HEXAGON_GOTOFF_HI16:    << 
138                         printk(KERN_ERR "%s: G << 
139                                module->name);  << 
140                         return -ENOEXEC;       << 
141                 default:                           93                 default:
142                         printk(KERN_ERR "%s: u !!  94                         pr_err("module %s: Unknown relocation: %u\n", me->name,
143                                module->name,   !!  95                                ELF32_R_TYPE(rel[i].r_info));
144                                ELF32_R_TYPE(re << 
145                         return -ENOEXEC;           96                         return -ENOEXEC;
146                 }                                  97                 }
147         }                                          98         }
148         return 0;                                  99         return 0;
                                                   >> 100 }
                                                   >> 101 
                                                   >> 102 int module_finalize(const Elf_Ehdr *hdr,
                                                   >> 103                     const Elf_Shdr *sechdrs,
                                                   >> 104                     struct module *mod)
                                                   >> 105 {
                                                   >> 106         module_fixup(mod, mod->arch.fixup_start, mod->arch.fixup_end);
                                                   >> 107         return 0;
                                                   >> 108 }
                                                   >> 109 
                                                   >> 110 #endif /* CONFIG_MODULES */
                                                   >> 111 
                                                   >> 112 void module_fixup(struct module *mod, struct m68k_fixup_info *start,
                                                   >> 113                   struct m68k_fixup_info *end)
                                                   >> 114 {
                                                   >> 115 #ifdef CONFIG_MMU
                                                   >> 116         struct m68k_fixup_info *fixup;
                                                   >> 117 
                                                   >> 118         for (fixup = start; fixup < end; fixup++) {
                                                   >> 119                 switch (fixup->type) {
                                                   >> 120                 case m68k_fixup_memoffset:
                                                   >> 121                         *(u32 *)fixup->addr = m68k_memoffset;
                                                   >> 122                         break;
                                                   >> 123                 case m68k_fixup_vnode_shift:
                                                   >> 124                         *(u16 *)fixup->addr += m68k_virt_to_node_shift;
                                                   >> 125                         break;
                                                   >> 126                 }
                                                   >> 127         }
                                                   >> 128 #endif
149 }                                                 129 }
150                                                   130 

~ [ 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