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

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

Version: ~ [ linux-5.13-rc5 ] ~ [ linux-5.12.9 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.42 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.124 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.193 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.235 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.271 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.271 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * OpenRISC module.c
  3  *
  4  * Linux architectural port borrowing liberally from similar works of
  5  * others.  All original copyrights apply as per the original source
  6  * declaration.
  7  *
  8  * Modifications for the OpenRISC architecture:
  9  * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
 10  *
 11  *      This program is free software; you can redistribute it and/or
 12  *      modify it under the terms of the GNU General Public License
 13  *      as published by the Free Software Foundation; either version
 14  *      2 of the License, or (at your option) any later version.
 15  */
 16 
 17 #include <linux/moduleloader.h>
 18 #include <linux/elf.h>
 19 
 20 int apply_relocate_add(Elf32_Shdr *sechdrs,
 21                        const char *strtab,
 22                        unsigned int symindex,
 23                        unsigned int relsec,
 24                        struct module *me)
 25 {
 26         unsigned int i;
 27         Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
 28         Elf32_Sym *sym;
 29         uint32_t *location;
 30         uint32_t value;
 31 
 32         pr_debug("Applying relocate section %u to %u\n", relsec,
 33                  sechdrs[relsec].sh_info);
 34         for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
 35                 /* This is where to make the change */
 36                 location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
 37                         + rel[i].r_offset;
 38 
 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                 value = sym->st_value + rel[i].r_addend;
 44 
 45                 switch (ELF32_R_TYPE(rel[i].r_info)) {
 46                 case R_OR32_32:
 47                         *location = value;
 48                         break;
 49                 case R_OR32_CONST:
 50                         *((uint16_t *)location + 1) = value;
 51                         break;
 52                 case R_OR32_CONSTH:
 53                         *((uint16_t *)location + 1) = value >> 16;
 54                         break;
 55                 case R_OR32_JUMPTARG:
 56                         value -= (uint32_t)location;
 57                         value >>= 2;
 58                         value &= 0x03ffffff;
 59                         value |= *location & 0xfc000000;
 60                         *location = value;
 61                         break;
 62                 default:
 63                         pr_err("module %s: Unknown relocation: %u\n",
 64                                me->name, ELF32_R_TYPE(rel[i].r_info));
 65                         break;
 66                 }
 67         }
 68 
 69         return 0;
 70 }
 71 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp