24 #include <linux/elf.h>
27 #include <linux/slab.h>
29 #include <linux/string.h>
30 #include <linux/kernel.h>
34 #include <asm/pgtable.h>
50 __builtin_return_address(0));
69 pr_err(
"module %s: dangerous R_MIPS_26 REL relocation\n",
74 if ((v & 0xf0000000) != (((
unsigned long)location + 4) & 0xf0000000)) {
76 "module %s: relocation overflow\n",
81 *location = (*location & ~0x03ffffff) |
82 ((*location + (v >> 2)) & 0x03ffffff);
102 n->
next = me->arch.r_mips_hi16_list;
103 me->arch.r_mips_hi16_list =
n;
108 static void free_relocation_chain(
struct mips_hi16 *
l)
126 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000;
128 if (me->arch.r_mips_hi16_list !=
NULL) {
129 l = me->arch.r_mips_hi16_list;
147 val = ((insn & 0xffff) << 16) + vallo;
154 val = ((val >> 16) + ((val & 0x8000) != 0)) & 0xffff;
156 insn = (insn & ~0xffff) | val;
164 me->arch.r_mips_hi16_list =
NULL;
171 insnlo = (insnlo & ~0xffff) | (val & 0xffff);
177 free_relocation_chain(l);
178 me->arch.r_mips_hi16_list =
NULL;
180 pr_err(
"module %s: dangerous R_MIPS_LO16 REL relocation\n", me->
name);
195 unsigned int symindex,
unsigned int relsec,
198 Elf_Mips_Rel *rel = (
void *) sechdrs[relsec].sh_addr;
205 pr_debug(
"Applying relocate section %u to %u\n", relsec,
206 sechdrs[relsec].sh_info);
208 me->arch.r_mips_hi16_list =
NULL;
209 for (i = 0; i < sechdrs[relsec].sh_size /
sizeof(*rel); i++) {
211 location = (
void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
214 sym = (
Elf_Sym *)sechdrs[symindex].sh_addr
215 + ELF_MIPS_R_SYM(rel[i]);
221 me->
name, strtab + sym->st_name);
227 res = reloc_handlers_rel[ELF_MIPS_R_TYPE(rel[i])](me,
location,
v);
238 if (me->arch.r_mips_hi16_list) {
239 free_relocation_chain(me->arch.r_mips_hi16_list);
240 me->arch.r_mips_hi16_list =
NULL;
261 spin_unlock_irqrestore(&dbe_lock, flags);
274 char *secstrings = (
void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
277 jump_label_apply_nops(me);
279 INIT_LIST_HEAD(&me->arch.dbe_list);
280 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
281 if (
strcmp(
"__dbe_table", secstrings + s->sh_name) != 0)
283 me->arch.dbe_start = (
void *)s->sh_addr;
284 me->arch.dbe_end = (
void *)s->sh_addr + s->sh_size;
285 spin_lock_irq(&dbe_lock);
286 list_add(&me->arch.dbe_list, &
dbe_list);
287 spin_unlock_irq(&dbe_lock);
294 spin_lock_irq(&dbe_lock);
296 spin_unlock_irq(&dbe_lock);